Billing Agreement Customer Information

solerunnhide
Contributor
Contributor

Is it possible to prefill in the customer details specifically on Billing Agreements through the REST API?  This would seem like a standard supported feature, but I am unable to find the documentation anywhere.  Utilizing the API documentation and the new v2.0-beta SDK our transactions are properly executing and billing agreements are active. 

 

The below JSON is passed to PayPal with the payor information via AgreementCreateRequest.  The information itself is correct and the JSON objects are valid.  Should this be located elsewhere or is this not specifically supported by Billing Agreements?

 

{  
   "name":"Product Name",
   "description":"Product Description",
   "start_date":"2018-04-04T2:52:56Z",
   "payer":{  
      "payment_method":"paypal",
      "payer_info":{  
         "first_name":"John",
         "last_name":"Doe",
         "email":"email-address-removed",
         "billing_address":{  
            "line1":"1234 Main Street",
            "line2":"",
            "city":"Atlanta",
            "state":"GA",
            "country_code":"US",
            "postal_code":"30326"
         }
      }
   },
   "plan":{  
      "id":"P-5M7848894Y828350BRTNMNLA"
   }
}

 

Login to Me Too
5 REPLIES 5

solerunnhide
Contributor
Contributor

For further clarification, this is related to the Express Checkout.  Customers are redirected to PayPal to the billing agreement approval URL at which point they are forced to refill in all fields that were passed to PayPal upfront.

Login to Me Too

MTS_Andre
Moderator
Moderator
Hi, you mean that the details that you are passing (Atlanta, GA etc..) are not the one on the Agreement checkout page? If you pass those details in the shipping_address object then they will be shown on the checkout page. If not can you send a screenshot of what you mean?
Login to Me Too

solerunnhide
Contributor
Contributor

@MTS_Andre Thanks for the reply.  I am indeed referring to the Agreement Checkout.  However, passing the information in the JSON structure with the shipping address is ignored and does not solve the issue.

 

JSON sent from PayPal\v1\BillingAgreements\AgreementCreateRequest()

 

{  
   "name":"Product Name",
   "description":"Product Description",
   "start_date":"2018-04-04T2:52:56Z",
   "payer":{  
      "payment_method":"paypal",
      "payer_info":{  
         "first_name":"John",
         "last_name":"Doe",
         "email":"email-address-removed",
         "billing_address":{  
            "line1":"1234 Main Street",
            "line2":"",
            "city":"Atlanta",
            "state":"GA",
            "country_code":"US",
            "postal_code":"30326"
         },
         "shipping_address":{  
            "line1":"1234 Main Street",
            "line2":"",
            "city":"Atlanta",
            "state":"GA",
            "country_code":"US",
            "postal_code":"30326"
         }
      }
   },
   "plan":{  
      "id":"P-5M7848894Y828350BRTNMNLA"
   },
   "shipping_address":{  
      "line1":"1234 Main Street",
      "line2":"",
      "city":"Atlanta",
      "state":"GA",
      "country_code":"US",
      "postal_code":"30326"
   }
}

 

Result is still only a partially filled form with the following missing from the original sent information:

  • First Name
  • Last Name
  • Email

I'm assuming this is being pulled from outside the payer_info object?

 

 

 

Login to Me Too

MTS_Andre
Moderator
Moderator

I understand, can you send a screenshot of the form that is now returning (with missing details) and one where you eventually highlight where they should be? So to have an idea we are on the same page.

Login to Me Too

solerunnhide
Contributor
Contributor

Sure.

 

 

Inputs

PayPal Form Prefill

JSON Structure for Billing Agreement

    $client = new PayPalHttpClient($credentials);

    $body = '{
      "name": "' . $buyer['title'] . '",
      "description": "' . $buyer['description'] . '",
      "start_date": "' . date('Y-m-d\Tg:i:s\Z', strtotime('+1 days')) . '",
      "payer": {
        "payment_method": "paypal",
        "payer_info": {
          "first_name": "' . $buyer['first_name'] . '",
          "last_name": "' . $buyer['last_name'] . '",
          "email": "' . $buyer['email'] . '",
          "billing_address": {
            "line1": "' . $buyer['billing']['line1'] . '",
            "line2": "' . $buyer['billing']['line2'] . '",
            "city": "' . $buyer['billing']['city'] . '",
            "state": "' . $buyer['billing']['state'] . '",
            "country_code": "' . $buyer['billing']['country_code'] . '",
            "postal_code": "' . $buyer['billing']['postal_code'] . '"
          },
          "shipping_address": {
            "line1": "' . $buyer['billing']['line1'] . '",
            "line2": "' . $buyer['billing']['line2'] . '",
            "city": "' . $buyer['billing']['city'] . '",
            "state": "' . $buyer['billing']['state'] . '",
            "country_code": "' . $buyer['billing']['country_code'] . '",
            "postal_code": "' . $buyer['billing']['postal_code'] . '"
          }
        }
      },
      "plan": {
        "id": "' . $plan_id . '"
      }
    }';  
      
    $request = new AgreementCreateRequest();

Buyer Array for Billing Agreement

Array ( [user_id] => 1 [company] => [first_name] => John [last_name] => Die [email] => email-removed [title] => Product Title [description] => Product Description [billing] => Array ( [line1] => 1234 Main Street [line2] => [city] => Atlanta [state] => GA [country_code] => US [postal_code] => 30326 ) )

JSON sent from AgreementCreateRequest

{ "name": "Product Title", "description": "Product Description", "start_date": "2018-04-06T11:58:03Z", "payer": { "payment_method": "paypal", "payer_info": { "first_name": "John", "last_name": "Die", "email": "email-removed", "billing_address": { "line1": "1234 Main Street", "line2": "", "city": "Atlanta", "state": "GA", "country_code": "US", "postal_code": "30326" }, "shipping_address": { "line1": "1234 Main Street", "line2": "", "city": "Atlanta", "state": "GA", "country_code": "US", "postal_code": "30326" } } }, "plan": { "id": "P-13P40544TB028345SS2DWOFY" } }

 

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.