Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final checkout amount to pay not up to date with Paypal #260

Open
Lynx-D opened this issue Feb 11, 2024 · 8 comments
Open

Final checkout amount to pay not up to date with Paypal #260

Lynx-D opened this issue Feb 11, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@Lynx-D
Copy link

Lynx-D commented Feb 11, 2024

Hi, there is an issue with the paypal plugin integration, paypal get the request of the amount authorization too early during the checkout process. For example, when I order a product that cost me CA$30.78, I will add a shipping method that will cost me CA$9.99 but on the Paypal payment modal it will say that I have to pay only CA$30.78 instead of CA$40,77, because the amount hasn't been updated on Paypal.

Is their a solution for this or do I have to rewrite the checkout process ?

@VariableVic VariableVic added the bug Something isn't working label Feb 12, 2024
@VariableVic
Copy link
Collaborator

Hey @Lynx-D,

I tried to reproduce your issue, but it seems to work as expected in my local environment.

Steps I took:

  • Clear cache and cookies.
  • Set region / currency to Canada + CAD.
  • Add item to cart.
  • Enter checkout.
  • Add shipping method (CAD 9,99)
  • Set PayPal as payment method
  • Click PayPal button and enter my email.

This resulted in a PayPal modal with the exact same total as my cart in checkout:

Screenshot 2024-02-12 at 12 22 49

Could you provide the detailed steps needed to reproduce this issue?

@raiyansarker
Copy link

@VariableVic, I followed this guide, I am not sure how paypal understand how much to charge as I am just providing client id in the frontend. Am I missing something?

@raiyansarker
Copy link

I think it is due to not add createOrder callback in paypal button. If I am right then the docs should mention it, otherwise @VariableVic, can you share your code?

@VariableVic
Copy link
Collaborator

@raiyansarker I think you might be right about the createOrder callback missing in the docs example.

Here is the code I use. I'm passing the payment session id in the createOrder callback, and the Medusa plugin takes care of providing the order details to PayPal.

@raiyansarker
Copy link

@VariableVic I am not sure whether I should ask this question here but what are the events that should be selected for paypal?

@VariableVic
Copy link
Collaborator

@raiyansarker I'm not sure what events you're referring to, could you elaborate?

@raiyansarker
Copy link

@raiyansarker I'm not sure what events you're referring to, could you elaborate?

webhook events

kodiakhq bot pushed a commit to medusajs/medusa that referenced this issue Apr 2, 2024
This PR adds missing information in paypal plugin docs which is crucial to its use. Previously, docs didn't mention about createOrder callback that is required by PayPal sdk to connect with backend for details like currency and amount to be charged. Medusa backend responds with required id for the PayPal sdk to use. Related to medusajs/nextjs-starter-medusa#260 (comment)

Co-authored-by: Shahed Nasser <[email protected]>
@manuel-schoebel
Copy link

manuel-schoebel commented Apr 29, 2024

I have a similar issue.

I create a cart. No shipping option selected. I create the PaymentSession. I assume this initiates the payment on paypal, but without shipping costs.

Then i set a shipping option - the carts total changes.

When I then pass the payment_session.data.id to the createOrder fn of the PayPalButtons it gets the paypal event id of the earlier created one, without shipping cost. So the redirect to paypal shows the wrong one without shipping cost.

If i create the paymentSession only after the shipping was selected it does work correctly.

But the problem is, that whenever I create a new PaymentSession i get the old payment session id.

So ideally when creating a payment session it always creates a new one, but does not return the old one.

Maybe it is some caching issue with next. Or the paypal plugin does not create a new one if it already has one or does not update it on paypals side if the cart changes (if that is at all possible) 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants