问题
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