didCreatePaymentResult stripeID is a card_ token, can't seem to save to customer

ⅰ亾dé卋堺 提交于 2019-12-12 17:12:22

问题


I have a swift iOS app which asks the user to their payment details for a payment in app and future payment. This uses the stripe SDK with Apple Pay and seems to all be set up correctly.

I have the below method:

func paymentContext(_ paymentContext: STPPaymentContext, didCreatePaymentResult paymentResult: STPPaymentResult, completion: @escaping STPErrorBlock) {
    orderToken = paymentResult.source.stripeID
    StripePaymentClient.setupAccount(token: orderToken)
}

With then the setupAccount method sending the orderToken to my backend PHP server. Which has code like:

$customer = \Stripe\Customer::create(array(
                 'source'   => $_POST["orderToken"],
                 'email' => $user["Email"],
                 'description' => "Name: " . $user["FirstName"] . " " . $user["LastName"]
            ));

Now the problem is the above PHP gives an error (token obscured):

No such token: card_XXXXXXXXXXX

I assume this is because the PHP Stripe method is expecting a card toke in the form tok_ and not card_

How do I either use the card_ token and save it against a customer. Or how do I get a tok_ token from the stripe API within iOS. Neither methods seem clear from the documentation or my research.

来源:https://stackoverflow.com/questions/49999506/didcreatepaymentresult-stripeid-is-a-card-token-cant-seem-to-save-to-customer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!