Enable Recurring Payments in Vantage with simple code edits
OK. This is NOT an official fix or solution but it works. I had to find a way to get recurring payments working without holding my breath for months and months for a 'maybe'! Once I found where the code was, this took me an hour to do. So, my question, if a numpty like me can do this, why is it taking 'AppThemes' so long to implement it officially?
PayPal-Code-Edits.jpg
None of this is done through the dashboard, I'm not that clever!
The only file being edited is
themes > vantage > includes > payments > gateways > paypal >
paypal-form.php
Look at the image to see the lines I changed to send recurring payment info to PayPal (in my example, I also included a free period).
(Line numbers are approximate)
Line 31:
Code:
'cmd' => '_xclick',
change to
Code:
'cmd' => '_xclick-subscriptions',
To add a free trial period or a reduced price period, you'll need something like this:
Code:
// Trial Period (free for 3 months)
$fields['a1'] = '0';
$fields['p1'] = '3';
$fields['t1'] = 'M';
Look for this line (about 47)
Code:
$fields['amount'] = $order->get_total();
and change the field name to
a3, like this
Code:
$fields['a3'] = $order->get_total();
a3 is the field name PayPal uses as the regular payment for each period in the recurring billing.
Underneath that
a3 line, add 2 more lines that tell PayPal how many periods per payment and what a period is, in this case the number of periods per payment is '1' and the period is 1 'Y'ear.
Code:
$fields['p3'] = '1';
$fields['t3'] = 'Y';
Finally, we have to enable the recurring payment and tell PayPal to try again if payment fails the first time (all standard PayPal stuff) and that is done with these two fields.
Code:
// enable recurring payments
$fields['src'] = '1';
$fields['sra'] = '1';
The first line 'src' is required else the recurring payments will NOT be enabled.
The second line 'sra' is optional, that tells PayPal to try again if the payment fails for any reason.
DISCLAIMER: This is NOT an official Vantage fix. It was coded by myself to accommodate my client's directory requirements. It works for us.
Hope it works for you... All contributions gladly received!!!
Martin