I’m trying to finish completing a checkout with the Payments API
On the API docs it lists 4 required fields: amount, request_details, session_id, unique_token. https://help.shopify.com/en/api/reference/sales-channels/payment#create_payment
On the Sales Channel Guides it has different fields: payment_token instead of session_id, and payment_token is an object not a string. Also there’s an option to just pass in a customer (below)?
https://help.shopify.com/en/api/guides/sales-channel-sdk/completing-a-payment
Your API docs could use some serious clarification, any help here would be extremely appreciated.
Question 1:
How do I use a Stripe Card source (e.g. ‘card_8kjfwkdjfskdfh’) that I’ve already created with a saved Stripe Customer ? This is not a one time token, but a source that can be used multiple times by the same customer. What would be my input on the Shopify payment object?
I’ve created this at the platform account level, not at some individual shopify_payments_account_id
The Guide says:
“If you’ve already tokenized the customer’s credit card and created a customer in your Stripe platform account, then you can send the customer id from your platform account instead of sending the card information.”
But it doesn’t tell you how to pass in a customer. Also a customer could have multiple cards attached, which one would it choose to charge?
{
"payment": {
"request_details": {
"ip_address": "123.1.1.1",
"accept_language": "en-US,en;q=0.8,fr;q=0.6",
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"
},
"amount": "20.00",
"session_id": "DO I PUT THE CARD (card_8kjfwkdjfskdfh) HERE?????",
"OTHER_FIELD": "OR IS THERE A NEW FIELD TO ENTER???",
"unique_token": "client-side-idempotency-token"
}
}
Question 2:
Another option, Am I supposed to charge the customer (using Stripe) before I send some sort of session_id to Shopify? E.g. using Stripe’s Create Charge
const stripe = require("stripe")("sk_test_key");
stripe.charges.create({
amount: 2000,
currency: "usd",
customer: "cus_9823ujwdfkjsh",
source: "card_8kjfwkdjfskdfh",
description: "Charge for jenny.rosen@example.com"
}, function(err, charge) {
// asynchronously called
});