eWay Gateway problem.

There was a problem setting up the transaction with eWay: Amount is not valid; Currency is not valid or not allowed;

Hi I just had a client pay for eWay membership etc, and ive run into this problem.

firstly ignore the Currency issue, I know why thats broken, but the Amount is not Valid error.. thats got me stumped.

Can a developer please check out eWay payment gateway and check its still working as it should from a fresh install?

  • Jamin
    • Site Builder, Child of Zeus

    All checked.

    My client has signed up to eWay NZ (not australia) so I updated the file to include the nz.eway gateway instead of au.eway.

    This doesnt fix the Amount is not valid error, which is the major problem.

    I believe that the $_SESSION is not passing the total amount to eWay.

    Can you please notify the lead developer of this thread.

  • Kimberly
    • Champion of Loops

    The lead developer is not available, but I have someone else looking into it and have called in a favor from someone that may be able to help.

    Have you updated the Marketpress currency settings as well?

    If you are using the Sandbox you need to test in AUD currency. Have you tried to test the reporting in the eWAY account direct?

  • Paul
    • The Green Incsub

    @Jamin, if you have the ability to edit your PHP code I would like to get some debug information from you.

    I need you to find the eway gateway file . Should be located
    /wp-content/plugins/marketpress/marketpress-includes/plugins-gateway/eway.php

    Open the file then go to line 192. You should see where the amount value is set. Then the next line is where the call to eWay is made.

    `$params['Amount'] = $mp->display_currency($total);

    $result = $this->api_call('https://au.ewaygateway.com/Request', $params);`

    What I want you to do is add the following line between those lines

    echo "params<pre>"; print_r($params); echo "</pre>";

    When you hit the checkout Confirm Your Purchase page you should see the debug output at the top. Something like the following:

    http://screencast.com/t/40NCHLVKBxZW

    This should help us debug what is going on. From my initial testing this morning things do seem to work correctly as advertised.

  • Paul
    • The Green Incsub

    @Jamin, Sorry for more followup. Have been running more tests on my end. About my setup.

    WordPress 3.4 RC2
    MarketPress 2.5.9 (current)
    Theme: TwentyEleven
    Plugins: No other plugins running.

    MarketPress setup
    Store Settings > General - I've setup the Base Country for NZ http://screencast.com/t/D0OPj77hDD on this same page I have the Currency setup also as NZ http://screencast.com/t/hbvSWlst

    Store Settings > Payments - I've enable eWay. And have the eWay Currency set to NZ http://screencast.com/t/iIBQMYumUL

    I made an edit to the eWay gateway PHP code /wp-content/plugins/marketpress/marketpress-includes/plugins-gateway/eway.php line 194 to changed the gateway request URL from using the AU to NZ system.

    $result = $this->api_call('https://nz.ewaygateway.com/Request', $params);

    I've setup a single $10.00 product in my local test system. Added a quantity of 1 to my cart. Went through the processing. And way able to get to the eWay checkout
    page http://screencast.com/t/dHJZM5ojXP the URL is https://nz.ewaygateway.com/NZ/PaymentPage.aspx?value=??? to provide proof it went to NZ and not AU.

    So at this point I'm not sure the issue on your end. Kimberly has befriended a technical contact at eWay. What we need to do it somehow figure out the exact error code number returned. I have a PDF of the API code when we have this.

    In your away.php file after the line for the gateway:
    $result = $this->api_call('https://nz.ewaygateway.com/Request', $params);

    Can you add this additional line to output the result
    echo "result<pre>"; print_r($result); echo "</pre>";

    The result is actually XML code. So you will need to view source in your browser to capture it and paste it back into this thread.

    I know we are 12 hours apart. So I'll be around this evening my time to help get this resolved.

  • Jamin
    • Site Builder, Child of Zeus

    hi Paul,

    thanks very much for looking into this. Time is running out to get it working before the client launches.

    I followed your exact instructions. Everything is set to NZ dollar, country, currency etc like in your screenshots.

    Here is the debug output:

    result
    FalseAmount is not valid;

    I am running WP 3.3 and the current version of Marketpress.

    I can grant you ftp access if its easier as we are on the other side of the world :slight_smile:

  • Paul
    • The Green Incsub

    Jamin,

    Yeah, that re info doest not help. This is not listed in the API documentation for eWay Shared processing.

    If you can provide FTP and wp-admin access that would be great. Please send that to my email paul [at] incsub.com. Then I can see what is different on your setup.

    Thanks.

    Paul

  • Jamin
    • Site Builder, Child of Zeus

    print_r($params) =

    Array
    (
        [CustomerID] => 1246xxxxxx
        [UserName] => timmxxxxx@xxxxx
        [MerchantInvoice] => 758xxxxxxx
        [MerchantReference] => 758xxxxxxx
        [Currency] => NZD
        [Language] => EN
        [ReturnURL] => http://customtabs.co.nz/edaboc2/store/shopping-cart/confirmation/
        [CancelURL] => http://customtabs.co.nz/edaboc2/store/shopping-cart/checkout/?eway-cancel=1
        [ModifiableCustomerDetails] => false
        [InvoiceDescription] => Theme Test Store Purchase - Order ID: 7584d1dc87b3
        [CustomerEmail] => ben@custoxxxxxx
        [CustomerFirstName] => Ben
        [CustomerLastName] => Ben
        [CustomerAddress] => MY PRIVATE ADDRESS YOU CANT SEE IT :P
        [CustomerPhone] => MY PRIVATE NUMBER LOL
        [CustomerPostCode] => 10xxxx
        [CustomerCity] => Auckland
        [CustomerState] => NL
        [CustomerCountry] => NZ
        [Amount] => 2
    )

    everything looks like it should be working..

  • Jamin
    • Site Builder, Child of Zeus

    Paul youre correct about the decimal.

    That is the error. I just turned off the option to remove the decimal place from Store settings.

    It worked!

    Maybe you have a way of it using decimal places when checking out with the option still on.

  • Paul
    • The Green Incsub

    Great!!

    Yeah, I think that logic has to do really with the gateway. I think most gateways expect amounts with 2 decimal places always. I'm not aware of one without. Regardless the option you mention is on the store presentation side. So for your presentation you should be able to chose to show prices for provides without the decimal. But when the order processing kicks in for the gateway I think MarketProcess should format it to include the 2 decimal places.

    So I think you found a slight bug. For now I would say leave the decimal showing until we can get this patched. I need to check with Aaron who is the lead developer of this plugin.

  • Jamin
    • Site Builder, Child of Zeus

    Yay we (you really lol) found a bug :smiley:

    Ok i will have to just go with having the decimal in there for now, my client wont like it lol but meh as long as he can launch on time he'll be happy :slight_smile:

    Thank you Paul!

    Ben

  • Paul
    • The Green Incsub

    Ben,

    Sorry about that. But yeah at least it should work now. One other thing is I don't like having to edit the PHP code to alter the URL for the NZ vs. AU eWay system. If you ever upgrade that change would need to be reapplied. So need to put this on the UI where you can select it like the other gateway options.

    So since I have FTP access I could patch the eWay gateway PHP code to add in the decimal places. This way you can leave then off for the user presentation.

  • Jamin
    • Site Builder, Child of Zeus

    Please if you could do that, I make lots of backups before I update in case anything breaks. I have a log of all the core changes I make. Ill note this one down too incase its not fixed in the next update.

    It would be handy to have an option to change the eWay gateway address depending on the currency selected.

  • Paul
    • The Green Incsub

    This hack is now done (A one line change actually) to the eway.php file line 193

    //$params['Amount'] = $mp->display_currency($total); // Old line
    $params['Amount'] = number_format( round( $total, 2 ), 2, '.', ''); // New line

    Just to confirm the 'Show Decimal in Prices' option under Store Settings General tab is current 'No'. Just ran a test with quantity of 2 in the cart.
    http://screencast.com/t/fyg3d3Qi

    And order went to eWay correctly. http://screencast.com/t/RQeeWGvgSCeK for the corrected $2.00 amount.

    So please backup the eway.php file. And please confirm this is working (again). Then when you are ready feel free to close this ticket.

    Thanks.

    Paul

  • Jamin
    • Site Builder, Child of Zeus

    Oh look at me, fixed it.

    The response from eWay was TrxnStatus=true.

    Whats in the eway.php file line ~278 is

    if ($xml->TrxnStatus == 'True') {

    changed to non-capital true and fixed. There's another bug :slight_smile:

  • Jamin
    • Site Builder, Child of Zeus

    PaulM, please add another bug i discovered.

    When using the Domain Mapping plugin, the Return and Cancel URLs still use the original site url instead of the new mapped domain.

    I fixed it by stealing the following code from the Paypal Gateway file and inserting it into eWay.php line 121.

    $this->returnURL = mp_checkout_step_url('confirmation');
    $this->cancelURL = mp_checkout_step_url('checkout') . "?cancel=1";

    Without these extra lines, the payment was being processed, but the order was never sent back to the correct domain (in my case it was being sent to customtabs.co.nz/edaboc/.../confirmation instead of edaboc.com/.../confirmation).

    Dangerous bug lol

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.