Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Adding card with braintree

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 448
    Comment on it

    Hi All ,

    These are simple steps to add card to braintree account in iOS.

    1.Initialize braintree object with valid client token.

        BTAPIClient *token = [[BTAPIClient alloc] initWithAuthorization:@"cleintToken received from tree"];
        BTCardClient *client = [[BTCardClient alloc]initWithAPIClient:token];
    

    2.Initialize BTCard object with information like :-

     BTCard *request = [BTCard new];
        request.number = _cardNumberTF.text;    //textfield text
        request.expirationMonth = _monthTF.text;   //textfield text
        request.expirationYear =  _yearTF.text;   //textfield text
        request.cvv = _cvvTF.text;  //textfield text
        if (![Utility checkForEmptyString:_zipTF.text]) {
            request.postalCode = _zipTF.text;    //textfield text
        }
    

    3.Call braintree api to register card and to get nounce

    [client tokenizeCard:request
                      completion:^(BTCardNonce * _Nullable tokenizedCard, NSError * _Nullable error) {
    
                          if (error) {
                              [Utility showErrorDropDown:self.view title:@"REQUEST FAILED" message:error.description];
                              return ;
                          }
                         NSLog("%@",tokenizedCard.nonce);
                      }];
    

    If you get nonce in above call then card is verified by braintree then you send this nonce to backend , so that then call braintree rest api to add card to customer account.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: