Attaches a Source object to a Customer. The source must be in a chargeable state.
curl https://api.stripe.com/v1/customers/cus_CBbg9PmQ9sLbmo/sources \
-u STRIPE_SECRET_KEY: \
-d source=src_1BnETLGswQrCoh0X5KOorXEP \
-X POST
#import <CkoRest.h>
#import <NSString.h>
#import <CkoJsonObject.h>
CkoRest *rest = [[CkoRest alloc] init];
BOOL success;
// URL: https://api.stripe.com/v1/customers/cus_CBbg9PmQ9sLbmo/sources
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: @"source" value: @"src_1BnETLGswQrCoh0X5KOorXEP"];
NSString *strResponseBody = [rest FullRequestFormUrlEncoded: @"POST" uriPath: @"/v1/customers/cus_CBbg9PmQ9sLbmo/sources"];
if (rest.LastMethodSuccess != YES) {
NSLog(@"%@",rest.LastErrorText);
return;
}
CkoJsonObject *jsonResponse = [[CkoJsonObject alloc] init];
[jsonResponse Load: strResponseBody];
NSString *id = 0;
NSString *object = 0;
int amount;
NSString *client_secret = 0;
int created;
NSString *currency = 0;
NSString *flow = 0;
BOOL livemode;
BOOL ownerAddress;
NSString *ownerEmail = 0;
BOOL ownerName;
BOOL ownerPhone;
BOOL ownerVerified_address;
BOOL ownerVerified_email;
BOOL ownerVerified_name;
BOOL ownerVerified_phone;
NSString *receiverAddress = 0;
int receiverAmount_charged;
int receiverAmount_received;
int receiverAmount_returned;
NSString *receiverRefund_attributes_method = 0;
NSString *receiverRefund_attributes_status = 0;
BOOL statement_descriptor;
NSString *status = 0;
NSString *type = 0;
NSString *usage = 0;
NSString *bitcoinAddress = 0;
int bitcoinAmount;
int bitcoinAmount_charged;
int bitcoinAmount_received;
int bitcoinAmount_returned;
NSString *bitcoinUri = 0;
NSString *customer = 0;
id = [jsonResponse StringOf: @"id"];
object = [jsonResponse StringOf: @"object"];
amount = [[jsonResponse IntOf: @"amount"] intValue];
client_secret = [jsonResponse StringOf: @"client_secret"];
created = [[jsonResponse IntOf: @"created"] intValue];
currency = [jsonResponse StringOf: @"currency"];
flow = [jsonResponse StringOf: @"flow"];
livemode = [jsonResponse BoolOf: @"livemode"];
ownerAddress = [jsonResponse IsNullOf: @"owner.address"];
ownerEmail = [jsonResponse StringOf: @"owner.email"];
ownerName = [jsonResponse IsNullOf: @"owner.name"];
ownerPhone = [jsonResponse IsNullOf: @"owner.phone"];
ownerVerified_address = [jsonResponse IsNullOf: @"owner.verified_address"];
ownerVerified_email = [jsonResponse IsNullOf: @"owner.verified_email"];
ownerVerified_name = [jsonResponse IsNullOf: @"owner.verified_name"];
ownerVerified_phone = [jsonResponse IsNullOf: @"owner.verified_phone"];
receiverAddress = [jsonResponse StringOf: @"receiver.address"];
receiverAmount_charged = [[jsonResponse IntOf: @"receiver.amount_charged"] intValue];
receiverAmount_received = [[jsonResponse IntOf: @"receiver.amount_received"] intValue];
receiverAmount_returned = [[jsonResponse IntOf: @"receiver.amount_returned"] intValue];
receiverRefund_attributes_method = [jsonResponse StringOf: @"receiver.refund_attributes_method"];
receiverRefund_attributes_status = [jsonResponse StringOf: @"receiver.refund_attributes_status"];
statement_descriptor = [jsonResponse IsNullOf: @"statement_descriptor"];
status = [jsonResponse StringOf: @"status"];
type = [jsonResponse StringOf: @"type"];
usage = [jsonResponse StringOf: @"usage"];
bitcoinAddress = [jsonResponse StringOf: @"bitcoin.address"];
bitcoinAmount = [[jsonResponse IntOf: @"bitcoin.amount"] intValue];
bitcoinAmount_charged = [[jsonResponse IntOf: @"bitcoin.amount_charged"] intValue];
bitcoinAmount_received = [[jsonResponse IntOf: @"bitcoin.amount_received"] intValue];
bitcoinAmount_returned = [[jsonResponse IntOf: @"bitcoin.amount_returned"] intValue];
bitcoinUri = [jsonResponse StringOf: @"bitcoin.uri"];
customer = [jsonResponse StringOf: @"customer"];
{
"id": "src_1BnETLGswQrCoh0X5KOorXEP",
"object": "source",
"amount": 1000,
"client_secret": "src_client_secret_CBbgdvc1AflN5jN0wQevA2jA",
"created": 1516662783,
"currency": "usd",
"flow": "receiver",
"livemode": false,
"metadata": {},
"owner": {
"address": null,
"email": "jenny.rosen@example.com",
"name": null,
"phone": null,
"verified_address": null,
"verified_email": null,
"verified_name": null,
"verified_phone": null
},
"receiver": {
"address": "test_1MBhWS3uv4ynCfQXF3xQjJkzFPukr4K56N",
"amount_charged": 0,
"amount_received": 0,
"amount_returned": 0,
"refund_attributes_method": "email",
"refund_attributes_status": "missing"
},
"statement_descriptor": null,
"status": "chargeable",
"type": "bitcoin",
"usage": "single_use",
"bitcoin": {
"address": "test_1MBhWS3uv4ynCfQXF3xQjJkzFPukr4K56N",
"amount": 2371000,
"amount_charged": 0,
"amount_received": 0,
"amount_returned": 0,
"uri": "bitcoin:test_1MBhWS3uv4ynCfQXF3xQjJkzFPukr4K56N?amount=0.02371000"
},
"customer": "cus_CBbg9PmQ9sLbmo"
}