Referenced Transaction - Permission Denied Sandbox Account

dzerium
Contributor
Contributor

Hi I have been testing with Referenced Transacations on my Sandbox Account. 


Here's the steps I've done so far. 

1. Create Billing Agreement

2. Approve Billing Agreement

3. Execute Billing Agreement. 

 

Step number 3 provides me with the agreement ID which I could also use in updating the billing agreement. 

 

Here's the request sent on Payments API:

{
      "intent": "sale",
      "payer":
      {
        "payment_method": "PAYPAL",
        "funding_instruments": [
        {
          "billing":
          {
            "billing_agreement_id": "I-6Y6L1XP6L6FA"
          }
        }]
      },
      "transactions": [
      {
        "amount":
        {
          "currency": "USD",
          "total": "1.00"
        },
        "description": "Payment transaction.",
        "custom": "Payment custom field.",
        "note_to_payee": "Note to payee field.",
        "item_list":
        {
          "items": [
          {
            "sku": "sku",
            "name": "ItemNo1",
            "description": "The item description.",
            "quantity": "1",
            "price": "1.00",
            "currency": "USD"
          }]
        }
      }],
      "redirect_urls":
      {
        "return_url": "https://example.com/return",
        "cancel_url": "https://example.com/cancel"
      }
    }

And here's the response

{
    "name": "PERMISSION_DENIED",
    "message": "No permission for the requested operation",
    "information_link": "https://developer.paypal.com/docs/api/payments/#errors",
    "debug_id": "3137f962a1dfa",
    "code": "PERMISSION_DENIED"
}

 

Based on what I have read, Paypal referenced transactions should be available by default on Sandbox accounts. 
Can somebody enlighten me as to what the error code meant in this case? 

 

Thank you very much!

Login to Me Too
2 REPLIES 2

MTS-Aaron
PayPal Employee
PayPal Employee

Hi @dzerium 

 

This doesn't look like a permissions issue with Reference Transactions actually. From what I'm seeing, that "Note to Payee" field should actually be "note_to_payer" as you can see in the request variables here. That's what the system looks to be saying "permission_denied" to.

 

I hope that helps!

-Aaron

Login to Me Too

dzerium
Contributor
Contributor

Hi @MTS-Aaron

Thank you very much for providing me assistance and thank you for pointing out my error!

 

I did update the request to: 

{
      "intent": "sale",
      "payer":
      {
        "payment_method": "PAYPAL",
        "funding_instruments": [
        {
          "billing":
          {
            "billing_agreement_id": "I-3AD4BAMG087W"
          }
        }]
      },
      "transactions": [
      {
        "amount":
        {
          "currency": "EUR",
          "total": "1.00"
        },
        "description": "Payment transaction.",
        "custom": "Payment custom field.",
        "note_to_payer": "Note to payer field.",
        "item_list":
        {
          "items": [
          {
            "sku": "sku",
            "name": "ItemNo1",
            "description": "The item description.",
            "quantity": "1",
            "price": "1.00",
            "currency": "EUR"
          }]
        }
      }],
      "redirect_urls":
      {
        "return_url": "https://example.com/return",
        "cancel_url": "https://example.com/cancel"
      }
    }

 

It still gives me the error: 

 

{
    "name": "PERMISSION_DENIED",
    "message": "No permission for the requested operation",
    "information_link": "https://developer.paypal.com/docs/api/payments/#errors",
    "debug_id": "e332894f70bcb",
    "code": "PERMISSION_DENIED"
}

 

However, when I remove the "funding_instruments" object in the request and proceeded, I get a successful response.

{
    "id": "PAYID-MBNO3MI37V09383GK5094236",
    "intent": "sale",
    "state": "created",
    "payer": {
        "payment_method": "paypal"
    },
    "transactions": [
        {
            "amount": {
                "total": "1.00",
                "currency": "EUR"
            },
            "description": "Payment transaction.",
            "custom": "Payment custom field.",
            "item_list": {
                "items": [
                    {
                        "name": "ItemNo1",
                        "sku": "sku",
                        "description": "The item description.",
                        "price": "1.00",
                        "currency": "EUR",
                        "quantity": 1
                    }
                ]
            },
            "related_resources": []
        }
    ],
    "create_time": "2021-03-24T07:43:45Z",
    "links": [
        {
            "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAYID-MBNO3MI37V09383GK5094236",
            "rel": "self",
            "method": "GET"
        },
        {
            "href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-79H40392MX2936104",
            "rel": "approval_url",
            "method": "REDIRECT"
        },
        {
            "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAYID-MBNO3MI37V09383GK5094236/execute",
            "rel": "execute",
            "method": "POST"
        }
    ]
}


The URL leads me to a PayPal page to approve the payment transaction.
However, what I do want to achieve is to create a payment transaction on behalf of the customers using the created billing agreement. 

This scenario I believe is achievable right? Is there something wrong with how the billing agreement was created? 

 

 

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.