Xojo Plugin Stripe: Create a Refund

Back to Index

Creates a new refund to refund a charge that has previously been created but not yet refunded.

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

CURL Command

curl https://api.stripe.com/v1/refunds \
   -d charge=ch_1BnETKGswQrCoh0XE7kJI2wj
   -X POST

Xojo Plugin Example

Dim rest As New Chilkat.Rest
Dim success As Boolean

//  URL: https://api.stripe.com/v1/refunds
Dim bTls As Boolean
bTls = True
Dim port As Int32
port = 443
Dim bAutoReconnect As Boolean
bAutoReconnect = True
success = rest.Connect("api.stripe.com",port,bTls,bAutoReconnect)
If (success <> True) Then
    System.DebugLog("ConnectFailReason: " + Str(rest.ConnectFailReason))
End If



Dim strResponseBody As String
strResponseBody = rest.FullRequestFormUrlEncoded("POST","/v1/refunds")
If (rest.LastMethodSuccess <> True) Then
End If

Dim jsonResponse As New Chilkat.JsonObject

Dim id As String
Dim object As String
Dim amount As Int32
Dim balance_transaction As Boolean
Dim charge As String
Dim created As Int32
Dim currency As String
Dim reason As Boolean
Dim receipt_number As Boolean
Dim status As String

id = jsonResponse.StringOf("id")
object = jsonResponse.StringOf("object")
amount = jsonResponse.IntOf("amount")
balance_transaction = jsonResponse.IsNullOf("balance_transaction")
charge = jsonResponse.StringOf("charge")
created = jsonResponse.IntOf("created")
currency = jsonResponse.StringOf("currency")
reason = jsonResponse.IsNullOf("reason")
receipt_number = jsonResponse.IsNullOf("receipt_number")
status = jsonResponse.StringOf("status")

Sample JSON Response Body

  "id": "re_1BnETKGswQrCoh0XT2qLx7S0",
  "object": "refund",
  "amount": 100,
  "balance_transaction": null,
  "charge": "ch_1BnETKGswQrCoh0XE7kJI2wj",
  "created": 1516662782,
  "currency": "usd",
  "metadata": {},
  "reason": null,
  "receipt_number": null,
  "status": "succeeded"