Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

transaction amount is not sending to paypal #347

Closed
zaw-hlaing-bwar opened this issue Feb 20, 2018 · 13 comments
Closed

transaction amount is not sending to paypal #347

zaw-hlaing-bwar opened this issue Feb 20, 2018 · 13 comments

Comments

@zaw-hlaing-bwar
Copy link

image
I cant see the transition total amount in paypal site.
I am using paypal rest sdk v2.0
The following code is how i execute payment

client.execute(request).then((response) => {
        console.log(response.statusCode);
        console.log(response.result);
        var id = response.result.id;
        var links = response.result.links;
        var counter = links.length;
        while( counter -- ) {
            if ( links[counter].method == 'REDIRECT') {
                return res.redirect( links[counter].href )
            }
        }
      }).catch((error) => {
        console.error(error.statusCode);
        console.error(error.message);
      })

I also feel strange with that UI too.
I integrated paypal in react but it come up with a new ui

The following image is how paypal return result!
image

@zaw-hlaing-bwar zaw-hlaing-bwar changed the title transition amount is not sending to paypal transaction amount is not sending to paypal Feb 20, 2018
@bluk
Copy link
Contributor

bluk commented Feb 20, 2018

The different UI was potentially due to a sandbox issue. Can you please try again?

@zaw-hlaing-bwar
Copy link
Author

zaw-hlaing-bwar commented Feb 21, 2018

@bluk
using paypal checkout in react (sandbox) but it goes everything fine.
but in node still having the old UI till now!
I think it doesn't come with sandbox issue
I found different url
image
The right url comes up with new UI

@xiaoleih41
Copy link
Contributor

We will look into this

@zaw-hlaing-bwar
Copy link
Author

@xiaoleih41 @bluk
fix transition amount view by adding some more params in payment request json.
I hope you guys can help me fix the UI issue with One Touch(TM).
I also want to know how to get the payment response by PAY-ID for furthermore check up.
I saw sample on v1 and that doesnt work on v2.
Thanks for ur work guys.

@xiaoleih41
Copy link
Contributor

Can you please send us a sample of request? We are trying to figure out if this is due to the transaction amount not being sent or because some issue going to the old UI.

@zaw-hlaing-bwar
Copy link
Author

zaw-hlaing-bwar commented Feb 28, 2018

@xiaoleih41
This is the code for creating payment.
Please check it.
And by the way, is there any update docs for v2?

let payment = {
    'intent': 'authorize',
    'redirect_urls': {
      'cancel_url': 'http://localhost:8000/cancel',
      'return_url': 'http://localhost:8000/result-url'
    },
    'payer': {
      'payment_method': 'paypal'
    },
    "transactions": [{
              "amount": {
                  "total": 10,
                  "currency": "USD",
                  /*
                  adding details and item lists in transactions params let me show the amount
                  */
                  "details": {
                      "subtotal": 10,
                      "tax": "0.00",
                      "shipping": "0.00"
                  }
              },
              "description": "This is payment description.",
              /*
              adding details and item lists in transactions params let me show the amount
              */
              "item_list": {
                  "items":[
                      {
                          "quantity":"1",
                          "name":"ticket",
                          "price": 10,
                          "currency":"USD"
                      }
                  ]
              }
          }]
  };
  var request = new payments.PaymentCreateRequest();
  request.requestBody(payment);

  client.execute(request).then((response) => {
    var id = response.result.id;
    var links = response.result.links;
    var counter = links.length;
    while( counter -- ) {
        if ( links[counter].method == 'REDIRECT') {
          //check pay id and save in db
          //redirect to paypal page for user confirmation
            return res.redirect( links[counter].href )
        }
    }
  }).catch((error) => {
    console.error(error.statusCode);
    console.error(error.message);
  });

@ankibalyan
Copy link

ankibalyan commented Mar 1, 2018

@xiaoleih41 @zaw-hlaing-bwar how would you execute the payment after user confirmation. I'm trying something like

function handleChargeResponse({ body, payment_ref }) {
  const payments = paypal.v1.payments;
  const payReq = new payments.PaymentExecuteRequest(body.paymentId);
  payReq.headers['PayPal-Request-ID'] = payment_ref;
  payReq.headers['Authorization'] = `Bearer ${body.token}`;
  const details = { payer_id: body.payerId};
  payReq.requestBody(body.paymentId, details);
  return client.execute(payReq)
    .then((chargeObject) => {
      console.log('=============== START DEBUG LOG retrieve Paypal chargeObject ===============');
      console.log(chargeObject);
      console.log('=============== END DEBUG LOG retrieve Paypal chargeObject ===============');
      return { chargeObject };
    })
    .catch((err) => {
      console.log(err);
      return { chargeObject };
    });
}

@ankibalyan
Copy link

#350 raised an issue here

@ankibalyan
Copy link

@zaw-hlaing-bwar Can you try passing all the amount fields as string with fixed 2 decimal places. I'm using the similar pattern and its working for me.
Let me know if anything more details you want.

@zaw-hlaing-bwar
Copy link
Author

@ankibalyan
Thanks for your help,
Currently I am busy with another project and so I haven't tested your code,
I can fix the transaction amount problem by adding some params,
the really problem is paypal is showing up with old UI, not with the new One Touch UI.
How does your paypal UI work with?
with new One Touch(TM) UI?

@ankibalyan
Copy link

@zaw-hlaing-bwar yes, I'm getting new One Touch UI.

@xjijies
Copy link

xjijies commented Sep 25, 2019

@zaw-hlaing-bwar Are you still facing this issue?

@xjijies
Copy link

xjijies commented Sep 30, 2019

@zaw-hlaing-bwar Closing this issue. Please reopen if you are still see this instances around.

@xjijies xjijies closed this as completed Sep 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants