Hi I am writing a REST web application and confused on how to handle the payment via Stripe.
I am unclear on when to create order, below is 2 approaches I have thought:
First approach
User enters order details and clicks place order.
Order gets created in database with a boolean flag is_active and orderId is sent to UI.
user gets redirected to stripe payment page.
user enters card details and we get stripe token for charging card
token with orderId sent to backend.
token is used in backend to send request to Stripe to charge user, if charge success then mark order as active otherwise report failure to user.
Second approach
User enters details and clicks place order.
user gets redirected to stripe payment page.
user enters card details and we get stripe token for charging card
token with orderdetails sent to backend.
token is used in backend to send request to Stripe to charge user, if charge success then create order otherwise report failure to user.
which of the above two approach should I use or is there any other way through which I should be handling the payments?
I would only use the first option if building an order was such a lengthy or high-stakes process that you would want to persist a dead candidate order.
The second approach is fine. I would suggest splitting the process of saving a card off from the process of submitting an order; so you have two API calls that can do their error handing separately.
User enters order details and clicks "Next".
User is sent through the Stripe payment page (or your own on-site stripe integration).
The Stripe token is sent to the backend and saved as a/the payment method for the user.
The user clicks "Submit".
Order details are sent to the backend.
Token is used to request the charge, etc...
Related
I am using checkout-one-time-payments for stripe for subscription and one time payments.This is the demo link from stripe https://70p1h.sse.codesandbox.io/.
I am able to successfully collect payments for one time and subscription products . What I want to do now is to show a page that shows all the saved cards for the particular user if user has already made payment from stripe and then if user selects the pre saved card ,I want to move the customer direct to payment confirmation or failure. Dont want the user to re enter the card details and other info
I am using following code in backend for java
SessionCreateParams.Builder builder = new SessionCreateParams.Builder()
.setSuccessUrl(createcheckoutSessionRequest.getSuccessUrl() + "?session_id={CHECKOUT_SESSION_ID}").setCancelUrl(createcheckoutSessionRequest.getFailureUrl())
.addPaymentMethodType(PaymentMethodType.CARD)
.setMode(product.getIsSubscriptionProduct() ? SessionCreateParams.Mode.SUBSCRIPTION
: SessionCreateParams.Mode.PAYMENT)
I am quite confused with all these docs ,I am not able to find the actual scenario in docs ,any help will be really appreciated. Thanks
Using a customer's saved cards is not something that is currently supported by Checkout.
If you want to build this functionality yourself you'd have to do the following:
Retrieve all of a Customer's Payment Methods using the Stripe API (https://stripe.com/docs/api/payment_methods/list).
Once a Payment Method has been selected, use it along with the Customer ID to create a Payment Intent (https://stripe.com/docs/payments/save-during-payment#web-create-payment-intent-off-session) or a Subscription (https://stripe.com/docs/api/subscriptions/create).
Depending on the status of payment, redirect to your own success or failure page.
Stripe now supports using a customer's saved cards in Checkout.
This feature is automatically enabled in Checkout unless the 'Link with Stripe' feature is disabled in Stripe Settings. You may find more information about this in the docs.
Is there any way to pass the saved payment method directly to session object?
Yes. Pass a Customer object with an attached card payment method to a Checkout Session, and Checkout will prefill that customer’s previously saved card details so they can complete the payment with a 1-click checkout experience. You can read more about this in the docs.
Source: Stripe support
to integrate PayPal payment into Java web application ,i use this link Text,
but when i verify the paypal sandbox account for both buyer and seller i found the transaction will be added but it has a "pending" status and the money is not changing,so i want to complete the transaction to transfer money from buyer to seller and paypal inform me whether the transaction is successful or not.
I found the transaction will be added but it has a "pending" status
There are a few possible reasons for this, one is simply the expected behavior of requestPayment.setIntent("authorize");. You may simply want to change that to "sale" if it's not being captured automatically by the guide you were following.
Another possible reason is the currency if it is new to that sandbox receiver account. Log into the receiver account via https://www.sandbox.paypal.com , and see if you can accept one of the payments in the new currency, which will open a currency balance. Future payments won't be pending.
Also ensure the sandbox Business account receiving the payment has a confirmed email in the sandbox environment...
Log into it at https://www.sandbox.paypal.com/businessprofile/settings/email
Send the confirmation from there, if necessary
Read and proceed with the confirmation, via https://www.paypal.com/signin?intent=developer&returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Fnotifications%2F
I am trying to integrate paypal with spring boot application. I am using sandbox account for testing. I have successfully generated the order , order is generated and user is rediected to paypal to excute payment, when he clicks on cancel order , my localhost cancel order api is successfully called by paypal.
But when user(sandbox personal account) wants to continue the payment he is not able to do so. Payment is not being executed and he is redirected again to that continue payment page.
https://www.sandbox.paypal.com/webapps/hermes?flow=1-P&ulReturn=true&token=EC-7YJ233484C422661Y&hermes=1&fromLite=1#/checkout/selectFi
This url is called by paypal instead of return url which was set in the code.
This page is called again and again on clicking continue(I am randomly entering the cvv as it was not provided in the personal sandbox account.)
Please help !!
I believe there is currently a bug when paying with an Indian buyer account in the PayPal sandbox.
Try paying with a buyer from a different country, for example a US Personal account created at https://www.paypal.com/signin?intent=developer&returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Faccounts%2F
You may need to temporarily change your integration's currency from INR to something else, for example USD.
This seems to only be a problem with the sandbox simulator for IN / INR transactions
I am using the (Java) Rest API to perform payments directly from credit cards in the sandbox. The payments all receive "pending" status, which according to the docs (https://developer.paypal.com/webapps/developer/docs/api/#create-a-payment) is not even a valid state to be returned by the payment create call. Payment review is disabled.
I would like to see the process through and complete the transaction. How do I do that in the sandbox? Or should I receive a different state right away?
Under http://developer.paypal.com, Application tab, find out the email associated to the REST app.
Now click on "Sandbox accounts", Click on the REST app email, click on "Profile" link.
Select "Setting" tab, and turn off "Payment review". You shall get "Approved" payment and "Completed" Sale json object.
this is the same issue with paypal status is pending so answer should be the same, just check the seller's selling preferences on the sandbox account like Max-P said, this is just different currency and config issue on paypal
is it possible to maintaining conversation during redirect to external url?
I started paypal transaction with CDI conversation bean and next there is faces redirect to paypal page when I log in and doing payment and next paypal returning to my page and I want to have the same instance of my backing bean to remember details which I sent to paypal.
When paypal redirects back to my page, he appends to url transaction token and payer ID but I don't have any information about quantity of products which user bought. So I want to remember the quantity from before redirect. Now, after paypal returns to my site I call method doExpressCheckout and I want to pass quantity and other transaction details because I can set entirely different details than before the transaction and there is possible strange situation when customer accept on paypal page that buying some products for 10$, but I set 100$ after paypal redirects again to my page and customer will have no idea how much he paid.
I don't know why that this happens.
I use SOAP api.
Yes, you can resume your conversation from an external redirect. Just include the cid=nnn in the return URL you pass to PayPal. For example:
returnUrl = "http://myip/myapp/return.seam?cid=" + Conversation.instance().getId();
details.setReturnURL(returnUrl);
...
As the 2 minute default for conversation timeout is rather limited, you will eventually want to increase the conversation timeout before placing the call to PayPal:
Conversation.instance().setTimeout(900000); // 15 minutes
However, doing this is not necessarily a good idea as it keeps data around for potentially a long time, and you need to keep the session cookie as well for this scheme to work (so you must increase the session timeout as well if necessary).
A better strategy would be to keep the transaction data persistently (db or disk), associate a randomly generated ID to the data and retrieve it on return from PayPal. This way you don't need to keep the conversation in memory.
When paypal redirects back to my page, he appends to url transaction
token and payer ID but I don't have any information about quantity of
products which user bought.
You can append the pre conversation id to the url you pass to Paypal as the return url. This way the conversation id will be passed back together with the above parameters and seam will know to restore the prepayment conversation with all the data.