Jump to content

v5.1 Token support for eWay (Australia)


Damo

Recommended Posts

  • Replies 79
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Ok, so below is a copy of the code to make the eway token to work - drop it into the gateway folder like the other eway token file instructions -

 

<?php

function ewaytp_config() {
$configarray = array( 'FriendlyName' => array( 'Type' => 'System', 'Value' => 'eWay Token Payments' ), 'customerid' => array( 'FriendlyName' => 'Customer ID', 'Type' => 'text', 'Size' => '25', 'Description' => '' ), 'username' => array( 'FriendlyName' => 'Username', 'Type' => 'text', 'Size' => '40', 'Description' => '' ), 'password' => array( 'FriendlyName' => 'Password', 'Type' => 'password', 'Size' => '25', 'Description' => '' ), 'demomode' => array( 'FriendlyName' => 'Demo Mode', 'Type' => 'yesno' ) ); return $configarray; }

function ewaytp_storeremote($params) {
if ($params['demomode']) {
$url = 'https://www.eway.com.au/gateway/ManagedPaymentService/test/managedCreditCardPayment.asmx';
} else {
$url = 'https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx';
}


$xml = '<?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:man="https://www.eway.com.au/gateway/managedpayment">
<soapenv:Header>
<man:eWAYHeader>
<man:eWAYCustomerID>' . $params['customerid'] . '</man:eWAYCustomerID> <man:Username>' . $params['username'] . '</man:Username> <man:Password>' . $params['password'] . '</man:Password> </man:eWAYHeader> </soapenv:Header> '; $xml_header = $xml;


if ($params['gatewayid'] == '') {
$xml .= '<soapenv:Body>
<man:CreateCustomer>
<man:Title>Mr.</man:Title>
<man:FirstName>' . $params['clientdetails']['firstname'] . '</man:FirstName> <man:LastName>' . $params['clientdetails']['lastname'] . '</man:LastName> <man:Address>' . $params['clientdetails']['address1'] . '</man:Address> <man:Suburb>' . $params['clientdetails']['city'] . '</man:Suburb> <man:State>' . $params['clientdetails']['state'] . '</man:State> <man:Company>' . $params['clientdetails']['companyname'] . '</man:Company> <man:PostCode>' . $params['clientdetails']['postcode'] . '</man:PostCode> <man:Country>' . strtolower( $params['clientdetails']['country'] ) . '</man:Country> <man:Email>' . $params['clientdetails']['email'] . '</man:Email> <man:Fax></man:Fax> <man:Phone></man:Phone> <man:Mobile></man:Mobile> <man:CustomerRef></man:CustomerRef>
<man:JobDesc></man:JobDesc>
<man:Comments></man:Comments>
<man:URL></man:URL>
<man:CCNumber>' . $params['cardnum'] . '</man:CCNumber> <man:CCNameOnCard>' . $params['clientdetails']['firstname'] . ' ' . $params['clientdetails']['lastname'] . '</man:CCNameOnCard> <man:CCExpiryMonth>' . substr( $params['cardexp'], 0, 2 ) . '</man:CCExpiryMonth> <man:CCExpiryYear>' . substr( $params['cardexp'], 2, 2 ) . '</man:CCExpiryYear> </man:CreateCustomer> </soapenv:Body> </soapenv:Envelope> '; } else { $xml .= '<soapenv:Body> <man:UpdateCustomer> <man:managedCustomerID>' . $params['gatewayid'] . '</man:managedCustomerID> <man:Title>Mr.</man:Title> <man:FirstName>' . $params['clientdetails']['firstname'] . '</man:FirstName> <man:LastName>' . $params['clientdetails']['lastname'] . '</man:LastName> <man:Address>' . $params['clientdetails']['address1'] . '</man:Address> <man:Suburb>' . $params['clientdetails']['city'] . '</man:Suburb> <man:State>' . $params['clientdetails']['state'] . '</man:State> <man:Company>' . $params['clientdetails']['companyname'] . '</man:Company> <man:PostCode>' . $params['clientdetails']['postcode'] . '</man:PostCode> <man:Country>' . strtolower( $params['clientdetails']['country'] ) . '</man:Country> <man:Email>' . $params['clientdetails']['email'] . '</man:Email> <man:Fax></man:Fax> <man:Phone></man:Phone> <man:Mobile></man:Mobile> <man:CustomerRef></man:CustomerRef>
<man:JobDesc></man:JobDesc>
<man:Comments></man:Comments>
<man:URL></man:URL>
<man:CCNumber>' . $params['cardnum'] . '</man:CCNumber> <man:CCNameOnCard>' . $params['clientdetails']['firstname'] . ' ' . $params['clientdetails']['lastname'] . '</man:CCNameOnCard> <man:CCExpiryMonth>' . substr( $params['cardexp'], 0, 2 ) . '</man:CCExpiryMonth> <man:CCExpiryYear>' . substr( $params['cardexp'], 2, 2 ) . '</man:CCExpiryYear> </man:UpdateCustomer> </soapenv:Body> </soapenv:Envelope> '; }

$ch = curl_init($url);
curl_setopt( $ch, CURLOPT_MUTE, 1);
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 ); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 ); curl_setopt( $ch, CURLOPT_POST, 1 ); curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml') ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $xml ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); $data = curl_exec( $ch ); curl_close( $ch );

if ($xmldata = XMLtoArray( $data )) {
$managedCustomerID = $xmldata['SOAP:ENVELOPE']['SOAP:BODY']['CREATECUSTOMERRESPONSE']['CREATECUSTOMERRESULT'];

if ($managedCustomerID) {
update_query( 'tblclients', array( 'gatewayid' => $managedCustomerID ), array( 'id' => $params['clientdetails']['userid'] ) ); }

return array( 'status' => 'success', 'rawdata' => array( $data ) ); }

return array( 'status' => 'failed', 'rawdata' => array( $data ) ); }

function ewaytp_capture($params) {
if ($params['demomode']) {
$url = 'https://www.eway.com.au/gateway/ManagedPaymentService/test/managedCreditCardPayment.asmx';
} else {
$url = 'https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx';
}


$xml = '<?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:man="https://www.eway.com.au/gateway/managedpayment">
<soapenv:Header>
<man:eWAYHeader>
<man:eWAYCustomerID>' . $params['customerid'] . '</man:eWAYCustomerID> <man:Username>' . $params['username'] . '</man:Username> <man:Password>' . $params['password'] . '</man:Password> </man:eWAYHeader> </soapenv:Header> '; $xml_header = $xml; $params['amount'] = $params['amount'] * 100; $managedCustomerId = $params['gatewayid'];


if (!$managedCustomerId) {
return array( 'status' => 'skipped', 'rawdata' => 'No Remote Customer ID Found' ); }

if (!$params['cccvv']) {
$action = 'ProcessPayment';
$process_xml = $xml_header . '<soapenv:Body> <man:ProcessPayment> <man:managedCustomerID>' . $managedCustomerId . '</man:managedCustomerID> <man:amount>' . $params['amount'] . '</man:amount> <man:invoiceReference>' . $params['invoiceid'] . '</man:invoiceReference> <man:invoiceDescription>Payment for Invoice #' . $params['invoiceid'] . '</man:invoiceDescription> </man:ProcessPayment>'; } else { $action = 'ProcessPaymentWithCVN'; $process_xml = $xml_header . '<soapenv:Body> <man:ProcessPaymentWithCVN> <man:managedCustomerID>' . $managedCustomerId . '</man:managedCustomerID> <man:amount>' . $params['amount'] . '</man:amount> <man:invoiceReference>' . $params['invoiceid'] . '</man:invoiceReference> <man:invoiceDescription>Payment for Invoice #' . $params['invoiceid'] . '</man:invoiceDescription> <man:cvn>' . $params['cccvv'] . '</man:cvn> </man:ProcessPaymentWithCVN>'; }


$process_xml .= '</soapenv:Body>
</soapenv:Envelope>
';

logTransaction( 'eWay Sent', $process_xml, 'Sent' );

$process_ch = curl_init($url);
curl_setopt( $process_ch, CURLOPT_MUTE, 1); curl_setopt( $process_ch, CURLOPT_SSL_VERIFYHOST, 0 ); curl_setopt( $process_ch, CURLOPT_SSL_VERIFYPEER, 0 ); curl_setopt( $process_ch, CURLOPT_POST, 1 ); curl_setopt( $process_ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml') ); curl_setopt( $process_ch, CURLOPT_POSTFIELDS, $process_xml ); curl_setopt( $process_ch, CURLOPT_RETURNTRANSFER, 1 ); $process_data = curl_exec( $process_ch ); curl_close( $process_ch );

if ($process_xmldata = XMLtoArray( $process_data )) { $trans_status = $process_xmldata['SOAP:ENVELOPE']['SOAP:BODY'][strtoupper( $action ) . 'RESPONSE']['EWAYRESPONSE']['EWAYTRXNSTATUS'];
$trans_id = $process_xmldata['SOAP:ENVELOPE']['SOAP:BODY'][strtoupper( $action ) . 'RESPONSE']['EWAYRESPONSE']['EWAYTRXNNUMBER'];

if ($trans_status == 'True') {
return array( 'status' => 'success', 'transid' => $trans_id, 'rawdata' => $process_data ); }

if ($trans_status == 'False') {
return array( 'status' => 'declined', 'rawdata' => $process_data ); }

return array( 'status' => 'failed', 'rawdata' => $process_data ); }

return array( 'status' => 'error', 'rawdata' => ( '' . 'XML: ' . $process_xml . '
' ) . '
Data: ' . $process_data );
}

?>

 

 

There is still some things I need a hand with.

 

First I notice that even though this stores the eway token id in the clients column gatewayid - it appears that the credit card details are also stored? Not sure on the details of this yet but will work on it .... guessing it is part of the credit card code ... not part of this module

 

Second - I have setup a custom field for the Title (i.e added a drop down on profile with Mr.,Mrs.,Ms., etc) as required by eway develop code - but not sure on how to implement this into the above for this line here - <man:Title>Mr.</man:Title> - so that every person does not need to be a Mr. :) - must be a way to use customfield code in this gateway module .. help?

 

Thirdly - I notice that if you do change the payment method from old eway to new ewaytp then in the tbclient database column default gateway it still remains as eway - so this may need to be manually changed by mysql query or via persons logging in and changing when they pay next time?

 

Any way work in progress - but I'm sure putting this out there will be some help to expedite things. Works better than the current one ;)

Edited by Infopro
wrapped code in code tags
Link to comment
Share on other sites

Ok - attached is eway token code working thus far ... install as per other eway token downloaded from whmcs site ...

 

Still need hand with a few things ...

 

First - it looks like credit card details are still stored even though the eway token id is stored in the tbclients table under the gatewayid - so this will need to be looked at further.

 

Second - the section - <man:Title>Mr.</man:Title> - needs to be changed... I have added a customised drop down field in the profile for Title that includes Mr.,Mrs.,Ms., etc as per eway token guide ..... but need to work out how to add a customised field as a parameter to the gateway module so not everyone is a Mr :)

 

Thirdly, if you had eway set in the default gateway and then select eway token as new - then you may need to manually change the default gateway column in tblclients column with a mysql query - or get the customers to update ... which they will need to do to get a gatewayid number from eway.

 

Anyway this is a start and with this out we can all work on it :) And its better than what we have currently .... ;)

ewaytp.zip

Link to comment
Share on other sites

OK, so essentially the official release from WHMCS is a dogs breakfast - Completly broken.

 

No wonder I havnt had a reply (still) since the 31st of last month.

 

We upgraded to 5.1.2 on the promise of eway token support. :-(

 

To find out that its completly and utterly broken makes me a tad angry.

Link to comment
Share on other sites

Look at the bright side - we can work towards getting it right now. The problem I have with things like encrypted code all the time is that when you rely heavily on a couple of people for support ... In the end it gets too much and we have issues like this. Alternatively if they opened the code a bit , users of the product could get sooooo much more done and assist and get these issues solved faster.

Link to comment
Share on other sites

But if there was well documented code out there already then they wouldn't have had to start from scratch and their customers could have had a better solution faster that didn't rely exclusively on a small group of devs for support and maintenance.

Link to comment
Share on other sites

Ok,

 

Here is a good working version of the eway token payment. Upload to gateway module and fill out details as required. Tested a few things and seems ok.

 

Issues fixed -

 

Wrong xml layout to eway fixed.

Wrong xml headers fixed

Unsafe storage of credit details into log via xml data fixed

Removal of credit card info from mysql database on transaction now occurs (updates database with blank details cc number and other bits - but keeps name of card and last 4 digits to keep client login details ok for repayment ...)

Attempt to redo transaction without credit card details fixed

Logging of details and errors - more detail

Additional customfield of Title added - Note: If you wish to take advantage of Title function you will need to add a dropdown customfield called Title with the following in the select options section - Mr.,Mrs.,Ms.,Miss,Dr.,Sir.,Prof. - default if not included is to use Mr.

 

Anyway - please give it a go and let me know if successful or not - code is open to anyone who wants to make improvements :)

 

I will be back to the forum again soon - no doubt looking for help on other issues :)

ewaytp.php.zip

Link to comment
Share on other sites

I have had a reply from support advising that they should have a working version by Monday Afternoon. (its now late monday arvo here in Australia, but I assume they meant UK time) - So hopefully by this time tomorrow WHMCS will have rerealeased the eway token module with the required fixes.

Link to comment
Share on other sites

The responce was:

 

"Hi David,

 

Thank you for updating this ticket with the eWay response. We have updated the module as per your update and will have an update by Monday evening after running a few tests.

 

Regards,

 

Vijay

Developer"

 

The mention of 'updated the module as per your update' refers to some info eway gave me:

 

The fields being passed is correct but the <man:Fax></man:Fax> is n the wrong position. What you have now is;

.

..

...

<man:Email>adrian@dreamtilt.com.au</man:Email>

<man:Phone></man:Phone>

<man:Mobile></man:Mobile>

<man:Fax></man:Fax>

<man:URL></man:URL>

...

..

.

Where it should be;

.

..

...

<man:Email>adrian@dreamtilt.com.au</man:Email>

<man:Fax></man:Fax>

<man:Phone></man:Phone>

<man:Mobile></man:Mobile>

<man:URL></man:URL>

Link to comment
Share on other sites

Eway have responded with this:

 

Hi David,

 

Please find the updated module attached and let us know if you still notice any issues. If you collected "Title" during the registration process using a Custom Client Field, you can enter the name of the Custom Client Field under Admin Area > Setup > Payments > Payment Gateways > eWay Token Payments.

 

Regards,

 

Vijay

Developer

 

I have attached a ziped version of the file. Unfortunatly WHMCS encoded it, so I cannot see what they changed, nor have I had time to test it.

ewaytp.zip

Link to comment
Share on other sites

I'm going to leave it out and see what happens.

 

I dream of the day when developers document the reasons behind things like this field, rather than simply tell us what to do with it. In this case, they have not documented the reason for it nor the consequences of leaving it out.

Link to comment
Share on other sites

FYI - the title field is required by the eway token payment api. WHMCS does not have a Title component in their database - so the option is to add a custom Title field with Mr., Mrs., Ms., etc or the script will use the default and add everyone to eway token payment as a Mr. in the title field. Looks like the new script above does the same ... worst case scenario is everyone in your eway database token payment section will have a Mr. in the title section......

Link to comment
Share on other sites

Ok, this morning when my daily cron ran, WHMCS successfully processed an overdue invoice via the eway Token gateway. Its been trying every day for the last few days, but has been unsuccessful due to lack of funds. Today the client had the money and it was successful. Im stoked that the Token system is now working :-)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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