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
integer li_rc
oleobject loo_Rest
integer li_Success
integer li_BTls
integer li_Port
integer li_BAutoReconnect
string ls_StrResponseBody
oleobject loo_JsonResponse
string ls_Id
string ls_Object
integer li_Amount_off
integer li_Created
integer li_Currency
string ls_Duration
integer li_Duration_in_months
integer li_Livemode
integer li_Max_redemptions
integer li_Percent_off
integer li_Redeem_by
integer li_Times_redeemed
integer li_Valid
loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest")
if li_rc < 0 then
destroy loo_Rest
MessageBox("Error","Connecting to COM object failed")
return
end if
// URL: https://api.stripe.com/v1/coupons
li_BTls = 1
li_Port = 443
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("api.stripe.com",li_Port,li_BTls,li_BAutoReconnect)
if li_Success <> 1 then
Write-Debug "ConnectFailReason: " + string(loo_Rest.ConnectFailReason)
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
return
end if
loo_Rest.SetAuthBasic("STRIPE_SECRET_KEY","")
loo_Rest.AddQueryParam("percent_off","25")
loo_Rest.AddQueryParam("duration","repeating")
loo_Rest.AddQueryParam("duration_in_months","3")
loo_Rest.AddQueryParam("id","25OFF")
ls_StrResponseBody = loo_Rest.FullRequestFormUrlEncoded("POST","/v1/coupons")
if loo_Rest.LastMethodSuccess <> 1 then
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
return
end if
loo_JsonResponse = create oleobject
li_rc = loo_JsonResponse.ConnectToNewObject("Chilkat_9_5_0.JsonObject")
loo_JsonResponse.Load(ls_StrResponseBody)
ls_Id = loo_JsonResponse.StringOf("id")
ls_Object = loo_JsonResponse.StringOf("object")
li_Amount_off = loo_JsonResponse.IsNullOf("amount_off")
li_Created = loo_JsonResponse.IntOf("created")
li_Currency = loo_JsonResponse.IsNullOf("currency")
ls_Duration = loo_JsonResponse.StringOf("duration")
li_Duration_in_months = loo_JsonResponse.IntOf("duration_in_months")
li_Livemode = loo_JsonResponse.BoolOf("livemode")
li_Max_redemptions = loo_JsonResponse.IsNullOf("max_redemptions")
li_Percent_off = loo_JsonResponse.IntOf("percent_off")
li_Redeem_by = loo_JsonResponse.IsNullOf("redeem_by")
li_Times_redeemed = loo_JsonResponse.IntOf("times_redeemed")
li_Valid = loo_JsonResponse.BoolOf("valid")
destroy loo_Rest
destroy loo_JsonResponse
{
"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
}