Jump to content

Payment Gateway Module Development


Dids

Recommended Posts

Hey everyone,

 

been working on a custom gw module for some time now, for a finnish payment gateway provider called Checkout.

 

The problem I'm facing is that after I checkout in WHMCS, I see the progress bar, then boom, I'm back in the cart. Gateway log is empty aswell. :-/

 

There's quite a few values that the payment gateway requires the POST to post to their url, so I've just set static values in the module, for now.

 

Any idea what could be causing this? I'd be happy to provide the code if anyone's interested in having a look (I'm more into C# than I am into PHP, so might've missed something really obvious, plus there's a lot of unneeded template code still there).

Link to comment
Share on other sites

Thanks for the quick reply. :)

 

Basically, the gateway handles all the payments, as it supports both finnish web-bank transactions and credit cards, so the usual WHMCS -> gateway -> WHMCS.

 

I'll just copy & paste the required info here, so there's the the name, value and an explanation:

 

ACTION = https://payment.checkout.fi/

METHOD = POST

 

VERSION "0001" - Always 0001

STAMP - Unique ID (invoice ID should work, I think)

AMOUNT - Price in cents, not euros and with no commas etc.

REFERENCE - Your standard transaction/invoice reference number

MERCHANT - ID of the merchant, I've got a test merchant user ID for this

RETURN - The return URL

CANCEL - The cancel URL

CURRENCY EUR - Currency, which should just be set to EUR by default

DEVICE 1 - Just sets the transaction "device/termnial" as HTML

CONTENT 1 - The 1 sets the purchase to be a "normal" purchase

TYPE 0 - The type 0 sets the type of payment

ALGORITHM 1 - Always set to 1

DELIVERY_DATE - This should be the date of the transaction, YYYYMMDD

MAC - This is an MD5 hash that gets calculated from the info above

 

So basically, the ones that don't have a value still require one.

 

Also, just tell me if this seems confusing. :P

Link to comment
Share on other sites

As far as I know, it needs all of the variables, as it doesn't state that it wants just the MD5 hash, or just the variables.

 

Guess is gets the variables and the "MAC", then compares them all together? :/

Link to comment
Share on other sites

Oh I do, and they just mention the values I mentioned before.

Here's the API documentation, although it's in finnish: http://bit.ly/8BR0U

 

You should atleast spot the values and MD5 hash generation in that PDF.

 

I'm pretty sure I need to include all the variables in the POST, as the first one, "VERSION", had to be included (without it, it just kept telling me that the version number is wrong). So now with all the info, it tells me the hash is incorrect.

Link to comment
Share on other sites

The only idea I have is with the "'s, because using "0001" as the VERSION didn't work.

 

So I'll try setting everything up statically (not using $parameters) and see if I get any further with that. :)

Link to comment
Share on other sites

I've tried several ways of debugging it, but so far I'm still not getting the md5 hash right, even though I'm using the same code for the hash generation as in the working osCommerce module.

 

Here's the source for the test code: http://didstopia.com/laskutus/testmodule.sphp

 

And the actual test: http://didstopia.com/laskutus/testmodule.php

 

I can see that it spits out the right values (as far as I can tell) but after I hit Test, it still whines about the "MAC".

Link to comment
Share on other sites

Are you sure that you need the "+" in-between all of the variables when you create your hash.

eg...

this is the hash you are creating with the extra "+"'s

F6A887FFB3135A0D62C00AE886B6A314

and here, the same info without them

D5B003F8A327F31DE41B8F22BD22B39D

 

Maybe you should go back to the API specs to see exactly how the hash is to be created.

Link to comment
Share on other sites

The API requires that the hash is in uppercase, aswell as the +'s between the values. That's what the API says anyway. :-)

 

The sample code for osCommerce also includes the +'s (as $value . "+" . $value2)

Link to comment
Share on other sites

Sure. :)

 

First it says how it calculates the fields together to form the hash, then that the fields are separated by the + sign.

 

Then it has the hash creation like this:

 

MD5(VERSION+

STAMP+

AMOUNT+

REFERENCE+

MESSAGE+

LANGUAGE+

MERCHANT+

RETURN+

CANCEL+

REJECT+

DELAYED+

COUNTRY+

CURRENCY+

DEVICE+

CONTENT+

TYPE+

ALGORITHM+

DELIVERY_DATE+

FIRSTNAME+

LASTNAME+

ADDRESS+

POSTCODE+

POSTOFFICE+

CONFIRMCODE)

Link to comment
Share on other sites

I'm happy to say that the module now works superbly well. :)

 

A british PHP guru cleaned up the code a bit, and in the process of doing that, it started working! :D

 

Now, time for that callback code. :P

 

(and time to figure out what URLs I need to use when cancelling WHMCS orders)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated