eWAYPayment / eway-rapid-php

Eway Rapid PHP library
https://www.eway.com.au
MIT License
14 stars 24 forks source link

Method: UpdateTokenCustomer, ApiMethod: TransparentRedirect, Payment TotalAmount: 0 returns an Invalid Payment TotalAmount error. #13

Closed AriesXIX closed 8 years ago

AriesXIX commented 8 years ago

I'm tryng to set up a simple payment system using Transparent Redirect.

I'm able to process payments via transparent redirects, but I've been experiencing an issue when trying to update a customer's token using transparent redirect.

What I'm trying to do: I have a customer who has made a prior successful payment (I have their token stored). My requirement now is to provide a form whereby the existing customer can update their credit card information using a transparent redirect form.

What I'm getting I'm getting an "invalid Payment TotalAmount" message. When I'm requesting an accesscode. If I set the amount to 1, I'm able to pass, but your documentation (and your support engineers) suggest that I should be able to use 0 value for TotalAmount.

Seems like a bug with STEP1 for using the TransparentRedirect API Method with UpdateTokenCustomer.

Please help.

Test with the following code sample:

// installed via eway-rapid-php 1.3.4 via composer
require('../../vendor/autoload.php');

$apiKey = 'someapikey';
$apiPassword = 'somepassword';
$apiEndpoint = \Eway\Rapid\Client::MODE_SANDBOX;
$client = \Eway\Rapid::createClient($apiKey, $apiPassword, $apiEndpoint);
$transaction = [
    'Customer' => [
        'TokenCustomerID' => "someValidNumericToken",
    ],
    'Payment'=>[
        'TotalAmount'=>0
    ],
    'Method' => "UpdateTokenCustomer",
    'RedirectUrl' => 'http://somesite.com.au/thank-you/',
];

$response = $client->createTransaction(\Eway\Rapid\Enum\ApiMethod::TRANSPARENT_REDIRECT, $transaction);
if ($response->getErrors()) {
    foreach ($response->getErrors() as $error) {
        echo(\Eway\Rapid::getMessage($error));
    }
}

Any ideas?

incarnate commented 8 years ago

Hi David,

Thanks for reaching out! There is a specific method in the API for updating customers, updateCustomer, which simplifies updating a customer:

$client = \Eway\Rapid::createClient($apiKey, $apiPassword, $apiEndpoint);

$customer = [
 'TokenCustomerID' => someValidNumericToken,
 'RedirectUrl' => 'http://somesite.com.au/thank-you/'
];

$response = $client->updateCustomer(\Eway\Rapid\Enum\ApiMethod::TRANSPARENT_REDIRECT, $customer);

You can find this documented in the Token section of the eWAY API Reference. Hope this helps!