• Resolved Philip Sola

    (@philsola)


    I am looking at using WooCommerce for a headless WordPress build coming up, and in particular the new StoreAPI to handle the cart and checkout experience.

    On the official WooCommerce GitHub documentation on the attached link, they give an example of the POST request data you would need to send the endpoint to process the order. One of the parameters is a payment_data array of objects.

    In their docs it states the following:

    “An example of the payment data sent to the Checkout Order endpoint when using the WooCommerce Stripe Payment Gateway is shown below.”

    "payment_data": [
    {
    "key": "stripe_source",
    "value": "src_xxxxxxxxxxxxx"
    },
    {
    "key": "billing_email",
    "value": "[email protected]"
    },
    {
    "key": "billing_first_name",
    "value": "Jane"
    },
    {
    "key": "billing_last_name",
    "value": "Doe"
    },
    {
    "key": "paymentMethod",
    "value": "stripe"
    },
    {
    "key": "paymentRequestType",
    "value": "cc"
    },
    {
    "key": "wc-stripe-new-payment-method",
    "value": true
    }
    ]

    Expand

    There are many payment gateways available for merchants to use, and each one will be expecting different payment_data. We cannot comprehensively list all expected requests for all payment gateways, and we would recommend reaching out to the authors of the payment gateway plugins you’re working with for further information.

    I am reaching out to find out from you as my preferred stripe plugin of choice what you would need within this payment_data array?

    In their example, it doesn’t even include any card details or payment details so I’m not sure how this is meant to even work, using their example.

    Any help and advice for this specific plugin would be greatly appreciated.

    Many thanks,
    Phil

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Afzal (woo-hc)

    (@afzalpansuvi)

    Hi @philsola,

    Thank you for reaching out to us. I understand you’re looking to set up a headless WordPress build and need clarity on the payment_data array required for processing orders. The payment_data array is indeed crucial for integrating payment gateways with the WooCommerce Store API. As you’ve noticed, the example provided in the documentation doesn’t include card details. This is because the actual card details are handled by Stripe’s secure environment to comply with PCI standards. The payment_data array will typically include tokens or keys that reference the payment details stored securely in Stripe’s system.

    For the WooCommerce Stripe Payment Gateway, the payment_data array should contain the necessary information that Stripe requires to process a payment. This usually includes a source or token generated by Stripe after a customer enters their payment details, along with any other relevant billing information.

    To get the specific details that you need to include in the payment_data array for Stripe, I recommend checking the official Stripe documentation for developers, which provides comprehensive guidance on the required fields and data structure. You can find this documentation at https://stripe.com/docs/api.

    Let us know if there’s anything else we can help you with.

    Thread Starter Philip Sola

    (@philsola)

    Hi Afzal,

    Thank you so much for such a comprehensive response, and apologies for the delay getting back sooner, I’ve been away over the weekend.

    Just to clarify with this API, I assume I am right in understanding that the payment itself and the order completion will be handled directly by WooCommerce & the Payment Gateway on the WordPress side, and I am just essentially “setting up this payment” on the Headless frontend of the site?

    Are you able to be any more specific on the API with Stripe that would be responsible for setting up this array of data? Stripe has a lot of different APIs and the stripe_source in the example on the WooCommerce docs, is actually a deprecated API so assume I am meant to use something else?

    Thanks

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @philsola

    Just to clarify with this API, I assume I am right in understanding that the payment itself and the order completion will be handled directly by WooCommerce & the Payment Gateway on the WordPress side, and I am just essentially “setting up this payment” on the Headless frontend of the site?

    Yes, your understanding is correct. The payment and order completion are handled directly by WooCommerce and the payment gateway on the WordPress side. The headless frontend of the site is responsible for setting up the payment and passing the necessary information to the backend.

    Are you able to be any more specific on the API with Stripe that would be responsible for setting up this array of data? Stripe has a lot of different APIs and the stripe_source in the example on the WooCommerce docs, is actually a deprecated API so assume I am meant to use something else?

    In our WooCommerce Stripe Gateway plugin, we are already using the PaymentIntents and SetupIntents for handling payments. More info:

    Additionally, please note that this particular forum is meant for general support with the core functionality of WooCommerce Stripe Payment Gateway itself. For development and custom coding questions, it’s best to ask for insight related to those on either the WooCommerce Advanced Facebook group or the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question. You can also seek help from the following:

    I wish I could help more, but hopefully, this gets you going in the right direction to get some further insight/information.

    Hi ?? We haven’t heard back from you in a while, so I’m going to mark this as resolved – we’ll be here if and/or when you are ready to continue.

    The headless frontend of the site is responsible for setting up the payment and passing the necessary information to the backend.

    I’ve spent 2 days trying to understand what “necessary information” actually means in this case. I have not been able to figure it out yet. So close to getting my headless store up and running, this is my missing key.

    It would be much appreciated if you could provide a payment_data object example to pass into the Store API, based on the response from a Payment Intent from Stripe?

    There are many threads / questions about this, so I think a straight response displaying a correct payment_intent will suffice and help many developers coming into a headless woocommerce setup.

    I’ve asked about it here, with more in depth explanations and examples: https://github.com/woocommerce/woocommerce/issues/50678

    Plugin Support Zubair Zahid (woo-hc)

    (@doublezed2)

    Hello Herr Ahman,

    Thank you for reaching out to Woo support!

    This thread is a bit old, so could you kindly start a new topic and let me know what issue you’re experiencing? I’d be happy to help you with any questions you have.

    Looking forward to your response. ??

    Best regards.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WC StoreAPI payment_data array’ is closed to new replies.