1. 程式人生 > >信用卡繫結(BrainTree)

信用卡繫結(BrainTree)

/**
 * 
獲取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];
                      }
                  }];