将令牌发送到后端条带目标c

时间:2017-08-02 21:09:13

标签: ios objective-c firebase

我似乎无法找到将令牌发送到我的firebase后端的代码。

- (void)addCardViewController:(STPAddCardViewController *)addCardViewController didCreateToken:(STPToken *)token completion:(STPErrorBlock)completion {
    [self submitTokenToBackend:token completion:^(NSError *error) {
        if (error) {
            completion(error);
        } else {
            [self dismissViewControllerAnimated:YES completion:^{
                [self showReceiptPage];
            }];
        }
    }];
}

1 个答案:

答案 0 :(得分:1)

试试这段代码,

STPAddress  *address = [[STPAddress alloc] init];
address.name ="Test";
address.line1 = @"Test Address-1";
address.line2 = @"Test Address-2";
address.city = @"City";
address.postalCode = @"1234";
address.state = @"State";
address.country = @"Country";



STPCard *stripCard;
stripCard = [[STPCard alloc] init];
stripCard.number = strCard_Number;
stripCard.cvc = strCard_Cvv;
stripCard.expMonth = month;
stripCard.expYear = year;
stripCard.address = address;
stripCard.currency = @"INR";


 [[STPAPIClient sharedClient] createTokenWithCard:stripCard completion:^(STPToken * _Nullable token, NSError * _Nullable error)
 {
        NSString *strMess= @"";
        if(error) {
            strMess = [error localizedDescription];    
        }
        else {
            strMess = stringValue(token.tokenId);
            strMess = [NSString stringWithFormat:@"Token:\n-------\n%@\n\n\nCard Details:\n-------\n%@",strMess,token.allResponseFields];
            //[Function showAlertMessage:strMess autoHide:NO];

            NSString *strToken = @"";
            strToken = token.tokenId;

            NSLog(@"strToken: %@",strToken);
      }
      NSLog(@"strMess: %@",strMess);
 }];