skip to Main Content

I’ve integrated a Paypal button into an app. When I try to get the gross amount of the order that was just placed, it says it is undefined in the browser.

Here’s the code i’m using:

onApprove: function(data, actions) {

return actions.order.get().then(function(details) {

alert(details.seller_receivable_breakdown.gross_amount.value)

...

I’m in sandbox mode, btw.. Is this something that only works in production mode?

Thanks!

2

Answers


  1. Chosen as BEST ANSWER

    Figured it out!!

    Don't need to use the .get() function at all, .capture() works fine. I had tried using this in one of my many attempts before posting here: details.purchase_units[0].amount.value;

    The problem was that purchase_units returns as a json array, so I needed to add [0].

    Here's what worked: details.purchase_units[0].amount.value;

    :)


  2. No order has been placed after a .get(), you need .capture() for an order to be placed. See the sample at https://developer.paypal.com/demo/checkout/#/pattern/client

    Use console.log(details) to see all the information

    The information you want may not be there in the order capture response. You can use the V2 payments API to get more information about a capture: https://developer.paypal.com/docs/api/payments/v2/#captures_get

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search