使用Authorize.net AIM API退款

时间:2013-01-30 02:43:16

标签: php api payment-gateway authorize.net authorize.net-aim

我正在尝试使用Authorize.net的AIM API找到退款方式。我找到了示例代码:https://github.com/stymiee/Authorize.Net-XML。以下是我从示例中使用的代码:

require('../../config.inc.php');
require('../../AuthnetXML.class.php');

$xml = new AuthnetXML(AUTHNET_LOGIN, AUTHNET_TRANSKEY, AuthnetXML::USE_DEVELOPMENT_SERVER);
$xml->createTransactionRequest(array(
    'refId' => rand(1000000, 100000000),
    'transactionRequest' => array(
        'transactionType' => 'refundTransaction',
        'amount' => 5,
        'payment' => array(
            'creditCard' => array(
                'cardNumber' => 'XXXX1111',
                'expirationDate' => '122016'
            )
        ),
        'authCode' => '2165668159'
    ),
));

我一直收到一条错误消息,说明卡片代码丢失了。是否有任何想法可以让退款通过?

新代码:

 $xml = new AuthnetXML(AUTHNET_LOGIN, AUTHNET_TRANSKEY);
 $xml->createTransactionRequest(array(
    'refId' => rand(1000000, 100000000),
    'transactionRequest' => array(
        'transactionType' => 'refundTransaction',
        'amount' => 1.00,
        'payment' => array(
            'creditCard' => array(
                'cardNumber' => 'XXXX1014',
                'expirationDate' => '122025',
            )
        ),
        'refTransId' => '4928163616',
    ),
));

1 个答案:

答案 0 :(得分:0)

$xml = new AuthnetXML(AUTHNET_LOGIN, AUTHNET_TRANSKEY);
$xml->createTransactionRequest(array(
    'refId' => rand(1000000, 100000000),
    'transactionRequest' => array(
        'transactionType' => 'refundTransaction',
        'amount' => 1.00,
        'payment' => array(
            'creditCard' => array(
                'cardNumber' => 'XXXX1014',
                'expirationDate' => '122025',
            )
        ),
        'refTransId' => '4928163616',
        'transactionSettings' => array(
            'setting' => array(
                0 => array(
                    'settingName' => 'emailCustomer',
                    'settingValue' => 'true'
                ),
            )
        ),
    ),
));