PHP Extension Stripe: Retrieve a Refund

Back to Index

Retrieves the details of an existing refund.

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

CURL Command

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

PHP Extension Example

<?php

// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:
include("chilkat_9_5_0.php");

$rest = new CkRest();

//  URL: https://api.stripe.com/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0
$bTls = true;
$port = 443;
$bAutoReconnect = true;
$success = $rest->Connect('api.stripe.com',$port,$bTls,$bAutoReconnect);
if ($success != true) {
    print 'ConnectFailReason: ' . $rest->get_ConnectFailReason() . "\n";
    print $rest->lastErrorText() . "\n";
    exit;
}

$rest->SetAuthBasic('STRIPE_SECRET_KEY','');

$sbResponseBody = new CkStringBuilder();
$success = $rest->FullRequestNoBodySb('GET','/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0',$sbResponseBody);
if ($success != true) {
    print $rest->lastErrorText() . "\n";
    exit;
}

$jsonResponse = new CkJsonObject();
$jsonResponse->LoadSb($sbResponseBody);

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