Hii everyone, I'm trying to use the Stripe payment...
# general
p
Hii everyone, I'm trying to use the Stripe payment gateway, but when I try to create an order payment using the https://example.com/api/orders/{order_number}/payments endpoint that Solidus provided, where I pass request like:- { "payment": { "amount": "42.42", "payment_method_id": 2 } } I get a response saying that the source can't be blank. when I try to pass the request as:- { "payment": { "amount": "42.42", "payment_method_id": 2, "source_attributes": { "cc_type": "Visa", "gateway_customer_profile_id": 2, "gateway_payment_profile_id": 1, "last_digits": "242", "month": 12, "name": "Test Roney", "year": "2028", "number": "4242424242424242" } } } then I am seeing an issue similar to this: SolidusStripe:PaymentSourceActiveModel:UnknownAttributeError (unknown attribute 'cc_type'), for all the source_attributes. Could you kindly explain to me how to pass source_attributes in the payment api for all the parameters that I am sending in source_attributes?
k
Why are you using the API to create the payment? Are you using a custom implementation?
m
For security reasons, you don't want to send the credit card information to your own server. Usually, payment providers like Stripe handle the credit card input using JS on the browser, store the data on THEIR servers, and then send you back a token. That token (and a bit of stuff to be able to display the credit card on the server) is all you need to create the stripe payment source.
p
I am using solidus apis not my own
k
Solidus Stripe doesn’t come with support for creating orders with APIs unfortunately. It works out of the box if you use the extension using the starter frontend provided. There’s definitely a way to make it work via APIs, but you need to figure that out on your own by studying the right parameters to pass via the API request you are trying to do.
As Martin suggested, it’s probably a matter of getting the credit card token via the Stripe SDK and create the payment via the Solidus API, passing the token only, and not all the credit card fields.
p
Thank You
Yes, we use the solidus api solely from BE and the custom implementation from FE. Therefore, for integrating stripe from BE along with the solidus apis, I follow this guide: https://solidus.stoplight.io/docs/solidus/a49d5475e6413-create-order-payment. like you indicated, in order to pass the stripe token in the API; however, this documentation only mentions the "X-Spree-Order-Token" argument. How do I construct an X-Spree-Order-Token and how do I pass that? Would you kindly elaborate?
k
the order token is not related to the Stripe token and it’s documented here: https://solidus.stoplight.io
p
How I get stripe token & which api is use to create order payment?? How to store payment related info in BE??
k
it really depends on how you are integrating Stripe in your custom Frontend, but the solution should be on the Stripe documentation, here: https://stripe.com/docs/payments/payment-element