我想在保存卡后获取STPToken来获取Stripe的Customerid。无法从Swift的STPToken创建customerid。请帮忙。这是我的代码段。

let paymentConfig = STPPaymentConfiguration.init();
        paymentConfig.requiredBillingAddressFields = STPBillingAddressFields.none;
        paymentConfig.publishableKey = "pk_test_whRD827lMXvFb1MtY9T7bRzW"
        let theme = STPTheme.default();
        let addCardViewController = STPAddCardViewController.init(configuration: paymentConfig, theme: theme);
        addCardViewController.delegate = self;
        let navigationController = UINavigationController(rootViewController: addCardViewController);
        self.present(navigationController, animated: true, completion: nil);


   func addCardViewController(_ addCardViewController: STPAddCardViewController, didCreateToken token: STPToken, completion: @escaping STPErrorBlock) {
        print(token)
        dismiss(animated: true)


    }

最佳答案

您无法从客户端获取客户ID。它应该在您的服务器上生成。这是服务器生成客户的参考,

https://stripe.com/docs/api/dotnet#create_customer

您应该有一个API在服务器上发送stptoken,然后您的服务器应该创建一个customer并在响应中返回customerId

10-06 02:54