Need help setting up PayPal BillingAgreements

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
jhollender
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Wed Apr 02, 2014 2:52 pm

Need help setting up PayPal BillingAgreements

Post by jhollender » Tue Feb 09, 2016 9:04 am

We need to be able to capture a sale through PayPal and if the customer makes a change to their order, we need to be able to charge them for the modifications. PayPal said they offer this ability with BillingAgreements that can be added into the cart's code for the PayPal Express checkout through the API.

Here's a sample from their documentation for what needs to be added:

Code: Select all

Charge the customer for the first-time and create Billing agreement ID API Request:

USER=xxxxx_biz_api1.paypal.com
PWD=xxxxxx
SIGNATURE=xxxxx
METHOD=SetExpressCheckout
VERSION=121.0
RETURNURL=https://localhost/return.php
CANCELURL=https://localhost
PAYMENTREQUEST_0_PAYMENTACTION=Sale
PAYMENTREQUEST_0_AMT =10.00
PAYMENTREQUEST_0_CURRENCYCODE =USD
PAYMENTREQUEST_0_DESC =test EC payment
[b]L_BILLINGTYPE0=MerchantInitiatedBilling[/b]

The response should be:

Array
(
[TOKEN] => EC%2d14240720UX0919338
[TIMESTAMP] => 2010%2d11%2d11T01%3a54%3a55Z
[CORRELATIONID] => 8716bb9e93de5
[ACK] => Success
[VERSION] => 64%2e0
[BUILD] => 1603004
)

So now you have the token and you redirect in the same manner taking them to PayPal.com
https://www.paypal.com/checkoutnow?token=<token>

They then return to the URL specified in the SetExpressCheckout API call with a Post Back of the Token, and the Payer ID. Once you have the PayerID and Token you can do your normal "GetExpressCheckoutDetails" call to get the data. You parse out the returned data and get ready for your DoExpressCheckoutPayment API call. DoExpressCheckoutPayment looks about the same as normal, except you get back the "BillingAgreementID":

Array
(
[TOKEN] => EC%2d14240720UX0919338
[BILLINGAGREEMENTID] => B%2d8AG97914JU089040M
[TIMESTAMP] => 2010%2d11%2d11T02%3a02%3a25Z
[CORRELATIONID] => d986158e6c496
[ACK] => Success
[VERSION] => 64%2e0
[BUILD] => 1603004
[TRANSACTIONID] => 6V1164425Y0419841
[TRANSACTIONTYPE] => expresscheckout
[PAYMENTTYPE] => instant
[ORDERTIME] => 2010%2d11%2d11T02%3a02%3a23Z
[AMT] => 10%2e00
[FEEAMT] => 0%2e01
[TAXAMT] => 0%2e00
[CURRENCYCODE] => USD
[PAYMENTSTATUS] => Completed
[PENDINGREASON] => None
[REASONCODE] => None
[PROTECTIONELIGIBILITY] => Eligible
[INSURANCEOPTIONSELECTED] => false
[SHIPPINGOPTIONISDEFAULT] => false
)

Now you save the BillingAgreementID with that customer. Then when they go back later they can use their PayPal account without having to login.
Does anyone have any idea on how to implement this? Can we modify the PayPal GetExpressCheckout API call used in AbleCommerce?

We are using AbleCommerce 7.0.7 and cannot upgrade to GOLD.

Post Reply