BelVG Subscriptions with PayPal Subscribe Button in Prestashop

March 21, 2016 Dmitry Urbanovich Prestashop
BelVG Subscriptions with PayPal Subscribe Button in Prestashop

Today I would like to describe our updated Subscriptions module for Prestashop, which lets customers to purchase a product periodically (for instance, each Monday every week).

The first version of the module received a lot of feedback on how to improve the performance as well as a lot of feature requests. One of the requests was to let you subscribe to a specific product, so you would not need to return back to the product page each time to pay for it. The problem was that not every payment processor lets you to pay for products without manual transaction approve. It is also hard to create a multi-platform integrator for the most of popular payment processors. However, it appeared, that PayPal had the functionality that could meet our demands, specifically the Subscribe Buttons feature. This function lets you pay for products via your PayPal account:

BelVG Subscriptions with PayPal Subscribe Button

Or by your credit card:

BelVG Subscriptions with PayPal Subscribe Button

In order to add Subscribe Button widget to the Subscriptions module I used PayPal SOAP API. PayPal suggests using Button Manager PHP SDK for developers (you can find many more libraries on the sdks list).

So, let’s begin: we will need to create a business PayPal account to get access to the PayPal SOAP API. You can create account on the PayPal Developer portal (later use it even for testing purposes). We need to create and place the Subscribe button somewhere on the website (for instance, product page) to let customers subscribe for the product. For that we will use this code:

This gives us back a “Subscribe button” code:

Now to subscribe a customer we can either place HTML code from the $responce->Website property directly on the page or use the link from $responce->Email to redirect a customer to the subscription page.

Some situations require to modify already created subscription based on the dynamic customer’s choice. In this case we can use the Update button method:

It is all practically the same except that we are using the classes BMUpdateButtonReq and HostedButtonID (this is the id of the subscription button that we already have created).

This solution will let customers to use subscriptions and automatic payments functionality on the store, while the site owner will be receiving all the information about the payments and products delivery.



1 comment

Post a new comment

top