如何获取Authorize.net sdk for php的账单地址?

时间:2016-04-29 16:17:21

标签: php api sdk authorize.net authorize.net-cim

我正在尝试为php设置authorize.net的SDK,但我无法让帐单地址正常工作。我检查了GitHub上的示例,我可以将交易记录到我的沙箱帐户,但我不知道如何显示结算信息。请记住我不是php wiz所以如果有更深入的解释请不要假设。

这是代码......

<?php
require 'vendor/autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
define("AUTHORIZENET_LOG_FILE", "phplog");

// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("My api login");
$merchantAuthentication->setTransactionKey("my api key");

// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("6011000000000012");
$creditCard->setExpirationDate("2038-12");
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);


// Create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType( "authCaptureTransaction"); 
$transactionRequestType->setAmount(9.51);
$transactionRequestType->setPayment($paymentOne);

//Billing Address
$billTo = new AnetAPI\billToType();
$billTo->setfirstName("Jordan");
$billTo->setlastName("Smith");
$billTo->setaddress("381 Indian Ave");
$billTo->setcity("Bridgeport");
$billTo->setstate("CT");
$billTo->setzip("06606");
$billTo->setcountry("USA");


$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setTransactionRequest( $transactionRequestType);
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);

if ($response != null)
{
    $tresponse = $response->getTransactionResponse();

    if (($tresponse != null) && ($tresponse->getResponseCode()=="1") )   
    {
        echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n";
        echo "Charge Credit Card TRANS ID  : " . $tresponse->getTransId() . "\n";
    }
    else
    {
        echo  "Charge Credit Card ERROR :  Invalid response\n";
    }
}
else
{
    echo  "Charge Credit card Null response returned";
}
?>

感谢您的帮助。

以下是交易详情的图片...... enter image description here

0 个答案:

没有答案