The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
[How-To] Extending the vBulletin Payment Gateway
Overview This tutorial shows you how to add a new payment method to the vBulletin Payment Gateway. It uses my pgStormPay hack as the example. Step 1: The database The first thing you need to understand is the paymentapi table in the database. Code:
Field Type ----- ---- Title varchar(250) Currency varchar(250) Recurring smallint(6) Classname varchar(250) Active smallint(6) Settings Mediumtext The title of the payment method, in our case ?StormPay?. Currency Comma delimited list of currency types this payment method can accept. StormPay only accepts us dollars, so in our case it?s just ?usd?. Recurring Whether or not this payment method can handle recurring payments (monthly, yearly, etc?). Classname The name of the class in yourforum/includes/paymentapi that contains the functions needed to use this payment method. This field name is a little deceptive, because it you look in yourforum/payment_gateway.php you see the following: PHP Code:
Active Is this payment method active? In general you should set this to 0 initially and let the admin activate your payment method from the admincp. Settings This is a critical part of the payment method, and needs some explaining. It represents the information the admin must fill in for this payment method to work. It will be different for each payment method. It is an array of arrays, with each inner array representing a field to be filled out. The structure of the inner array is similar to a html input element. It has a type, a value, and how to validate the value. For StormPay, we create four fields, as shown bellow. PHP Code:
Once you know the values you want for your payment method, you can write them into the database in your install section of your product xml file. PHP Code:
Next you?ll need to create a template for your payment form. This is the form that is filled out automatically by vBulletin before it submits data to your payment method. In the case of StormPay, we are going to use a simple single item payment, as specified in their integration api: http://www.stormpay.com/stormpay/user/manual.php Note: I use unit_price instead of amount. It works the same, and seems to clear up some minor bugs. HTML Code:
<input type="hidden" name="test_mode" value="$settings[test_mode]"> <input type="hidden" name="payee_email" value="$settings[email]"> <input type="hidden" name="product_name" value="$subinfo[title] Subscription"> <input type="hidden" name="description" value="$subinfo[description]"> <input type="hidden" name="unit_price" value="$cost"> <input type="hidden" name="user1" value="$hash"> <input type="hidden" name="require_IPN" value="1"> <input type="hidden" name="return_URL" value="$vboptions[bburl]/payment_gateway.php?method=stormpay"> To create this template, vBulletin expects it to have the name subscription_payment_classname. So in our case the template section of the product xml would look like this: HTML Code:
<templates> <template name="subscription_payment_stormpay" templatetype="template" date="0" username="Hambil" version="3.6.0"> <![CDATA[?]]> </template> </templates> This is not the only way to accomplish this step, but it is the way I have chosen. You need to add the StormPay phrase to the vbphrases array, so it can appear on the ?Order Using? button. Since these are service names, and not translated, vBulletin hard codes them in yourforum/payment.php. However, it does provide a hook (paidsub_order_start). The hook code we need is very simple: PHP Code:
HTML Code:
<plugins> <plugin active="1" executionorder="5"> <title><![CDATA[StormPay - add 'order using']]></title> <hookname>paidsub_order_start</hookname> <phpcode><![CDATA[?]]></phpcode> </plugin> </plugins> Code:
Global setting_stormpay_email_desc This is the email address you want to receive payment (the pay to email address). setting_stormpay_email_title Email setting_stormpay_secret_code_desc This must be the EXACT secret code value you set in your "Profile" > "IPN Configuration" form in StormPay. setting_stormpay_secret_code_title Secrect Code setting_stormpay_test_mode_desc Enable Test Mode. Transactions in test mode are 'fake' and not charged to an account. setting_stormpay_test_mode_title Test Mode setting_stormpay_MD5_desc If you enable MD5 encryption you MUST set the list of IPN variables for Hashing in the "IPN Configuration" form of your StormPay Merchant Account to transaction_id; transaction_date; amount; user_id; user1. setting_stormpay_MD5_title Use MD5 Encryption stormpay_order_instructions To pay for your subscription via StormPay click the button below and follow the onscreen instructions. Error Messages stormpay_pending Your subscription is Pending. Please check the StormPay website. stormpay_cancel Your subscription was canceled. stormpay_error An error was encountered processing your subscription. You have not been charged. HTML Code:
<phrases> <phrasetype name="GLOBAL" fieldname="global">?</phrasetype> <phrasetype name="Error Messages" fieldname="error">?</phrasetype> </phrases> This is the final part, and the real meat of the payment method. It ties everything else together. It extends the vBulletin class vB_PaidSubscriptionMethod, and the easiest thing is probably to copy one of the existing classes and modify it. It has three functions you need to deal with: verify_payment() function This function will depend on what the payment method you are using sends back to the payment_gateway.php file. In general you?ll want to get the variables from the submitted request, check them for successful payment, and return true or false to the payment_gateway.php file. Here is a look at the verify_payment() function for StormPay: PHP Code:
test() function This function is used by the Test Communications link under the Paid Subscriptions menu in the admincp. In general it is just a validation of the specific data (settings) needed by the payment method. In our case, we need a valid email and a ?secret code?. So, or method looks like this: PHP Code:
This function generates the form that is sent to your payment method, using the template you created earlier. Several variables get passed into the method, and you can also retrieve any values you put into settings. Here is a look at the StormPay function. PHP Code:
One final thing to be aware of is that in order to display feedback from your payment method payment_gateway.php requires the value ?display_feedback? be set to true. It defaults to false in the vBulletin class you extend. So, you must force it true: PHP Code:
That?s it folks! Check out the pgStormPay hack if you still need more details. |
#12
|
|||
|
|||
of course, of course..
I was just pointing it out in general. This thread is not just about this Hack. It's about learning how to develop a new plugin isn't it. Thanks a lot for this thread. I was able to develop my first vB plugin as per the specification because of this thread. |
#13
|
|||
|
|||
Can this be used to modify an existing payment apt, ccbill specifically?
I need to modify vb CCBill Form Character Code where the form accepts more than just one form code. |
#14
|
|||
|
|||
Does your tutorial work for 3.6.7?
Whoops!! I mean 3.7 |
#15
|
|||
|
|||
I am trying to write a payment api at the moment, and was querying 'Settings
This is a critical part of the payment method, and needs some explaining. It represents the information the admin must fill in for this payment method to work. It will be different for each payment method. It is an array of arrays, with each inner array representing a field to be filled out. The structure of the inner array is similar to a html input element. It has a type, a value, and how to validate the value. For StormPay, we create four fields, as shown bellow.' how can i work out what my processor (paymex) requires? --------------- Added [DATE]1214174919[/DATE] at [TIME]1214174919[/TIME] --------------- I foudn these, but not sure which relates to what http://www.paymex.co.nz/kb.aspx?id=34 hoping that someone can help me, i can pay a small amount. |
#16
|
||||
|
||||
I am looking for a modification of payment api that permit manual payment approved by admin. User pays in various ways, send me confirmation of payment and I validate manually his subscription.
I have a small professional community so total number cannot go above 10k users and some of them are not familiar with electronic payment. They will send money by post, direct payment in bank account (or even pay me cash when we meet ) and I want to take advantage of the subscription system build in VB (reminders for end of subscription, period subscripted) so I don't need to make a separate group and write down each username , and period of subscription. My alternative for the moment is to make a group user request to join and I approve after receiving the confirmation of payment. This way I need to keep manual track of each user time of subscription ending and name. I have no coding knowledge but willing to learn or appreciate a helping hand. Maybe I am lucky and there is a setting I don't know in vb allowing me to do this ! PS I will like to have this additional to electronic payment (for users able to pay this way) after I manage to integrate my local card processor using this tutorial I am thankful for Edit: Found by accident a possible solution. In Subscription management make a valid payed subscription (even if no bank set) and manually add users from drop down menu in Subscription manager page from Admin CP. Hope is useful for some. |
#17
|
|||
|
|||
Does anyone know if this tutorial works for version 3.8.7?
|
#18
|
|||
|
|||
Anyone?
|
#19
|
||||
|
||||
Absolutely!
|
#20
|
||||
|
||||
IF anyone gets 2checkout working with vbulletin I'll pay yoU!
|
#21
|
||||
|
||||
I haven't looked in a very long time, but isn't 2CO already built in?
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|