ios - 存储用户信用信息

标签 ios objective-c braintree

我已经跟进了 objective-c 的 BrainTree 教程并完成了以下实现。我想知道,我怎么能存储用户信用卡信息,例如 UberAirBnb。每次,用户点击付款,并显示信用卡信息条目 View Controller 。

顺便说一下,交易成功了,我可以在我的 BrainTree 沙盒账户上看到费用。

- (IBAction)placeOrderBtnClicked:(id)sender {    
    [self showDropIn: TOKEN];
}

- (void)showDropIn:(NSString *)clientTokenOrTokenizationKey {
    BTDropInRequest *request = [[BTDropInRequest alloc] init];
    BTDropInController *dropIn = [[BTDropInController alloc] initWithAuthorization:clientTokenOrTokenizationKey request:request handler:^(BTDropInController * _Nonnull controller, BTDropInResult * _Nullable result, NSError * _Nullable error) {

        if (error != nil) {
            NSLog(@"ERROR");
        } else if (result.cancelled) {
            NSLog(@"CANCELLED");
            [self dismissViewControllerAnimated:YES completion:NULL];
        } else {
            [self postNonceToServer:result.paymentMethod.nonce];
        }
    }];
    [self presentViewController:dropIn animated:YES completion:nil];
}

- (void)postNonceToServer:(NSString *)paymentMethodNonce {
        self.manager = [AFHTTPSessionManager manager];
        NSDictionary *params = @{@"amount" : @"44", @"payment_method_nonce" : paymentMethodNonce};
        manager.responseSerializer = [AFHTTPResponseSerializer serializer];
        [manager POST:URLString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull operation, id  _Nonnull responseObject) {
            NSLog (@"transaction is succesfull");
        } failure:^(NSURLSessionDataTask * _Nullable operation, NSError * _Nonnull error) {

        }];
    }

// the following method never gets called!!!
- (void)fetchExistingPaymentMethod:(NSString *)clientToken {
    [BTDropInResult fetchDropInResultForAuthorization:clientToken handler:^(BTDropInResult * _Nullable result, NSError * _Nullable error) {
        if (error != nil) {
            NSLog(@"ERROR");
        } else {
            // Use the BTDropInResult properties to update your UI
            NSLog(@"Payment method :%@", result.paymentMethod);
            NSLog(@"Payment Description :%@", result.paymentDescription);
            NSLog(@"Payment option type :%ld", (long)result.paymentOptionType);
        }
    }];
}

更新:我想查看以下突出显示的部分

enter image description here

最佳答案

完全披露:我在 Braintree 工作。如果您还有任何疑问,请随时联系support .

您的意思是您希望付款表单显示已存储的付款,还是问如何存储付款?为了让 Drop-in 显示以前存储的付款方式,您需要将 customer_id 传递到 ClientToken.generate()在您的服务器端调用。如果您要保存付款方式,那么这又会发生在您的服务器端调用上,因为您必须将随机数从客户端传递到服务器并在 PaymentMethod.create() 中使用该随机数。称呼。

关于ios - 存储用户信用信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44606697/

相关文章:

objective-c - 代码签名错误 : Certificate identity appears more than once in the keychain

ios - Braintree 保险库不存储付款方式

ios - 在核心数据数据库中搜索特定半径的附近地点 [swift]

ios - 如何使用选项字典关闭 Swift 中的核心数据预写日志记录?

ios - 从下一个 minitue 计算当前时间然后 NSTimer 不应该工作

ios - 具有 block 和停止参数的递归方法

objective-c - Sin 和 Cos 函数返回不正确的结果

Objective-C:模偏差

python - 在 Django-Oscar 中通过 Paypal 处理付款

ios - 当我从 iOS 10 中的 BrainTree 支付页面点击 Paypal 时打开空白页面