VB.NET UWP/WinRT Stripe: Retrieve a Coupon

Back to Index

Retrieves the coupon with the given ID.

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

CURL Command

curl https://api.stripe.com/v1/coupons/25OFF \
   -u STRIPE_SECRET_KEY:

VB.NET UWP/WinRT Example

Dim rest As New Chilkat.Rest
Dim success As Boolean

'  URL: https://api.stripe.com/v1/coupons/25OFF
Dim bTls As Boolean = True
Dim port As Integer = 443
Dim bAutoReconnect As Boolean = True
success = Await rest.ConnectAsync("api.stripe.com",port,bTls,bAutoReconnect)
If (success <> True) Then
    Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


rest.SetAuthBasic("STRIPE_SECRET_KEY","")


Dim sbResponseBody As New Chilkat.StringBuilder
success = Await rest.FullRequestNoBodySbAsync("GET","/v1/coupons/25OFF",sbResponseBody)
If (success <> True) Then
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


Dim jsonResponse As New Chilkat.JsonObject
jsonResponse.LoadSb(sbResponseBody)

Dim id As String
Dim object As String
Dim amount_off As Boolean
Dim created As Integer
Dim currency As Boolean
Dim duration As String
Dim duration_in_months As Integer
Dim livemode As Boolean
Dim max_redemptions As Boolean
Dim percent_off As Integer
Dim redeem_by As Boolean
Dim times_redeemed As Integer
Dim valid As Boolean

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")
percent_off = jsonResponse.IntOf("percent_off")
redeem_by = jsonResponse.IsNullOf("redeem_by")
times_redeemed = jsonResponse.IntOf("times_redeemed")
valid = jsonResponse.BoolOf("valid")

Sample JSON Response Body

{
  "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
}