Test stripe api payment using google pay token - stripe-payments

I have set up a Google Pay button on the front end of my website and have tested communicating with the Google Pay API and have successfully received a response.
I have a Laravel project (PHP) so the front end sends this data to the server to be processed.
Once I have this response however I am not sure how to pass the required information to stripe api. From my understanding I need to pass the token received in the response to stripe's api but not sure how to formulate the request to stripe using this token.
Any assistance would be greatly appreciated

On your PHP side, you need to create a Charge on Stripe: https://stripe.com/docs/api/charges/create , using stripe-php library.
The Stripe Token you got from Google Pay, you would pass that under the source: tok_123 parameter.
(recommended) If you are using PaymentIntent/PaymentMethod objects, you would create a PaymentIntent (https://stripe.com/docs/api/payment_intents/create) using the API and pass payment_method: pm_123.

Related

Zapier Webhooks + Stripe API not returning "success_url"

I'm attempting to retrieve the "success_url" from a charge in Stripe via Zapier.
When using the Webhook step within Zapier, I get the following error:
The app returned "Missing required param: success_url.".
In the backend of Stripe, I'm able to view this session and confirm that it indeed does have a success_url specified, and the checkout process even brings the customer to the url correctly, but I still get this error within Zapier.
Am I missing something??
All I'm trying to do is retrieve that success_url so that I can email it to the customer after the transaction.
Which endpoint are you using to retrieve the success_url? Viewing the Stripe API docs, it seems the success_url is retrieved with a session ID:
https://stripe.com/docs/api/checkout/sessions/retrieve
The GET on the charges endpoint does not appear to return this ID:
https://stripe.com/docs/api/charges/retrieve
Perhaps you could share a screenshot blocking off any sensitive (API keys, PII, etc.) of the request?

Stripe integration - best approach for front end and back end

I'd like to ask about best approach for integrating Stripe payment for FrontEnd and Backend.
As far as I understand from webpage https://stripe.com/docs/payments/integration-builder we should use following flow:
FrontEnd asks Backend for clientSecret to continue payment. That means that Backend doesn't have to know about credit card and other secured information, but can securely build request from payment and calculate amount to be paid.
Once Stripe payment is finished FrontEnd gets the result of payment and then can send paymentId to the
Backend and Backed receives details from Stripe based on paymentId.
Is it the best and most secured way of payment? What should happend in case of issues with FrontEnd - payment is successfully processed, but because of some issue paymentId was not send to the Backend?

How to integrate Paypal with node js into REST way

I need to integrate paypal with node js ( first time ). But node js working as REST server with frontend built on mobile ( Android and iOS ). I think purpose of using return url and cancel url for web based frontend not for mobile.
Previously I implemented Stripe payment gateway which have simple system which generate a auth token on mobile and mobile sent this token to Node Js Rest API. So not node js application have buyer auth token and it process the required payment.
But I am very much confused how Paypal achieve same scenario.
UPDATE : I am using paypal official node js package https://github.com/paypal/PayPal-node-SDK
UPDATE : After more search, I see some steps in payment flow
User paypal payment create API into my REST API to get "payment id" and links.
Hit on approval_url link which used for fullfill buyer information on paypal site. After completion, Paypal hit automatically described return url in first API, along with payment id and payer id params.
In Return API, use payment id and payer id params to paypal payment execute API.
If all above is actual process to generate payment, Then I am assuming that Backend API only needed third Step which API url could be shared with mobile developer in their integration of paypal.
So Mobile will
create payment
Fill Buyer information
While Paypal automatically hit return url where backend API will execute payment.
If this is the recommended ( or only ) way to paypal integration with mobile and rest apis ?
The purpose of return and cancel url is to notify the client(mobile or web) for potential user action, if user completes payment then via return url and if user cancels payments via cancel Url
You can use rest or nvp PayPal will support both, they have rest endpoints which you can use to complete the transaction.
https://github.com/santhoshlfms/Android_PayPal_EC_NodeJs_Server_Sample (Node server)
https://github.com/santhoshlfms/Android_PayPal_EC_CustomTab_Demo (Mobile Front end)
you can follow these repo to figure out how to proceed.

How to send Billing information with Stripe token for validation checks

I have got a stripe token from stripe js, Now I want to charge the customer. How do I send the billing address along with the stripe token for charging. My objective is to validate zip code and address_line1 which I have enabled at the stripe dashboard.
Note:- I can send the billing info without using a stripe token, by using the card details entered. I want to do it using the token received. Is it possible?
The best solution is to send the billing address details when creating the token with Stripe.js This is covered in the createToken() documentation where it lists all the fields you can provide.
Otherwise, you would save the card on a customer first and then use the Update Card API on the server to provide the billing address.

Generating invoice email using Webhook in Stripe and Mailchimp

Can anyone please tell me (or point me in the direction) how to generate an invoice email using webhook api in stripe with the mailchimp account?
You actually can't do that directly because you can't create a MailChimp endpoint which receives data through the web. You need an intermediary layer in between Stripe and MailChimp, which receives data from Stripe, validates the data, converts the data according to your needs, and using MailChimp API sends it to MailChimp to be sent out as an email. But an easier approach will be (in my opinion) creating an in-house solution for sending out emails instead of using MailChimp.

Resources