Delphi ActiveX Stripe: Update a Refund

Back to Index

Updates the specified refund by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

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

CURL Command

curl https://api.stripe.com/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0 \
   -u STRIPE_SECRET_KEY:
   -X POST

Delphi ActiveX Example

var
rest: TChilkatRest;
success: Integer;
bTls: Integer;
port: Integer;
bAutoReconnect: Integer;
sbResponseBody: TChilkatStringBuilder;
jsonResponse: TChilkatJsonObject;
id: WideString;
object: WideString;
amount: Integer;
balance_transaction: WideString;
charge: WideString;
created: Integer;
currency: WideString;
metadataKey: WideString;
reason: Integer;
receipt_number: Integer;
status: WideString;

begin
rest := TChilkatRest.Create(Self);

//  URL: https://api.stripe.com/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0
bTls := 1;
port := 443;
bAutoReconnect := 1;
success := rest.Connect('api.stripe.com',port,bTls,bAutoReconnect);
if (success <> 1) then
  begin
    Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(rest.ConnectFailReason));
    Memo1.Lines.Add(rest.LastErrorText);
    Exit;
  end;

rest.SetAuthBasic('STRIPE_SECRET_KEY','');

sbResponseBody := TChilkatStringBuilder.Create(Self);
success := rest.FullRequestNoBodySb('POST','/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0',sbResponseBody.ControlInterface);
if (success <> 1) then
  begin
    Memo1.Lines.Add(rest.LastErrorText);
    Exit;
  end;

jsonResponse := TChilkatJsonObject.Create(Self);
jsonResponse.LoadSb(sbResponseBody.ControlInterface);

id := jsonResponse.StringOf('id');
object := jsonResponse.StringOf('object');
amount := jsonResponse.IntOf('amount');
balance_transaction := jsonResponse.StringOf('balance_transaction');
charge := jsonResponse.StringOf('charge');
created := jsonResponse.IntOf('created');
currency := jsonResponse.StringOf('currency');
metadataKey := jsonResponse.StringOf('metadata.key');
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": "txn_1BnETKGswQrCoh0X762wrMpF",
  "charge": "ch_1BnETKGswQrCoh0XE7kJI2wj",
  "created": 1516662782,
  "currency": "usd",
  "metadata": {
    "key": "value"
  },
  "reason": null,
  "receipt_number": null,
  "status": "succeeded"
}