0

我正在尝试使用omnipay-authorizenet AuthorizeNet_CIM设置支付处理器。这方面的文档不多。

步骤 1)我成功创建了网关对象,并且可以向 authorize.net 沙箱服务器发出请求。

第 2 步)是“创建卡”以供将来与令牌计费一起使用: $gateway->createCard() 。这是成功的。

来自通用 Omnipay 令牌计费文档

“... createCard($options) - 返回一个包含 cardReference 的响应对象,可用于未来的交易...”

我在上面的 createCard() 响应对象中没有看到特定的“cardReference”。

所以我创建了一个 $cardRef 数组并获取返回的响应 CustomerProfileId 和 CustomerPaymentProfileId 。

$profileResult['customerProfileId']=$response->getCustomerProfileId();

$profileResult['paymentProfileId']=$response->getCustomerPaymentProfileId();

步骤 3)是生成失败购买的函数:

function create_transaction($cardRef,$amount,$description,$invoice_number){

global $status, $gateway;

try {

// Send purchase request
$response = $gateway->purchase(
    array(
        'cardReference' => $cardRef ,               
        'amount' => $amount,
        'currency' => 'USD',                
        'description' => $_POST['description'],
        'transactionId' => $invoice_number

    )
)->send();          
if ($response->isSuccessful()) {

    // Payment was successful       
    $status.='Success: '.$response->getMessage();

} elseif ($response->isRedirect()) {

    // Redirect to offsite payment gateway
    $response->redirect();

} else {        

    // Payment failed
    $status.='Transaction Failure: '.$response->getMessage();

}       

} catch (Exception $e) {

    $status.='<strong>Error:</strong> '.$e->getMessage(). "<br/>";

}       

}

购买失败,当我查看 Response 对象时,似乎 Request 没有填充cardReference对象。

[cardReference] => Omnipay\AuthorizeNet\Model\CardReference Object
(
[customerProfileId:Omnipay\AuthorizeNet\Model\CardReference:private] =>
[paymentProfileId:Omnipay\AuthorizeNet\Model\CardReference:private] =>
[shippingProfileId:Omnipay\AuthorizeNet\Model\CardReference:private] =>
)

我显然没有将正确的cardReference数据传递给购买方法。

任何帮助将不胜感激。

谢谢

4

1 回答 1

1

我显然需要使用无证的 Omnipay 方法;

$response->getCardReference();

获取 cardReference 对象以传递给我的 create_transaction() 函数。

都修好了。

谢谢

于 2017-02-21T21:28:06.300 回答