jonhas Posted August 9, 2012 Share Posted August 9, 2012 Just spent most of the day upgrading from 5.0.3 to 5.1.2 (battling blank screens and getting customisations etc up and running) only to find out about this issue with the eWay Token. I hope this gets sorted out soon. 0 Quote Link to comment Share on other sites More sharing options...
arobo Posted August 9, 2012 Share Posted August 9, 2012 (edited) 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 September 7, 2012 by Infopro wrapped code in code tags 0 Quote Link to comment Share on other sites More sharing options...
arobo Posted August 9, 2012 Share Posted August 9, 2012 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 0 Quote Link to comment Share on other sites More sharing options...
arobo Posted August 9, 2012 Share Posted August 9, 2012 Ok - worked out how to add the custom field of Title and other further information to the XML request to eway (such as adding WHMCS client id in the Customer Ref section of the xml .... will post update tomorrow ... 0 Quote Link to comment Share on other sites More sharing options...
slim Posted August 10, 2012 Share Posted August 10, 2012 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. 0 Quote Link to comment Share on other sites More sharing options...
arobo Posted August 10, 2012 Share Posted August 10, 2012 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. 0 Quote Link to comment Share on other sites More sharing options...
slim Posted August 10, 2012 Share Posted August 10, 2012 Yeah, as long as the changes get rolled into the core app I'll be happy. I hate it when customers need to develop fixes and the developers ignore the fixes and keep on distributing broken code. 0 Quote Link to comment Share on other sites More sharing options...
jonhas Posted August 10, 2012 Share Posted August 10, 2012 I'm not sure why modular components like payment gateways and registrar modules should be encrypted. It's not like they can be used without the core. In cases like this it creates more problems than it fixes. 0 Quote Link to comment Share on other sites More sharing options...
slim Posted August 10, 2012 Share Posted August 10, 2012 True - Thou, I would suspect its due to the payment gateway themselves having a bit to do with the development and they wouldnt want the code open for other 'similar' gateways to pinch 0 Quote Link to comment Share on other sites More sharing options...
jonhas Posted August 10, 2012 Share Posted August 10, 2012 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. 0 Quote Link to comment Share on other sites More sharing options...
jonhas Posted August 10, 2012 Share Posted August 10, 2012 Pros and Cons I guess. All I really want is a working gateway to go with my brand new eWay account and merchant facility. 0 Quote Link to comment Share on other sites More sharing options...
slim Posted August 10, 2012 Share Posted August 10, 2012 Yep, I just want it to work to! Using the regular module shouldnt really be an option these days - Storing the cards is just to much of a risk. 0 Quote Link to comment Share on other sites More sharing options...
arobo Posted August 11, 2012 Share Posted August 11, 2012 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 0 Quote Link to comment Share on other sites More sharing options...
jonhas Posted August 13, 2012 Share Posted August 13, 2012 I still seem to be getting an error? has anyone else had success with arobo's file? 0 Quote Link to comment Share on other sites More sharing options...
slim Posted August 13, 2012 Share Posted August 13, 2012 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. 0 Quote Link to comment Share on other sites More sharing options...
slim Posted August 13, 2012 Share Posted August 13, 2012 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> 0 Quote Link to comment Share on other sites More sharing options...
arobo Posted August 13, 2012 Share Posted August 13, 2012 might pay to take my email off the last post that was me talking to eway regards the info. jonhas - can you provide some details on the error you are getting? Have you also looked at the customfield requirement? 0 Quote Link to comment Share on other sites More sharing options...
slim Posted August 13, 2012 Share Posted August 13, 2012 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 0 Quote Link to comment Share on other sites More sharing options...
jonhas Posted August 14, 2012 Share Posted August 14, 2012 The new version appears to be working 0 Quote Link to comment Share on other sites More sharing options...
slim Posted August 14, 2012 Share Posted August 14, 2012 Did you map the title field? I dont collect title in my signup.. 0 Quote Link to comment Share on other sites More sharing options...
jonhas Posted August 14, 2012 Share Posted August 14, 2012 Yeah, I added the extra field. 0 Quote Link to comment Share on other sites More sharing options...
slim Posted August 14, 2012 Share Posted August 14, 2012 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. 0 Quote Link to comment Share on other sites More sharing options...
arobo Posted August 15, 2012 Share Posted August 15, 2012 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...... 0 Quote Link to comment Share on other sites More sharing options...
slim Posted August 15, 2012 Share Posted August 15, 2012 I can live with that - No one will ever see it 0 Quote Link to comment Share on other sites More sharing options...
slim Posted August 16, 2012 Share Posted August 16, 2012 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 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.