C# UWP/WinRT Stripe: Delete a Customer Subscription Discount

Back to Index

Removes the currently applied discount on a subscription.

Documentation: https://stripe.com/docs/api/curl#delete_subscription_discount

CURL Command

curl https://api.stripe.com/v1/subscriptions/sub_CBbgnZGMJwa9ta/discount \
   -u STRIPE_SECRET_KEY: \
   -X DELETE

C# UWP/WinRT Example

Chilkat.Rest rest = new Chilkat.Rest();
bool success;

//  URL: https://api.stripe.com/v1/subscriptions/sub_CBbgnZGMJwa9ta/discount
bool bTls = true;
int port = 443;
bool bAutoReconnect = true;
success = await rest.ConnectAsync("api.stripe.com",port,bTls,bAutoReconnect);
if (success != true) {
    Debug.WriteLine("ConnectFailReason: " + Convert.ToString(rest.ConnectFailReason));
    Debug.WriteLine(rest.LastErrorText);
    return;
}

rest.SetAuthBasic("STRIPE_SECRET_KEY","");

Chilkat.StringBuilder sbResponseBody = new Chilkat.StringBuilder();
success = await rest.FullRequestNoBodySbAsync("DELETE","/v1/subscriptions/sub_CBbgnZGMJwa9ta/discount",sbResponseBody);
if (success != true) {
    Debug.WriteLine(rest.LastErrorText);
    return;
}

Chilkat.JsonObject jsonResponse = new Chilkat.JsonObject();
jsonResponse.LoadSb(sbResponseBody);

bool deleted;
string id;

deleted = jsonResponse.BoolOf("deleted");
id = jsonResponse.StringOf("id");

Sample JSON Response Body

{
  "deleted": true,
  "id": "di_1BnETLGswQrCoh0Xe991uMc7"
}