信用卡绑定(BrainTree)

//BrainTree ios
https://developers.braintreepayments.com/start/hello-client/ios/v4

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


//测试用信用卡号码
https://developers.braintreepayments.com/reference/general/testing/ruby

你可能感兴趣的:(ios技术)