Creates a new refund to refund a charge that has previously been created but not yet refunded.
curl https://api.stripe.com/v1/refunds \
-u STRIPE_SECRET_KEY: \
-d charge=ch_1BnETKGswQrCoh0XE7kJI2wj
-X POST
#import <CkoRest.h>
#import <NSString.h>
#import <CkoJsonObject.h>
CkoRest *rest = [[CkoRest alloc] init];
BOOL success;
// URL: https://api.stripe.com/v1/refunds
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: @""];
[rest AddQueryParam: @"charge" value: @"ch_1BnETKGswQrCoh0XE7kJI2wj"];
NSString *strResponseBody = [rest FullRequestFormUrlEncoded: @"POST" uriPath: @"/v1/refunds"];
if (rest.LastMethodSuccess != YES) {
NSLog(@"%@",rest.LastErrorText);
return;
}
CkoJsonObject *jsonResponse = [[CkoJsonObject alloc] init];
[jsonResponse Load: strResponseBody];
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"];
{
"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"
}