question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onShippingChange clarity

See original GitHub issue

This is a follow up to #470

In that issue, @crookedneighbor mentioned that actions.order.patch([ would not work in the onShippingChange callback. However, with limited testing, I was able to get it to work just fine as far as representing the change within the paypal modal popup. So, I’m not sure if I’m misunderstanding here (perhaps it appears to work fine, but in some production mode, or on the braintree side, it doesn’t work?), or if there is more to understand here?

The desired use case is to have the paypal modal be able to:

  • change shippingOptions based on addressChange
  • change amount (total) based on selected shippingOptions due to changes in tax and shipping * charges

Is this possible?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:31 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
shawncookcommented, Apr 6, 2022

@jortizsao I have noticed the same. The following does not currently work, but here is where I’m at:

In createOrder, if I sidestep Braintree and use actions.order.create({...}) instead of instance.createPayment({...}), I’m able to load a PayPal modal with its expected functionality (including correct behavior for onShippingChange).

Next, I attempt to authorize the order, hooking into Braintree instance.tokenizePayment to obtain a payment method nonce:

onApprove = (data, actions) => {

  // Authorize or capture to obtain the order's details
  actions.order.authorize().then((authorizePayload) => {

    /**
     * The values `data.billingToken` and/or `data.​paymentID` are necessary for Braintree
     * tokenization to work as expected. Because we're using `actions.order.create`
     * from PayPal SDK v2 instead of `instance.createPayment` from Braintree and v1,
     * those values return as empty strings.
     */
    instance.tokenizePayment(data).then((tokenizePayload) => {

       // When used during `gateway.transaction.sale` in backend, the value in
       // tokenizePayload.nonce triggers "Incomplete PayPal account information" error.

    });
  });
}

Unfortunately, running gateway.transaction.sale() on the backend using the nonce generated by tokenizePayment returns an error 82901. Perhaps I need to include facilitatorAccessToken in some form.

TL;DR:

  • Braintree uses Paypal Orders API v1 to perform tokenization, but actions.order.create is part of Orders API v2 (slight edit to language here)
  • Using onShippingChange sorta works, but shipping won’t be added to the line item total on first modal load, and changing shipping option triggers a PATCH error.
1reaction
719mediacommented, Nov 3, 2022

@crookedneighbor any updates here? It does seem very strange/unexpected/baffling that the new paypal v2 has been out for almost 4 years now, and braintree, the company we went with specifically for their first-party paypal support, still doesn’t support it. I mean no offense, I’m just surprised that this hasn’t been a higher initiative. Perhaps there are reasons that may help us understand why this continues to be backburnered? Should we look into just implementing paypal integration outside of braintree?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Listen for Shipping Changes
PayPal calls your onShippingChange function when: The buyer initially logs into their account (if the buyer already has a PayPal account). The buyer...
Read more >
braintree
braintree ; SDK version · 3.73.1 ; Environment · Sandbox ; onShippingChange clarity $ 0 · In that issue, @crookedneighbor mentioned that actions.order.patch([...
Read more >
Response Checking - Clarity Book
Since responses are meant to indicate the success or failure of an action, they cannot be left dangling. Checking the response simply means...
Read more >
Issues · braintree/braintree-web · GitHub
onShippingChange clarity. #472 opened Oct 28, 2019 by 719media · 28 · Script size v4 Issues that require a major version bump to...
Read more >
paypal-checkout/CHANGELOG.md
206, * feat(callback-api): Adding `onShippingChange` callback prop (#766) ... 2554, * Update docs for clarity ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found