Jump to content
Sign in to follow this  
SGershon

New Payment Module

Recommended Posts

Hello.

 

Signing with a local merchant account, I need now to make a payment module to work with them.

They don't have anything ready to use with OsCommerce, but they sent me the communication interface and some PHP examples.

 

Looked over the KB, but did not found any tutorial on building new modules to work with different vendors. Someone can push me in the right direction?

 

SGershon


If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Share this post


Link to post
Share on other sites

Can I understand this silence as "we did not understood your question"?

 

I need to build a new payment module, one that works with a local merchant_account we signed with.

 

I don't know where to start. Please point me a reference or the right direction.

 

SGershon


If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Share this post


Link to post
Share on other sites

I don't think there is a reference for building new payment modules...what is your URL and also link to the gateway?

 

Maybe I can get something coded for you.

Share this post


Link to post
Share on other sites

Hello,

 

Hope this isn't considered as hijacking you thread. :D

 

I have the same problem with a local service here in my country:

http://www.svedigt-kluns.dk/payment.htm

(the way its implemented at the moment is our costumer presses the EWIRE logo which starts ssl communication with the server).

 

Any input appreciated.

 

Just tell me if I must start a new thread.

 

Thanks


Dedicated OsCommerce user. 2011 will be the return of OsC

Share this post


Link to post
Share on other sites

Hello All.

 

I need to make my store "talk" with a local merchant account.

 

I am a programmer, and I also have php samples sent to me by the merchant.

So I think that building the query string, sending it to the merchant validation, receiving reply and treating it can be handled well.

But, they do not have an osCommerce store working with them, so they can not help me configuring osCommerce.

 

I have no idea how to start making a brand new payment module for oscommerce.

 

- What is needed?

- Can I receive an example or reference?

- A file inside the includes\modules\payment directory is enough?

- I need to make any addition to any other file? To the DataBase?

 

I did not find a payment module tutorial on the KB. Maybe I overlooked.

 

Any help is greatly appreciated.

 

SGershon


If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Share this post


Link to post
Share on other sites

Dear All,

 

I have the same request. I need to make my own Payment Module according to a specific Merchant.

 

Please help me.

 

March

Share this post


Link to post
Share on other sites

Hi March!

 

Maybe we could start sharing information. Did you learn something already?

 

How is your payment module be? Will you popup/refer to the merchant, or you will perform from inside your site? Do you know if/how this matters?

 

SGershon


If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Share this post


Link to post
Share on other sites

I'm in the same spot. I need to get a module, I have php samples, and I have actually moved one step further: I tried to model my module on one of the "ready-made" modules, namely Authorize.net.

 

What I have found out is summarized to this:

Each module contains the definition of a single class, the name of which is the name of the module itself. It is included dynamically in the scripts.

The class has 4 member variables for sure (it may have extra). These are:

 

string $code: the code of the module

string $title: the Title of the module (used in the admin pages)

string $description: Description of the module (used in the admin pages too)

bool $enabled: whether it is installed or not.

 

The class constructor has invariably the same structure, which I will not post here for reasons of brevity. One thing to notice is that there is a member variable called form_action_url, which is probably where the url of the payserver should go.

 

from then on, there are the following methods:

update_status():Haven't figured it out, but has the same appearance in all modules.

 

javascript_validation():usually it's just "return false;"

 

selection():Some modules create a form with this, where you fill in the credit card number. The others have roughly the same appearance.

 

pre_comfirmation_check():Checks validity of credit card. Same (?) in all modules.

 

comfirmation(): collects all info passed in through selection(), as well as some others in an array.

 

process_button(): Makes a form full of hidden input fields. I guess this is where we put all the information the payserver needs to have. Also, this is where the form_action_url variable probably comes into play.

 

before_process():?

 

after_process():?

 

output_error(): Probably self explanatory. Haven't looked into it

 

check(): Seems to be checking whether the module is installed or not.

 

install(): Installs the module. Mainly one large INSERT sql query.

 

remove(): Same as above, but DELETE instead of INSERT.

 

keys():Returns an array with some of the configuration constants associated with the module.

 

Apart from the modue itself, there needs to be another file: It has the same name, and it goes in the "language/modules/payment" directory. It contains all the configuration constants for the module.

 

My effort to create my own module came to a grinding halt when I realised that my payserver requires the order_id to do the comfirmation, but OSCommerce creates the order_id AFTER it receives comfirmation :(

 

Hope it helps (or I typed for 5 minutes in vain :-))

 

Yiangos


Feu! Edome8a upo rhnnosxhmwn lukwn!

Share this post


Link to post
Share on other sites
Hope it helps (or I typed for 5 minutes in vain :-))

Yiangos

It helps, it helps!

I actually wondered whether you just had these notes for yourself, or you just typed it. Typed it, I see. Thank you for your concern.

This explanation helped me a lot.

I'm in the same spot. I need to get a module, I have php samples, and I have actually moved one step further: I tried to model my module on one of the "ready-made" modules, namely Authorize.net
What is needed? Only the files inside the "includes/modules/payment"?
My effort to create my own module came to a grinding halt when I realised that my payserver requires the order_id to do the comfirmation, but OSCommerce creates the order_id AFTER it receives comfirmation :(
Well, did you solved this? Would it be a big problem to make the order number before and storing it for osCommerce to use it afterwards? Or, can you use as of now any other number and have the two numbers? Maybe it would work, this way -- but you will need to track two order numbers meanwhile.

 

Well, its time for me to check your technique.

 

SGershon


If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Share this post


Link to post
Share on other sites

Make sure you keep the methods you need (ie the ones that are common in all other modules) and create any extra ones that are custom to your payserver. For instance, you probably won't need those FP methods from authorizenet.php, but you might need some other method to do some custom work that your payserver requires.

For instance, I have found a way (actually, I was told a way) to bypass the order id issue. Namely, I just do a

 

srand(time());
$unique_id=md5(rand(500).time().rand(500));

and I get a nifty hash which is - to the best of my knowledge - quite unique.

 

Still baffled with the methods before_process() and after_process() though.

 

Also, as I mentioned before, there is more than what meets the eye with these modules: you need to make another file, with the same name, and store it in the /catalog/includes/language/modules/payment/ directory. This file should contain definitions for all the constants used in the main module.

 

If you actually go through and create a working module thanks to my remarks, I'd greatly appreciate a helping hand in finishing mine :-"

 

Yiangos


Feu! Edome8a upo rhnnosxhmwn lukwn!

Share this post


Link to post
Share on other sites
Still baffled with the methods before_process() and after_process() though.

 

I've recently written a payment module for my company's payment solution.

(Contopronto - search the contributions)

 

I used the before_process() to perform the verify transaction (callback) procedure.

It is called by checkout_process.php before processing the order.

 

ONE PROBLEM: one of our merchants added tax to shipping. So before order_totals->process is called, tax is missing from shipping and the total amount ($order->info['total']) does not match the transaction amount and the verification fails... still trying to work out a solution here. Comments appreciated...

 

I also stumbled on the orderid problem - solved this by using $customer_id

Not unique for the order, but at least some reference...

 

Eskil

Share this post


Link to post
Share on other sites

I have two sample PHP scripts from my merchant, as I am newbie to PHP, I do not know what should I do ?

 

My merchant needs 3 parameters from OsCommerce to be posted to their Gateway first.

1) Total price

2) Merchant ID and Password

3) A Reference order or Order number from OsCommerce.

 

Then, it is redirected to Merchant webpage and customer enters the Card information there.

------------------------

Verify.php :

<?php

include('/usr/share/pear/nusoap.php');

require_once('nusoap.php');

$soapclient = new soapclient('https://192.168.1.22/ref-payment/ws/ReferencePayment?WSDL','wsdl');

#$soapclient->debug_flag=true;

$soapProxy = $soapclient->getProxy() ;

#if( $err = $soapclient->getError() )

# echo $err ;

#echo $soapclient->debug_str;

$res= $soapProxy->VerifyTransaction('T8qrtY6bK81mcAe2y0tH','00015001-28');#reference number and sellerid

if( $res <= 0 )

echo 'verification failed' ;

else

{

echo 'it verified';

echo $res ;

}

?>

-----------------------

 

After sucessfull transaction, Merchant generates a Reference Number and it should be post to OsCommerce.

 

Then, OsCommerce should very the Reference Number with the Merchant again for final confirmation.

 

If confirmation is OK, it posts a message to OsCommerce and the orders is completed

----------------------

reverse.php :

<?php

include('/usr/share/pear/nusoap.php');

require_once('nusoap.php');

$soapclient = new soapclient('http://192.168.1.22:8080/ref-payment/ws/ReferencePayment?WSDL','wsdl');

$soapProxy = $soapclient->getProxy() ;

$res= $soapProxy->ReverseTransaction('T8qrtY6bK81mcAe2y0tH','00015001-28','123456',2);#reference number,sellerid,password,reverse amount

if( $res == 1 )

echo 'reversed successfully' ;

else

echo 'reversed failed' ;

?>

----------------------

 

Please someone help me and make the Payment module for this merchant.

I really appreciate.

 

 

Thanks !

Marcheloo

Edited by marcheloo

Share this post


Link to post
Share on other sites

I have two sample PHP scripts from my merchant, as I am newbie to PHP, I do not know what should I do ?

 

My merchant needs 3 parameters from OsCommerce to be posted to their Gateway first.

1) Total price

2) Merchant ID and Password

3) A Reference order or Order number from OsCommerce.

 

Then, it is redirected to Merchant webpage and customer enters the Card information there.

------------------------

Verify.php :

<?php

include('/usr/share/pear/nusoap.php');

require_once('nusoap.php');

$soapclient = new soapclient('https://192.168.1.22/ref-payment/ws/ReferencePayment?WSDL','wsdl');

#$soapclient->debug_flag=true;

$soapProxy = $soapclient->getProxy() ;

#if( $err = $soapclient->getError() )

# echo $err ;

#echo $soapclient->debug_str;

$res= $soapProxy->VerifyTransaction('T8qrtY6bK81mcAe2y0tH','00015001-28');#reference number and sellerid

if( $res <= 0 )

echo 'verification failed' ;

else

{

echo 'it verified';

echo $res ;

}

?>

-----------------------

 

After sucessfull transaction, Merchant generates a Reference Number and it should be posted to OsCommerce.

 

Then, OsCommerce should do a revese verify for the Reference Number with the Merchant again for final confirmation.

I mean for double checking now, OsCommerce verify the Merchant Reference Number with the total price with the Merchant.

 

If confirmation is OK, it posts a message to OsCommerce and the orders is completed

----------------------

reverse.php :

<?php

include('/usr/share/pear/nusoap.php');

require_once('nusoap.php');

$soapclient = new soapclient('http://192.168.1.22:8080/ref-payment/ws/ReferencePayment?WSDL','wsdl');

$soapProxy = $soapclient->getProxy() ;

$res= $soapProxy->ReverseTransaction('T8qrtY6bK81mcAe2y0tH','00015001-28','123456',2);#reference number,sellerid,password,reverse amount

if( $res == 1 )

echo 'reversed successfully' ;

else

echo 'reversed failed' ;

?>

----------------------

 

Please someone help me and make the Payment module for this merchant.

I really appreciate.

 

 

Thanks !

Marcheloo

Share this post


Link to post
Share on other sites
Please someone help me and make the Payment module for this merchant.

I really appreciate.

Marcheloo

Hi Marcheloo.

I am sad to warn you that it does not work that way... From our past posts, you can see that is quite hard to make a payment module (maybe it is easier to modify an existing one. :rolleyes:

My first sugestion to you: Go to the contributions page and look for a payment module already built for your merchant (you did not say which merchant it was).

My second sugestion: Look for a module that work in this redirection way, and modify it. There are many modules and merchants that do not redirect pages, and there are modules that pop-up pages, so look for one that is close to your need. I think that being a redirection one, it is easier to change because most of the show is handled in the merchant page.

Third sugestion: Read the previous messages on this topic, and stay tuned for more. I'm working on a new module and may write my findings soon.

Fourth: You already can find two solutions for "3) A Reference order or Order number from OsCommerce." in this topic.

 

SGershon


If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Share this post


Link to post
Share on other sites
I don't think there is a reference for building new payment modules...what is your URL and also link to the gateway?

 

Maybe I can get something coded for you.

Hi Chemo!

Thanks for your response, and sorry for not noting it! Somehow, I did not receive a notification.

I would love your help on this! I am already a great fan of your mesoimpact, and had a few questions loaded for you! :)

 

My merchant sent me, more or less, the following example:

<?php
function perform($cardNumber, $expiry, $amount){
 $xmlString = "
   <requestId>ID_NUMBER</requestId>
   <terminalNumber>MY_TERM_NUMBER</terminalNumber>
   <transactionCode>MY_CODE</transactionCode>
   <cardNo>$cardNumber</cardNo>
   <cardExpiration>$expiry</cardExpiration>
   <total>$amount</total>

 $getString =  "user=USERNAME&password=PASSWORD&details=$xmlString";
 $resp = exec("curl -d '$getString' https://MERCHANT_DOMAIN.com/relay/Relay");
 print("$resp");
}

if ($_REQUEST['payment']== 'true'){
 perform($_REQUEST['card_no'], $_REQUEST['expiry'], $_REQUEST['amount']);
}else{
?>
<html><head></head><body><form action="example.php" method="GET">
 <table><tbody><tr>
  	 <td>Card number</td>
  	 <td><input type="text" name="card_no" value=""></input></td>
   </tr><tr>
  	 <td>Expiration</td>
  	 <td><input type="text" name="expiry" value=""></input></td>
   </tr><tr>
  	 <td>Total</td>
  	 <td><input type="text" name="amount" value=""></input></td>
   </tr></tbody></table>
 <input type="hidden" name="payment" value="true"></input>
 <input type="submit" Text="Send"></input></form></body></html>
<?
}
?>

So it seems very easy :huh: .

Just build the string, send to the merchant by GET (I dont think the curl is mandatory, right?), then study the response.

Response is an XML string that I need to parse. If <status>000</status>, its ok, anything else is an error and the card was not charged.

 

Can you point me in the right direction? Many Thanks!


If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Share this post


Link to post
Share on other sites

Dear SGershon,

 

 

Thank you very much for response.

 

I should say that my Merchant says that all information should be entered at therir website and I should not collect any information such as Card Number and password on my website.

So, I should only post 3 parameters to their website which is :

 

1) Total price of order

2) a Reference number from OsCommerce

3) Merchant ID

 

Can you please send me a sample Script of this.

For example, from checkout_confirmation.php I should send the total price.

My Merchant ID is : 00019001-36

and I need a reference number from osCommerce. I don't know what it can be.

 

The information should be posted to : https://www.sb24.com/CardServices/cardServices.jsp

 

Please update me.

 

 

Regards,

Marcheloo

Share this post


Link to post
Share on other sites
Can you introduce me a module like that , so I edit to my needs ?

Hi.

 

Just dig around in your installation of OSCommerce, and you'll find a directory (folder for windows users) called "modules". It will have a subdirectory called "Payment". That's where all the payment modules are. I need to warn you though: if you don't know how to program in php, you're in VERY DEEP waters there...

Better yet, if you don't know how to program in php, you'd better learn :-)

 

Also, posting things like Merchant ID, and the secure pages where the transaction is processed, is BAD FORM indeed... There are crackers around, you know...

 

Eskil, I thought of $CustomerID, or $CartID, but then that's not really unique is it? What if the same customer decides to do a second transaction before shipment is finished? Then you'd have a duplicate orderid in the bank, and the second transaction would be automatically rejected. Same holds for shopping carts. What if someone decides to buy two things, and keep three more in their wishlist: first transaction. Then they decide to buy the remaining things. Second transaction, same cartID=> duplicate orderid=>second transaction failed. That won't do. So I think I'll stick with my (improved) id generator:

srand(time());
$one=rand()*1000;
$two=rand()*1000;
$unique_id=md5($one.time().date('d/m/Y').$Customer_ID.$amount.$Cart_ID.$two);

 

I'd say that's pretty unique...

 

However, thank you for the input on before_process() it solved a small mystery, namely it answered the question: "HOW ON EARTH am I going to get this OK message to the bank if the transaction data they send me match the ones I sent in the first place?"

 

Now, with that one answered, I can continue working on the module, and MAYBE, get it to work...

 

Yiangos

Edited by yiangos

Feu! Edome8a upo rhnnosxhmwn lukwn!

Share this post


Link to post
Share on other sites

Yes, I think that would do ok with your payserver...

 

But...

 

A GET??? It seems rather risky to send trsansaction records through a get...

 

As regards the XML, I haven't seen any xml parsers in OSCommerce. You can use DOM, if your php installation has it. I do have another suggestion though: I have an xml parser class - conveniently called xml.php

 

I could send it over (it's only about 1500 lines of code - send me a private message for the details). You could include() it where you need the xml parsing, and retrieve whatever you want as a string.

 

Alternatively, you could subscribe to phpclasses.org (it's free, but they send you an email with EACH AND EVERY ONE script they upload, it's a bit irritating) and check their stuff as well. They have tons of php scripts (all of them defining classes) for various things. I think I got this one from there.

 

Yiangos


Feu! Edome8a upo rhnnosxhmwn lukwn!

Share this post


Link to post
Share on other sites

I did some progress with modifing the e-gold payment module :

 

 

tep_draw_hidden_field('Amount', ($order->info['total']) ) .

tep_draw_hidden_field('MID', '00019001-36') .

tep_draw_hidden_field('ResNum', $this->sort_order) .

tep_draw_hidden_field('RedirectURL', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL')) .

 

So you see, I have t send 4 parameters to the Merchant.

1) Amount

2) MID (Merchant ID)

3) ResNum (a unique Reference Number from OsCommerce)

4) RedirectURL (Returen URL from Merchant to OsCommerce)

 

The Merchant gets these information sucessfully, however I don't know how to show the results from Merchant.

It posts 3 parameters to OsCommerce.

 

1) RefNum (A digital receipt number from Merchant)

2) State (Status of process)

3) ResNum (OsCommerce Reference number back again from Merchant)

 

I don't know how to insert these parameters to OsCommerce.

 

 

Best Regards,

Marcheloo

Edited by marcheloo

Share this post


Link to post
Share on other sites
A GET??? It seems rather risky to send trsansaction records through a get...
Sorry.

Actually the "curl -d" implies POST.

I just confused POST and GET... :)

As regards the XML, I haven't seen any xml parsers in OSCommerce. You can use DOM, if your php installation has it. I do have another suggestion though: I have an xml parser class - conveniently called xml.php
I have DOM enabled in my server, Shared, with this conf:
DOM/XML             - enabled
DOM/XML API Version - 20020814
libxml Version      - 20419
HTML Support        - enabled
XPath Support       - enabled
XPointer Support    - enabled

The problem is that I never needed to use it (and don't know how to).

I'll try and learn, if I see its very hard I'll PM you about that class.

 

SGershon


If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Share this post


Link to post
Share on other sites
I don't know how to insert these parameters to OsCommerce.
I think what you want is what Eskil and Yango talked about

here, earlier in this forum.

Please inform if I misinterpreted your question.

 

SGershon


If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Share this post


Link to post
Share on other sites

Nice touch, merging the two threads into one...

 

Sure you can pm me anytime about the class.

 

Using it is not the -easiest- thing in the world, but I can also give you a couple of example scripts to get you started. My guess is, you need an HTTP client script (comes with OScommerce) to receive the response and parse it to extract the contents (the XML), and then the XML parser to get and process the results. The same things I'm using my HTTP client and XML parser classes for in other projects I have.

 

On second thought, don't even try to familiarise yourself with DOM, just PM me to send you the class B) It'll be faster.

 

Yiangos


Feu! Edome8a upo rhnnosxhmwn lukwn!

Share this post


Link to post
Share on other sites
Nice touch, merging the two threads into one...

 

Sure you can pm me anytime about the class.

On second thought, don't even try to familiarise yourself with DOM, just PM me to send you the class It'll be faster.

Yes, the moderators are very smart! The two threads were going in the same direction, with the same people.

 

I'll PM you later in this week (Wday-Tday) bacause I'll not going to be able to work on this untill then.

As soon as I get this working and have the time, I wan to to post a step by step of what I did, so it can be a guideline to others.

 

SGershon


If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×