"PAYEE_NOT_CONSENTED" Only for REST API ?

MRabaud
Contributor
Contributor

Hello, 

 

I am trying to integrating Paypal on my application. This application will allow people to sell tokens between them. So the money doesn't go to me, but to the payees. 

 

I first used smart button directly on my front-end (https://developer.paypal.com/docs/checkout/integrate/). I just had to add a payee field and it worked perfectly fine. 0 bug, no issue.

 

But now, I want to make the integration on a NodejS back-end, because it is more secure for me.

And despite I am doing exactly the same thing (create order -> capturing order), I am getting this error : 

 

{"name":"NOT_AUTHORIZED","details":[{"issue":"PAYEE_NOT_CONSENTED","description":"Payee does not have appropriate consent to allow the API caller to process this type of transaction on their behalf. Your current setup requires the 'payee' to provide a consent before this transaction can be processed successfully."}],"message":"Authorization failed due to insufficient permissions.","debug_id":"300756d694c77","links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-PAYEE_NOT_CONSENTED","rel":"information_link","method":"GET"}]}

 

Why ? Why it has no issue doing this kind of operation with smart button, but I can't do it with the checkout sdk on nodejs and need the payee consent ? 

 

Whats the difference ? 

 

Needing the consent or any kind of operation from the payee is really annoying for me, because I need payee to sell their tokens with the minimal of action to do it. 

 

And I don't see whats the difference between doing it with smart button, or with a back-end.

 

Btw here is my code : 

 

const paypal = require('@paypal/checkout-server-sdk')

if (process.env.NODE_ENV === "prod") {
    APP_SETTINGS = require('src/PRIVATE_APP_SETTINGS.json').prod;
    var environment = new paypal.core.LiveEnvironment(APP_SETTINGS.paypal.paypal_client_id, APP_SETTINGS.paypal.paypal_secret);
} else {
    APP_SETTINGS = require('src/PRIVATE_APP_SETTINGS.json').dev;
    var environment = new paypal.core.SandboxEnvironment(APP_SETTINGS.paypal.paypal_client_id, APP_SETTINGS.paypal.paypal_secret);
}

var client = new paypal.core.PayPalHttpClient(environment);


function createPayment(info)
{
  const body = {
    intent: 'CAPTURE',
    purchase_units: [{
      amount:
      {
        value: info.usdAmount,
        currency_code: 'USD'
      },
      payee: {
        email_address: info.paypalEmail
      }
    }],
  }
  let request = new paypal.orders.OrdersCreateRequest()
  request.requestBody(body)
  return client.execute(request).then(res => {
        return {res: true, id: res.result.id}
    }).catch(err => {
        if (err) {
          console.error(err.message);
        }
        return {res: false}
    })
}

function executePayment(info)
{
    console.log(info)
    const request = new paypal.orders.OrdersCaptureRequest(info.orderId)
    request.requestBody({})
    return client.execute(request).then((result) => {
      console.log("Payment suceed")
      return {res: true}
    }).catch(err => {
        if (err) {
          console.error(err);
        }
        return {res: false}
    })
}

 

Login to Me Too
1 REPLY 1

Namrata1
Contributor
Contributor

Hello, Have you found any solution regarding this?

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.