PayPal Billing Agreement - No approval_url or redirect_url after creation

1.2k Views Asked by At

I am trying to set up Billing Agreements using PayPal REST API with paypal-rest-api-sdk for Java on PayPal Sandbox. So, far I've been able to create a billing plan and pass it's id to create a Billing Agreement. However, the response that I get after creating a Billing Agreement does not have approval_url and redirect_url. The following is my request

{
 "name": "MYOP Recurring Contribution Agreement",
 "description": "Agreement for MYOP Recurring Contributions",
 "start_date": "2014-12-13T06:26:32Z",
 "payer": {
            "payment_method": "credit_card",
            "funding_instruments": [
               {
                 "credit_card": {
                   "number": "XXXXXXXXXXXX",
                   "type": "visa",
                   "expire_month": 1,
                   "expire_year": 2015,
                   "cvv2": 874,
                   "first_name": "Joe",
                   "last_name": "Young",
                   "billing_address": {
                      "line1": "52 N Main ST",
                      "city": "Johnstown",
                      "country_code": "US",
                      "postal_code": "43210",
                      "state": "OH"
                    }
                 }
             }
          ]
      },
"plan": {
    "id": "P-85A16162MC374104FU7KAYMQ"
 }
}

As a response to my create Billing Agreement request, I receive only the following:

{
  "id": "I-77GK9WNNV04U",
  "links": [
      {
        "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-77GK9WNNV04U",
        "rel": "self",
        "method": "GET"
      }
   ]
}

When I fetch the created Billing Agreement with a GET request on the agreement id, I receive information about the agreement that has a 'links' array that does not contain approval_url or redirect_url.

I am unable to proceed to send the payer to an approval url to then execute the agreement. Help please.

2

There are 2 best solutions below

1
Eshan On

The approval and the redirect url is only applicable when you make the PayPal Payments so that the buyers can login to their PayPal account and approve the transaction .

Since you are making the billing agreement on credit card , the recurring profile will be created right away and need not go thru any redirect url .

0
Ranjith On

You are using ("payment_method":"credit_card") Change the ("Payment_method":"PAYPAL")

 '{
        "name": "T-Shirt of the Month Club Plan",
        "description": "Template creation.",
        "start_date": "2016-03-31T00:37:04Z",
        "plan": {
            "id":"'.$plan_id.'"
        },
        "payer": {
            "payment_method": "PAYPAL"
        },
        "shipping_address": {
            "line1": "111 First Street",
            "city": "Saratoga",
            "state": "CA",
            "postal_code": "95070",
            "country_code": "US"
        }
    }';
Thanks