信用卡繫結(BrainTree)
阿新 • • 發佈:2019-02-01
/**
* 獲取payment-method-once引數
*/
-(void)getPaymentMethodOnceWithClientToken:(NSString *)ClientToken{
// or fetch a client token BTAPIClient *braintreeClient = [[BTAPIClient alloc] initWithAuthorization:ClientToken];
BTCardClient *cardClient = [[BTCardClient alloc] initWithAPIClient:braintreeClient];
BTCard *card = [[BTCard
alloc]
initWithNumber:self.creditNumField.text
expirationMonth:self.monthField.text
expirationYear:self.yearField.text
cvv:self.cvvField.text];
[cardClient tokenizeCard:card
completion:^(BTCardNonce *tokenizedCard, NSError *error) {
// Communicate the tokenizedCard.nonce to your server, or handle error
self.paymentMethodOnce
= tokenizedCard.nonce;
NSLog(@"self.paymentMethodOnce====%@",self.paymentMethodOnce);
if (self.paymentMethodOnce.length > 0) {
//執行繫結方法
[self requestBindCreditCardWithPaymentMethodnonce:self.paymentMethodOnce];
}else{
[[Loading shareLoading] stopLoading];
}
}];
* 獲取payment-method-once引數
*/
-(void)getPaymentMethodOnceWithClientToken:(NSString *)ClientToken{
// or fetch a client token BTAPIClient *braintreeClient = [[BTAPIClient alloc] initWithAuthorization:ClientToken];
BTCardClient *cardClient = [[BTCardClient alloc] initWithAPIClient:braintreeClient];
[cardClient tokenizeCard:card
completion:^(BTCardNonce *tokenizedCard, NSError *error) {
NSLog(@"self.paymentMethodOnce====%@",self.paymentMethodOnce);
if (self.paymentMethodOnce.length > 0) {
//執行繫結方法
[self requestBindCreditCardWithPaymentMethodnonce:self.paymentMethodOnce];
}else{
[[Loading shareLoading] stopLoading];
}
}];