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
Dim rest As New ChilkatRest
Dim success As Long
' URL: https://api.stripe.com/v1/coupons/25OFF
Dim bTls As Long
bTls = 1
Dim port As Long
port = 443
Dim bAutoReconnect As Long
bAutoReconnect = 1
success = rest.Connect("api.stripe.com",port,bTls,bAutoReconnect)
If (success <> 1) Then
Debug.Print "ConnectFailReason: " & rest.ConnectFailReason
Debug.Print rest.LastErrorText
Exit Sub
End If
success = rest.SetAuthBasic("STRIPE_SECRET_KEY","")
success = rest.AddQueryParam("metadata[order_id]","6735")
Dim strResponseBody As String
strResponseBody = rest.FullRequestFormUrlEncoded("POST","/v1/coupons/25OFF")
If (rest.LastMethodSuccess <> 1) Then
Debug.Print rest.LastErrorText
Exit Sub
End If
Dim jsonResponse As New ChilkatJsonObject
success = jsonResponse.Load(strResponseBody)
Dim id As String
Dim object As String
Dim amount_off As Long
Dim created As Long
Dim currency As Long
Dim duration As String
Dim duration_in_months As Long
Dim livemode As Long
Dim max_redemptions As Long
Dim metadataOrder_id As String
Dim percent_off As Long
Dim redeem_by As Long
Dim times_redeemed As Long
Dim valid As Long
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
}