Advertisement:

Paid subscriptions - Adding a payment gateway besides PayPal - 2.0

Aloittaja xtom, heinäkuu 01, 2009, 07:05:05 AP

« edellinen - seuraava »

xtom

Is it possible to add another payment gateway for paid subscriptions and if so what are the steps involved? I've tried making a copy of Subscriptions-PayPal.php and done some minor edits here and there but haven't really gotten anywhere.

xtom

Yeah it seems like a task and a half but it looks like it has been built to support additional gateways in the future, is there or will there be some kind of guide/documentation to adding other gateways in the future? Even a list of the files that need to be edited would be useful.

darubillah

its easy to implement any Payment processor if you know how to do it

you should read IPN guide of that payment processor for eg. Alertpay or Moneybookers, It should be easy I will try to make one for alertpay

Norv

What you need to do is simply add a single file in ./Sources, named Subscriptions-[provider_name].php, which should follow the example of the paypal file (concerning the format required for the leading comment, and the naming of classes and methods), which handles processing as the specific provider requests. SMF recognizes the files and loads them, and makes sure to call the appropriate methods at runtime provided you respected the naming scheme. So there is nothing more needed to do, except this file.
i.e., the leading comment is:

"// SMF Payment Gateway: [gatewayId]",

and the classes should be: [gatewayId]_payment and [gatewayId]_display. Similar for methods.
Please see the Subscriptions-PayPal.php for details about the expected format (and "fill it in" with your specific implementation for the gateway you chose).
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

darubillah


darubillah


luismanson

i copied the Subscriptions-paypal to Subscription-MyGateway
adapted the "// SMF Payment Gateway: MyGateway" line
and still i dont see any settings nor an option to pay with MyGateway :(


Norv

Lainaus käyttäjältä: Norv - joulukuu 21, 2009, 08:54:52 AP
What you need to do is simply add a single file in ./Sources, named Subscriptions-[provider_name].php, which should follow the example of the paypal file (concerning the format required for the leading comment, and the naming of classes and methods), which handles processing as the specific provider requests. SMF recognizes the files and loads them, and makes sure to call the appropriate methods at runtime provided you respected the naming scheme. So there is nothing more needed to do, except this file.
i.e., the leading comment is:

"// SMF Payment Gateway: [gatewayId]",

and the classes should be: [gatewayId]_payment and [gatewayId]_display. Similar for methods.
Please see the Subscriptions-PayPal.php for details about the expected format (and "fill it in" with your specific implementation for the gateway you chose).


Please note the above bolded text too: it's more work than that... Not only one line. I'm afraid that while not complicated, if you're uncertain of your understanding of code, it won't work just like that... If that is the case, you may want to ask someone to make the modifications for you. IMHO.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

luismanson

Lainaus käyttäjältä: Norv - huhtikuu 20, 2010, 10:11:12 AP
Lainaus käyttäjältä: Norv - joulukuu 21, 2009, 08:54:52 AP
What you need to do is simply add a single file in ./Sources, named Subscriptions-[provider_name].php, which should follow the example of the paypal file (concerning the format required for the leading comment, and the naming of classes and methods), which handles processing as the specific provider requests. SMF recognizes the files and loads them, and makes sure to call the appropriate methods at runtime provided you respected the naming scheme. So there is nothing more needed to do, except this file.
i.e., the leading comment is:

"// SMF Payment Gateway: [gatewayId]",

and the classes should be: [gatewayId]_payment and [gatewayId]_display. Similar for methods.
Please see the Subscriptions-PayPal.php for details about the expected format (and "fill it in" with your specific implementation for the gateway you chose).


Please note the above bolded text too: it's more work than that... Not only one line. I'm afraid that while not complicated, if you're uncertain of your understanding of code, it won't work just like that... If that is the case, you may want to ask someone to make the modifications for you. IMHO.

sorry, i also made those changes too, yet im not an experienced developer, i know the basics of PHP...
anyway i wonder where should i see the options of the gateway, in the uses side or the admin panel?

this is my test code:
http://pastebin.ca/1869739

also, is there any other file i should look into?

Norv

Please accept my apologies, I didn't mean to offend you. I misunderstood.

Relevant code: loading subscriptions data, which is in loadPaymentGateways() in ManagePaid.php (this should load all Subscriptions-GatewayName.php from Sources which have expected format). There's nothing you need to do there, just, if possible, verify that the code *is* loading yours too, or why it isn't.
Relevant test: not in user's panel, but in Admin panel, I think you can (and should) first activate the gateway from there

ETA: looking at your code... no, I'm afraid it's still a misunderstanding... This won't work.
Each payment gateway has a specific API which comes from the provider. That API (they give files, including PHP files usually), contains code specific to the provider, and what should be done is to adapt that code to the format we're talking about, the format used in Subscriptions-PayPal.php file.
Those methods, of your respective provider, should be used, with their everything. But in the format (naming scheme) exemplified by Subscriptions-PayPal.php. Like combining them in a single file...
Since your file is only PayPal implementation with the naming scheme of your gateway.. it won't work. As said... "fill it in" with the specific implementation for the gateway you chose.

Your gateway has documentation about its own API, and implementation examples. Take one of those, and look at it. They must say there how to do, for their gateway, the things you see done in Subscriptions-PayPal.php, like composing the request to send to the gateway and reading back the response. Your implementation should put all that in the format alike Subscriptions-PayPal.php.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

luismanson

thanks! i did not take your comment as an ofense :)
sorry for not being clear, with my this test file im tring to make some kind of "stub" or template so i can have a start place and begin testing code, a more experienced programmer could make this in a seccond but since my knowledge is very limited i do a lot of trial and error

thats why the classes are renamed but the code inside is still the one for paypal, i supposed that i should, at least, saw my gateway option somewhere to pay

its a shame there is not an API/documentation, this could help a lot of people where paypal is not an option or they have some kind of "local gateway"

KensonPlays

Amazon.com? I emailed them with the Subscription-PayPal.php and renamed it to a phps file and they might do it, if so I will post code here!

Owner of Mesozoic Haven

Advertisement: