thephpleague / omnipay-authorizenet

Authorize.Net driver for the Omnipay payment processing library
MIT License
57 stars 92 forks source link

Complete example please Authorize_AIM #86

Closed luis-ordering closed 5 years ago

luis-ordering commented 7 years ago

Hi, I have this, but when I run it it does not work for me

<?
require_once '../../common/vendor/autoload.php';
use \Omnipay\Omnipay;

$amount = floatval(10);
$currency = 'USD';

$gateway = Omnipay::create('AuthorizeNet_AIM');
$gateway->setApiLoginId('LOGINID');
$gateway->setTransactionKey('TRANSACTIONKEY');
$gateway->setDeveloperMode(true);

try {
    $response = $gateway->purchase(
        array(
            'card' => array(
                'number' => 5424000000000015,
                'expiryMonth' => 12,
                'expiryYear' => 2020,
                'code' => 999,
                'cardCode' => 999
            ),
            'amount' => $amount,
            'currency' => 'USD',
            'description' => 'Example',
            'transactionId' => '01AD'
        )
    )->send();
    echo $response->getMessage();
} catch (Exception $e) {
    print_r($e);
}

The server response is:

The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:cardCode' element is invalid - The value XX is invalid according to its datatype 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:cardCode' - The Pattern constraint failed.

I appreciate your help!

Edited: judgej code formatting characters.

judgej commented 7 years ago

Although these aren't the issue (which I will look at a little later), here are a few things that are worth changing:

In fact, try the card code as a 'string' and see if that makes a difference as a first step.

judgej commented 7 years ago

Rather than code or cardCode, use cvv.

judgej commented 5 years ago

I'm guessing this is now sorted.