Objective-C 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:

Objective-C Example

#import <CkoRest.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>

CkoRest *rest = [[CkoRest alloc] init];
BOOL success;

//  URL: https://api.stripe.com/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0
BOOL bTls = YES;
int port = 443;
BOOL bAutoReconnect = YES;
success = [rest Connect: @"api.stripe.com" port: [NSNumber numberWithInt: port] tls: bTls autoReconnect: bAutoReconnect];
if (success != YES) {
    NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);
    NSLog(@"%@",rest.LastErrorText);
    return;
}

[rest SetAuthBasic: @"STRIPE_SECRET_KEY" password: @""];

CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestNoBodySb: @"GET" uriPath: @"/v1/refunds/re_1BnETKGswQrCoh0XT2qLx7S0" sb: sbResponseBody];
if (success != YES) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}

CkoJsonObject *jsonResponse = [[CkoJsonObject alloc] init];
[jsonResponse LoadSb: sbResponseBody];

NSString *id = 0;
NSString *object = 0;
int amount;
BOOL balance_transaction;
NSString *charge = 0;
int created;
NSString *currency = 0;
BOOL reason;
BOOL receipt_number;
NSString *status = 0;

id = [jsonResponse StringOf: @"id"];
object = [jsonResponse StringOf: @"object"];
amount = [[jsonResponse IntOf: @"amount"] intValue];
balance_transaction = [jsonResponse IsNullOf: @"balance_transaction"];
charge = [jsonResponse StringOf: @"charge"];
created = [[jsonResponse IntOf: @"created"] intValue];
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"
}