PDA

View Full Version : Adding a new payment processor


StewardManscat
04-21-2005, 10:00 PM
I need to add a new payment processor. I am sure this has been done many times by many people. Sure wish vbulletin had a better forum search facility, because the answer must already be here.

But I don't dare even look. I'll get distracted by some other lovely toy, and there goes my effort!

Here I am going to just talk aloud, and document as I go. Perhaps someone will interrupt and send me to the proper place. Otherwise, maybe another can make use of this information.

Honestly, if I tell you guys what I am doing, as I do it, sometimes it helps me avoid the really stupid mistakes. Then again, sometimes not.

Enough editorial. Intended audience has some php/hacking experience. This is not a job for the rank novice. Watch me bleed.

Going to add two new processors. First stop: admin/functions_subscriptions.php

Find and modify:

$_SUBSCRIPTIONS['methods'] = array(
'paypal' => 1,
'nochex' => 2,
'worldpay' => 4,
'authorize' => 8,
'inhouse' => 16,
'plugnpay' => 32
);

// ######################## Define supported curencies ###################
$_SUBSCRIPTIONS['curencies'] = array(
'paypal' => array('usd' => true, 'gbp' => true, 'eur' => true),
'nochex' => array('gbp' => true),
'worldpay' => array('usd' => true, 'gbp' => true, 'eur' => true),
'authorize' => array('usd' => true, 'gbp' => true, 'eur' => true),
'inhouse' => array('usd' => true),
'plugnpay' => array('usd' => true)
);


I have added "inhouse" and "plugnpay". Carefully adding commas at the end of each new line (but screwing it up anyway).

For the bit values I choose increasing powers of two: after 32 comes 64, 128,512,1024... and if you have that more payment processors you surely have a calculator.

Next stop, using phpMyAdmin, I find the record in vb_settings where grouptitle='subscriptions'

I change the value for 'value' from 4 to 6, and I replace the value for 'optioncode' with the following.


<span class=\"smallfont\" style=\"white-space:nowrap\">
<input type=\"hidden\" name=\"setting[$setting[varname]][]\" value=\"0\" />
<label for=\"paypal\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"paypal\" value=\"1\" tabindex=\"1\" " . iif(bitwise($setting['value'], 1), HTML_CHECKED) . " />PayPal</label><br />
<label for=\"nochex\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"nochex\" value=\"2\" tabindex=\"1\" " . iif(bitwise($setting['value'], 2), HTML_CHECKED) . " />NOCHEX</label><br />
<label for=\"worldpay\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"worldpay\" value=\"4\" tabindex=\"1\" " . iif(bitwise($setting['value'], 4), HTML_CHECKED) . " />WorldPay</label><br />
<label for=\"authorize\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"authorize\" value=\"8\" tabindex=\"1\" " . iif(bitwise($setting['value'], 8), HTML_CHECKED) . " />Authorize.Net</label><br />
<label for=\"inhouse\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"inhouse\" value=\"16\" tabindex=\"1\" " . iif(bitwise($setting['value'], 16), HTML_CHECKED) . " />In House</label><br />
<label for=\"plugnpay\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"plugnpay\" value=\"32\" tabindex=\"1\" " . iif(bitwise($setting['value'], 32), HTML_CHECKED) . " />Plug n Pay</label><br />
</span>


Just duplicated the last line twice, and modified the names and bit values to match what I have invented so far.

Next stop: admin/functions_subscriptions.php (again).

inside function construct_payment() there is a switch statement. I need to add two more cases. Eg:


case 'inhouse':
$form['action'] = 'http://mysite.com/purchase';
$form['method'] = 'post';
$form['hiddenfields'] = "
<input type=\"hidden\" name=\"desc\" value=\"$item\" />
break;


This is now specific to the processor. But the $form entires are self-explanatory, and, given the standard release of vb, there are some examples to follow. So I create the strings that will plopped into a template for the form action, method, and hidden fields.

So far so good. I am seeing me different payment methods in the admincp, and when I buy a subscription.

Only I'm not seeing a name for the button 'Orde using...'.

Oh crud. Now I need a phrase.

And so ends today's lesson in getting started with a new payment processor.

Those of you who can point me to existing threads, or otherwise provide documentation or encouragement: many thanks in advance.

StewardManscat
04-21-2005, 10:57 PM
No wonder so many of my users hate vb.

I've been using it for over six months now, and here I am, wondering how to edit my own darn post. Grr!

And clearly I've posted in the wrong forum.

Oh well. Maybe another day it will be obvious to me.

Meantime, I have foolishly posted something I am incapable of editing or deleting.

Moderator assistance if and when possible please.

StewardManscat
04-21-2005, 11:11 PM
Still just finding where to make the mods....

The phrase search ends at a hard-coded array in forum/subscriptions.php


// These phrases are constant since they are the name of a service
$tmp = array(
'paypal' => 'PayPal',
'nochex' => 'NOCHEX',
'worldpay' => 'WorldPay',
'inhouse' => 'In House',
'plugnpay' => 'Plug n Pay'
);


Now, if I am groking in fullness, the $form array that I completed in an earlier step will be invoked. The payment processor takes over. I send a return url through a hidden field in this form (or by some admin panel at my payment processor). The return links are:

http://www.mysite.com/forum/subscriptions/inhouse.php
and
http://www.mysite.com/forum/subscriptions/inhouse.php

Now I'm ready to take an existing script from the subscriptions directory, rename it as inhouse.php or plugnpay.php, modify to accept the return values, and I might be done.

Cheers

twoseven
04-21-2005, 11:28 PM
<a href="https://vborg.vbsupport.ru/showthread.php?s=&threadid=66949" target="_blank">https://vborg.vbsupport.ru/showt...threadid=66949</a>
same thing released before by kall.

LEAD_WEIGHT
04-22-2005, 12:31 AM
https://vborg.vbsupport.ru/showthread.php?s=&threadid=66949
same thing released before by kall.
Your point twoseven

vB Version: 3.0.3 Mod Version: 1.00 Supported
DB Changes
Installer included

Release: 07. Jul 2004 Installs: 5
Last Update: Never Rating:

At least he is trying to upgrade it from 3.0.3 to 3.0.7 so do not knock him for doing this :ogre:

twoseven
04-22-2005, 12:40 AM
there is no change from 3.0.3 the subscription info never changed

jugo
04-22-2005, 07:07 PM
But I don't dare even look. I'll get distracted by some other lovely toy, and there goes my effort!

LMAO!!! Very true!!! happens to me all the time.

Deaths
04-23-2005, 09:11 AM
Hehe, same here :D

kall
04-24-2005, 11:13 AM
Your point twoseven

vB Version: 3.0.3 Mod Version: 1.00 Supported
DB Changes
Installer included

Release: 07. Jul 2004 Installs: 5
Last Update: Never Rating:

At least he is trying to upgrade it from 3.0.3 to 3.0.7 so do not knock him for doing this :ogre:
No, twoseven *is* right... releasing something exactly the same as something already released is generally not done around here.

Thank you for pointing out that I had it set at 3.0.3 though. You may not realise, having not released anything yourself, that this is a dropdown box, with no option to select 'various versions from 3.0.3 up'.

Twoseven is also right in saying there have been no changes to the system since my release, so that release still applies.

StewardManscat
04-24-2005, 01:44 PM
Your release not only still applies, but you did it without all the whining and crying. And you found one final phrase that I did not. People trying to simply make the change should definitely follow your thread (https://vborg.vbsupport.ru/showthread.php?s=&threadid=66949).

Kall shows different ways of making the mods: something about turning on debug and using the address bar to modify a setting. Even more potentially useful information.

I didn't quite understand I was "releasing" something here, I was just posting a whiner. We all have our days.

There is nothing to release. It's just a few steps to follow. So long as the threads are cross-linked, another may have twice the chance of understanding or learning. Or finding it in the first place.

Alert here's something curious. If you start with an existing subscriptions ipn (instant payment notification) module, you may find it includes init but not global.

Where do people define their group ids eg define('MYGROUP', 13). I would have guessed global.php

Other steps Many processors require a unique transaction identifier. I found I had to create a table. When the purchase was confirmed, write the userid and get an insert id. The subscription table itself will not do.

Now, if a cookie has expired when the IPN is received, you still have the insert id, and can recover the transaction details. I saved everything the processor sent:


foreach ($_REQUEST as $key => $value)
$postdata .="\n$key => $value";

if (status from processor is ok)
{
$DB_site->query("UPDATE ... postdata='".serialize($postdata)."'...
}


Many times you do not really understand what a processor is telling you until you see it in action. Once you have some rows in your table, you can see what they really meant by their status and return variables.

Also in this table, a COMPLETE status. If you try to complete a transaction that is already complete, you know somebody is hacking... or more likely, the payment processor is acting up, and users are desperately re-trying. Beats extending the subscription eight times. And provides a useful audit trail.

There's another difficulty for adult ("stupid") sites. Presenting all those payment methods is confusing for some people. Better to guide them one at a time, first through your main processor, then try for the others.

I'm not done yet! Appreciate the feedback.