问题
I implemented Apple Pay into my app and it works fine, but currently when I use apple pay the transaction isn't linked to a user, when I add a customer/user parameter on my cloud code I get this error.
error:
type: "invalid_request_error"
message: "Customer cus_xxx does not have a linked card with ID tok_xxxx."
param: "card"
code: "missing"
Parse.Cloud.define("chargeApplePay", function(request, response){
Stripe.Charges.create({
amount: 100 * 100,
currency: "usd",
customer: request.params.idcustomer,
token: request.params.tokenid
},{
success: function(httpResponse) {
response.success("success");
},
error: function(httpResponse) {
response.error(httpResponse)
}
});
});
回答1:
Instead of passing in a token
parameter as the ID of the token you created, you could omit this parameter altogether when creating the charge and pass in only the customer
parameter instead:
https://stripe.com/docs/api/node#create_charge-customer
This assumes that you already created a customer and saved that token as a payment source for that customer before making this charge: https://stripe.com/docs/charges#saving-credit-card-details-for-later
If you do want to charge a specific card for that customer (as opposed to the default card on record), you'd pass in the card ID (card_*) as the source
:
https://stripe.com/docs/api/node#create_charge-source
来源:https://stackoverflow.com/questions/37951550/how-do-i-save-apple-pay-transaction-on-a-customer