Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable.
curl https://api.stripe.com/v1/coupons/25OFF \
-u STRIPE_SECRET_KEY: \
-d metadata[order_id]=6735 \
-X POST
Chilkat.Rest rest = new Chilkat.Rest();
bool success;
// URL: https://api.stripe.com/v1/coupons/25OFF
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","");
rest.AddQueryParam("metadata[order_id]","6735");
string strResponseBody = await rest.FullRequestFormUrlEncodedAsync("POST","/v1/coupons/25OFF");
if (rest.LastMethodSuccess != true) {
Debug.WriteLine(rest.LastErrorText);
return;
}
Chilkat.JsonObject jsonResponse = new Chilkat.JsonObject();
jsonResponse.Load(strResponseBody);
string id;
string object;
bool amount_off;
int created;
bool currency;
string duration;
int duration_in_months;
bool livemode;
bool max_redemptions;
string metadataOrder_id;
int percent_off;
bool redeem_by;
int times_redeemed;
bool valid;
id = jsonResponse.StringOf("id");
object = jsonResponse.StringOf("object");
amount_off = jsonResponse.IsNullOf("amount_off");
created = jsonResponse.IntOf("created");
currency = jsonResponse.IsNullOf("currency");
duration = jsonResponse.StringOf("duration");
duration_in_months = jsonResponse.IntOf("duration_in_months");
livemode = jsonResponse.BoolOf("livemode");
max_redemptions = jsonResponse.IsNullOf("max_redemptions");
metadataOrder_id = jsonResponse.StringOf("metadata.order_id");
percent_off = jsonResponse.IntOf("percent_off");
redeem_by = jsonResponse.IsNullOf("redeem_by");
times_redeemed = jsonResponse.IntOf("times_redeemed");
valid = jsonResponse.BoolOf("valid");
{
"id": "25OFF",
"object": "coupon",
"amount_off": null,
"created": 1516662783,
"currency": null,
"duration": "repeating",
"duration_in_months": 3,
"livemode": false,
"max_redemptions": null,
"metadata": {
"order_id": "6735"
},
"percent_off": 25,
"redeem_by": null,
"times_redeemed": 0,
"valid": true
}