Creates a coupon object.
curl https://api.stripe.com/v1/coupons \
-u STRIPE_SECRET_KEY: \
-d percent_off=25 \
-d duration=repeating \
-d duration_in_months=3 \
-d id=25OFF \
-X POST
LOCAL loRest
LOCAL lnSuccess
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL lcStrResponseBody
LOCAL loJsonResponse
LOCAL lcId
LOCAL lcObject
LOCAL lnAmount_off
LOCAL lnCreated
LOCAL lnCurrency
LOCAL lcDuration
LOCAL lnDuration_in_months
LOCAL lnLivemode
LOCAL lnMax_redemptions
LOCAL lnPercent_off
LOCAL lnRedeem_by
LOCAL lnTimes_redeemed
LOCAL lnValid
loRest = CreateObject('Chilkat_9_5_0.Rest')
* URL: https://api.stripe.com/v1/coupons
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("api.stripe.com",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
? loRest.LastErrorText
RELEASE loRest
CANCEL
ENDIF
loRest.SetAuthBasic("STRIPE_SECRET_KEY","")
loRest.AddQueryParam("percent_off","25")
loRest.AddQueryParam("duration","repeating")
loRest.AddQueryParam("duration_in_months","3")
loRest.AddQueryParam("id","25OFF")
lcStrResponseBody = loRest.FullRequestFormUrlEncoded("POST","/v1/coupons")
IF (loRest.LastMethodSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
CANCEL
ENDIF
loJsonResponse = CreateObject('Chilkat_9_5_0.JsonObject')
loJsonResponse.Load(lcStrResponseBody)
lcId = loJsonResponse.StringOf("id")
lcObject = loJsonResponse.StringOf("object")
lnAmount_off = loJsonResponse.IsNullOf("amount_off")
lnCreated = loJsonResponse.IntOf("created")
lnCurrency = loJsonResponse.IsNullOf("currency")
lcDuration = loJsonResponse.StringOf("duration")
lnDuration_in_months = loJsonResponse.IntOf("duration_in_months")
lnLivemode = loJsonResponse.BoolOf("livemode")
lnMax_redemptions = loJsonResponse.IsNullOf("max_redemptions")
lnPercent_off = loJsonResponse.IntOf("percent_off")
lnRedeem_by = loJsonResponse.IsNullOf("redeem_by")
lnTimes_redeemed = loJsonResponse.IntOf("times_redeemed")
lnValid = loJsonResponse.BoolOf("valid")
RELEASE loRest
RELEASE loJsonResponse
{
"id": "25OFF",
"object": "coupon",
"amount_off": null,
"created": 1516662783,
"currency": null,
"duration": "repeating",
"duration_in_months": 3,
"livemode": false,
"max_redemptions": null,
"metadata": {},
"percent_off": 25,
"redeem_by": null,
"times_redeemed": 0,
"valid": true
}