public function testCreateTransactionApplePay()
 {
     $merchantAuthentication = new apiContract\MerchantAuthenticationType();
     $merchantAuthentication->setName(self::$LoginName);
     $merchantAuthentication->setTransactionKey(self::$TransactionKey);
     $OpaqueData = new apiContract\OpaqueDataType();
     $OpaqueData->setDataDescriptor("COMMON.APPLE.INAPP.PAYMENT");
     $OpaqueData->setDataValue("eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U2V2hGQk5uQ0hxenpXS2NrQlwvMG5xTFpSVFliRjBwK3Z5QmlWYVdIZWdoRVJmSHhSdGJ6cGVjelJQUHVGc2ZwSFZzNDhvUExDXC9rXC8xTU5kNDdrelwvcEhEY1JcL0R5NmFVTStsTmZvaWx5XC9RSk4rdFMzbTBIZk90SVNBUHFPbVhlbXZyNnhKQ2pDWmxDdXcwQzltWHpcL29iSHBvZnVJRVM4cjljcUdHc1VBUERwdzdnNjQybTRQendLRitIQnVZVW5lV0RCTlNEMnU2amJBRzMiLCJ2ZXJzaW9uIjoiRUNfdjEiLCJoZWFkZXIiOnsiYXBwbGljYXRpb25EYXRhIjoiOTRlZTA1OTMzNWU1ODdlNTAxY2M0YmY5MDYxM2UwODE0ZjAwYTdiMDhiYzdjNjQ4ZmQ4NjVhMmFmNmEyMmNjMiIsInRyYW5zYWN0aW9uSWQiOiJjMWNhZjVhZTcyZjAwMzlhODJiYWQ5MmI4MjgzNjM3MzRmODViZjJmOWNhZGYxOTNkMWJhZDlkZGNiNjBhNzk1IiwiZXBoZW1lcmFsUHVibGljS2V5IjoiTUlJQlN6Q0NBUU1HQnlxR1NNNDlBZ0V3Z2ZjQ0FRRXdMQVlIS29aSXpqMEJBUUloQVBcL1wvXC9cLzhBQUFBQkFBQUFBQUFBQUFBQUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL01Gc0VJUFwvXC9cL1wvOEFBQUFCQUFBQUFBQUFBQUFBQUFBQVwvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cLzhCQ0JheGpYWXFqcVQ1N1BydlZWMm1JYThaUjBHc014VHNQWTd6ancrSjlKZ1N3TVZBTVNkTmdpRzV3U1RhbVo0NFJPZEpyZUJuMzZRQkVFRWF4ZlI4dUVzUWtmNHZPYmxZNlJBOG5jRGZZRXQ2ek9nOUtFNVJkaVl3cFpQNDBMaVwvaHBcL200N242MHA4RDU0V0s4NHpWMnN4WHM3THRrQm9ONzlSOVFJaEFQXC9cL1wvXC84QUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cLys4NXZxdHB4ZWVoUE81eXNMOFl5VlJBZ0VCQTBJQUJHbStnc2wwUFpGVFwva0RkVVNreHd5Zm84SnB3VFFRekJtOWxKSm5tVGw0REdVdkFENEdzZUdqXC9wc2hCWjBLM1RldXFEdFwvdERMYkUrOFwvbTB5Q21veHc9IiwicHVibGljS2V5SGFzaCI6IlwvYmI5Q05DMzZ1QmhlSEZQYm1vaEI3T28xT3NYMkora0pxdjQ4ek9WVmlRPSJ9LCJzaWduYXR1cmUiOiJNSUlEUWdZSktvWklodmNOQVFjQ29JSURNekNDQXk4Q0FRRXhDekFKQmdVckRnTUNHZ1VBTUFzR0NTcUdTSWIzRFFFSEFhQ0NBaXN3Z2dJbk1JSUJsS0FEQWdFQ0FoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQXdKekVsTUNNR0ExVUVBeDRjQUdNQWFBQnRBR0VBYVFCQUFIWUFhUUJ6QUdFQUxnQmpBRzhBYlRBZUZ3MHhOREF4TURFd05qQXdNREJhRncweU5EQXhNREV3TmpBd01EQmFNQ2N4SlRBakJnTlZCQU1lSEFCakFHZ0FiUUJoQUdrQVFBQjJBR2tBY3dCaEFDNEFZd0J2QUcwd2daOHdEUVlKS29aSWh2Y05BUUVCQlFBRGdZMEFNSUdKQW9HQkFOQzgra2d0Z212V0YxT3pqZ0ROcmpURUJSdW9cLzVNS3ZsTTE0NnBBZjdHeDQxYmxFOXc0ZklYSkFEN0ZmTzdRS2pJWFlOdDM5ckx5eTd4RHdiXC81SWtaTTYwVFoyaUkxcGo1NVVjOGZkNGZ6T3BrM2Z0WmFRR1hOTFlwdEcxZDlWN0lTODJPdXA5TU1vMUJQVnJYVFBITmNzTTk5RVBVblBxZGJlR2M4N20wckFnTUJBQUdqWERCYU1GZ0dBMVVkQVFSUk1FK0FFSFpXUHJXdEpkN1laNDMxaENnN1lGU2hLVEFuTVNVd0l3WURWUVFESGh3QVl3Qm9BRzBBWVFCcEFFQUFkZ0JwQUhNQVlRQXVBR01BYndCdGdoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQURnWUVBYlVLWUNrdUlLUzlRUTJtRmNNWVJFSW0ybCtYZzhcL0pYditHQlZRSmtPS29zY1k0aU5ERkFcL2JRbG9nZjlMTFU4NFRId05SbnN2VjNQcnY3UlRZODFncTBkdEM4elljQWFBa0NISUkzeXFNbko0QU91NkVPVzlrSmsyMzJnU0U3V2xDdEhiZkxTS2Z1U2dRWDhLWFFZdVpMazJScjYzTjhBcFhzWHdCTDNjSjB4Z2VBd2dkMENBUUV3T3pBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWFCUUF3RFFZSktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0=");
     $paymentType = new apiContract\PaymentType();
     $paymentType->setOpaqueData($OpaqueData);
     //create a transaction
     $transactionRequestType = new apiContract\TransactionRequestType();
     $transactionRequestType->setTransactionType("authCaptureTransaction");
     // TODO Change to Enum
     $transactionRequestType->setAmount($this->setValidAmount($this->counter));
     $transactionRequestType->setPayment($paymentType);
     $request = new apiContract\CreateTransactionRequest();
     $request->setMerchantAuthentication($merchantAuthentication);
     $request->setTransactionRequest($transactionRequestType);
     $controller = new apiController\CreateTransactionController($request);
     $response = $controller->executeWithApiResponse(self::$TestEnvironment);
     // Handle the response.
     $this->assertNotNull($response, "null response");
     $this->assertNotNull($response->getMessages());
     self::displayMessages($response);
     if ("Ok" != $response->getMessages()->getResultCode()) {
         $this->displayTransactionMessages($response);
         //Ignore assertion for now
         //$this->assertTrue( false, "Should not reach here.");
     } else {
         $this->assertEquals("Ok", $response->getMessages()->getResultCode());
         $this->assertTrue(0 < count($response->getMessages()));
         foreach ($response->getMessages() as $message) {
             $this->assertEquals("I00001", $message->getCode());
             $this->assertEquals("Successful.", $response->getText());
         }
     }
 }
 public function testCreateTransactionCreditCard()
 {
     $this->markTestSkipped('Ignoring for Travis. Will fix after release.');
     //TODO
     $name = defined('AUTHORIZENET_API_LOGIN_ID') && '' != AUTHORIZENET_API_LOGIN_ID ? AUTHORIZENET_API_LOGIN_ID : getenv("api_login_id");
     $transactionKey = defined('AUTHORIZENET_TRANSACTION_KEY') && '' != AUTHORIZENET_TRANSACTION_KEY ? AUTHORIZENET_TRANSACTION_KEY : getenv("transaction_key");
     $merchantAuthentication = new MerchantAuthenticationType();
     $merchantAuthentication->setName($name);
     $merchantAuthentication->setTransactionKey($transactionKey);
     $refId = 'ref' . time();
     //create a transaction
     $transactionRequestType = new TransactionRequestType();
     $transactionRequestType->setTransactionType("authCaptureTransaction");
     // TODO Change to Enum
     $transactionRequestType->setAmount($this->setValidAmount($this->counter));
     $transactionRequestType->setPayment($this->paymentOne);
     $transactionRequestType->setOrder($this->orderType);
     $transactionRequestType->setCustomer($this->customerDataOne);
     $transactionRequestType->setBillTo($this->customerAddressOne);
     $request = new CreateTransactionRequest();
     $request->setMerchantAuthentication($merchantAuthentication);
     $request->setRefId($refId);
     $request->setTransactionRequest($transactionRequestType);
     $controller = new CreateTransactionController($request);
     $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
     $response = $controller->getApiResponse();
     // Handle the response.
     $this->assertNotNull($response, "null response");
     $this->assertNotNull($response->getMessages());
     $this->assertEquals("Ok", $response->getMessages()->getResultCode());
     $this->assertEquals($response->getRefId(), $refId);
     $this->assertTrue(0 < count($response->getMessages()));
     foreach ($response->getMessages() as $message) {
         $this->assertEquals("I00001", $message->getCode());
         $this->assertEquals("Successful.", $response->getText());
     }
 }
示例#3
0
function refundTransaction($amount)
{
    // Common setup for API credentials
    $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
    $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
    $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
    $refId = 'ref' . time();
    // Create the payment data for a credit card
    $creditCard = new AnetAPI\CreditCardType();
    $creditCard->setCardNumber("0015");
    $creditCard->setExpirationDate("XXXX");
    $paymentOne = new AnetAPI\PaymentType();
    $paymentOne->setCreditCard($creditCard);
    //create a transaction
    $transactionRequest = new AnetAPI\TransactionRequestType();
    $transactionRequest->setTransactionType("refundTransaction");
    $transactionRequest->setAmount($amount);
    $transactionRequest->setPayment($paymentOne);
    $request = new AnetAPI\CreateTransactionRequest();
    $request->setMerchantAuthentication($merchantAuthentication);
    $request->setRefId($refId);
    $request->setTransactionRequest($transactionRequest);
    $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 "Refund SUCCESS: " . $tresponse->getTransId() . "\n";
        } else {
            echo "Refund ERROR : " . $tresponse->getResponseCode() . "\n";
        }
    } else {
        echo "Refund Null response returned";
    }
    return $response;
}
示例#4
0
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("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$refId = 'ref' . time();
$payPalType = new AnetAPI\PayPalType();
$payPalType->setSuccessUrl("");
$payPalType->setCancelUrl("");
$paymentType = new AnetAPI\PaymentType();
$paymentType->setPayPal($payPalType);
$transactionRequest = new AnetAPI\TransactionRequestType();
$transactionRequest->setTransactionType("voidTransaction");
$transactionRequest->setPayment($paymentType);
$transactionRequest->setRefTransId(2241706281);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$request->setTransactionRequest($transactionRequest);
$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 "Void transaction SUCCESS TRANS ID  : " . $tresponse->getTransId() . "\n";
    } else {
        echo "Void transaction ERROR : " . $tresponse->getResponseCode() . "\n";
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 (with PayPal compatible merchant credentials)
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$payPalType = new AnetAPI\PayPalType();
$payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
$payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setPayPal($payPalType);
// Create an authorize and capture transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureTransaction");
$transactionRequestType->setPayment($paymentOne);
$transactionRequestType->setAmount(151);
$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) {
        echo "Received response code: " . $tresponse->getResponseCode() . "\n";
        //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent
        echo "Secure acceptance URL: " . $tresponse->getSecureAcceptance()->getSecureAcceptanceUrl() . "\n";
        echo "Transaction ID: " . $tresponse->getTransId() . "\n";
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("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$refId = 'ref' . time();
$payPalType = new AnetAPI\PayPalType();
$payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
$payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
$paymentType = new AnetAPI\PaymentType();
$paymentType->setPayPal($payPalType);
$transactionRequest = new AnetAPI\TransactionRequestType();
$transactionRequest->setTransactionType("priorAuthCaptureTransaction");
$transactionRequest->setPayment($paymentType);
$transactionRequest->setAmount(floatval(19.45));
$transactionRequest->setRefTransId(2241687191);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$request->setTransactionRequest($transactionRequest);
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
if ($response != null && $response->getMessages()->getResultCode() == "Ok") {
    $tresponse = $response->getTransactionResponse();
    if ($tresponse != null && $tresponse->getResponseCode() == "1") {
        echo "Prior Authorization capture AUTH CODE : " . $tresponse->getAuthCode() . "\n";
    } else {
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("556KThWQ6vf2");
$merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq");
$refId = 'ref' . time();
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("4111111111111111");
$creditCard->setExpirationDate("2038-12");
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
//create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("refundTransaction");
$transactionRequestType->setAmount(151.21);
$transactionRequestType->setPayment($paymentOne);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$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 "Refund SUCCESS: " . $tresponse->getTransId() . "\n";
    } else {
        echo "Refund ERROR : " . $tresponse->getResponseCode() . "\n";
 function refundTransaction()
 {
     $loggedUser = $this->Auth->user();
     //  pr($this->request->data['Transaction']);
     //    exit;
     $this->loadModel('Ticket');
     $this->loadModel('Track');
     $loggedUser = $this->Auth->user();
     // Common setup for API credentials
     $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
     // $merchantAuthentication->setName("95x9PuD6b2"); // testing mode
     $merchantAuthentication->setName("42UHbr9Qa9B");
     // live mode
     // $merchantAuthentication->setTransactionKey("547z56Vcbs3Nz9R9");  // testing mode
     $merchantAuthentication->setTransactionKey("6468X36RkrKGm3k6");
     // live mode
     $refId = 'ref' . time();
     // Create the payment data for a credit card
     $creditCard = new AnetAPI\CreditCardType();
     $creditCard->setCardNumber($this->request->data['Transaction']['card_no']);
     //$creditCard->setCardNumber("0015");
     $dateObj = $this->request->data['Transaction']['exp_date'];
     $this->request->data['Transaction']['exp_date'] = $dateObj['month'] . '/' . substr($dateObj['year'], -2);
     $creditCard->setExpirationDate($this->request->data['Transaction']['exp_date']);
     // $creditCard->setExpirationDate("XXXX");
     $paymentOne = new AnetAPI\PaymentType();
     $paymentOne->setCreditCard($creditCard);
     //create a transaction
     $transactionRequest = new AnetAPI\TransactionRequestType();
     $transactionRequest->setTransactionType("refundTransaction");
     $transactionRequest->setAmount($this->request->data['Transaction']['refund_amount']);
     $transactionRequest->setPayment($paymentOne);
     $request = new AnetAPI\CreateTransactionRequest();
     $request->setMerchantAuthentication($merchantAuthentication);
     $request->setRefId($refId);
     $request->setTransactionRequest($transactionRequest);
     $controller = new AnetController\CreateTransactionController($request);
     //$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
     $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION);
     $msg = '';
     $data4transaction['Transaction']['exp_date'] = $this->request->data['Transaction']['exp_date'];
     $data4transaction['Transaction']['card_no'] = $this->request->data['Transaction']['card_no'];
     $data4transaction['Transaction']['user_id'] = $loggedUser['id'];
     if ($response != null) {
         $tresponse = $response->getTransactionResponse();
         //pr($tresponse); exit;
         if ($tresponse != null && $tresponse->getResponseCode() == "1") {
             $data4transaction['Transaction']['paid_amount'] = $this->request->data['Transaction']['refund_amount'];
             $data4transaction['Transaction']['package_customer_id'] = $this->request->data['Transaction']['cid'];
             $data4transaction['Transaction']['status'] = 'Refund Successful';
             //   $data4transaction['Transaction']['trx_id'] = $tresponse->getTransId();
             $msg = ' <div class="alert alert-success">
         <button type="button" class="close" data-dismiss="alert"></button>
         <p> <strong>Refund SUCCESS</strong>
             </p> </div>';
             $tdata['Ticket'] = array('content' => 'Refund successfull');
             $tickect = $this->Ticket->save($tdata);
             // Data save in Ticket
             $trackData['Track'] = array('package_customer_id' => $data4transaction['Transaction']['package_customer_id'], 'ticket_id' => $tickect['Ticket']['id'], 'status' => 'closed', 'forwarded_by' => $loggedUser['id']);
             $this->Track->save($trackData);
         } else {
             $data4transaction['Transaction']['paid_amount'] = 0;
             $data4transaction['Transaction']['package_customer_id'] = $this->request->data['Transaction']['cid'];
             $data4transaction['Transaction']['status'] = 'Refund failed';
             $data4transaction['Transaction']['error_msg'] = "Refund ERROR : ";
             //. $tresponse->getResponseCode();
             $msg = ' <div class="alert alert-block alert-danger fade in">
         <button type="button" class="close" data-dismiss="alert"></button>
         <p> <strong>Refund ERROR  ' . '</strong> </p> </div>';
             $tdata['Ticket'] = array('content' => 'Refund failed for Null response');
             //  pr($tdata['Ticket']);exit;
             $tickect = $this->Ticket->save($tdata['Ticket']);
             // Data save in Ticket
             $trackData['Track'] = array('package_customer_id' => $data4transaction['Transaction']['package_customer_id'], 'ticket_id' => $tickect['Ticket']['id'], 'status' => 'closed', 'forwarded_by' => $loggedUser['id']);
             $this->Track->save($trackData);
         }
     } else {
         $data4transaction['Transaction']['paid_amount'] = 0;
         $data4transaction['Transaction']['package_customer_id'] = $this->request->data['Transaction']['cid'];
         $data4transaction['Transaction']['status'] = 'Refund failed';
         $data4transaction['Transaction']['error_msg'] = "Refund Null response returned";
         $msg .= 'Refund failed for Null response';
         $msg = ' <div class="alert alert-block alert-danger fade in">
         <button type="button" class="close" data-dismiss="alert"></button>
         <p> <strong>Refund failed for Null response  </strong> </p> </div>';
         $tdata['Ticket'] = array('content' => 'Transaction ' . ' Refund failed for Null response');
         $tickect = $this->Ticket->save($tdata);
         // Data save in Ticket
         $trackData['Track'] = array('package_customer_id' => $data4transaction['Transaction']['package_customer_id'], 'ticket_id' => $tickect['Ticket']['id'], 'status' => 'open', 'forwarded_by' => $loggedUser['id']);
         $this->Track->save($trackData);
         //            $tdata4ticket['Ticket'] = array('content' => 'Refund for ' . $pc['fname'] . ' ' . $pc['lname'] . ' failed for Charge Credit card Null response');
         //            $tickect = $this->Ticket->save($tdata); // Data save in Ticket
         //            $trackData['Track'] = array(
         //                'package_customer_id' => $cid,
         //                'ticket_id' => $tickect['Ticket']['id'],
         //                'status' => 'open',
         //                'forwarded_by' => $loggedUser['id']
         //            );
         //            $this->Track->save($trackData);
         //  echo "Refund Null response returned";
     }
     $this->loadModel('Transaction');
     //        pr($this->request->data); exit;
     $data4transaction['Transaction']['pay_mode'] = 'refund';
     $this->Transaction->save($data4transaction);
     $this->Session->setFlash($msg);
     return $this->redirect($this->referer());
 }
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("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$refId = 'ref' . time();
$profileToCharge = new AnetAPI\CustomerProfilePaymentType();
$profileToCharge->setCustomerProfileId("36731856");
$paymentProfile = new AnetAPI\PaymentProfileType();
$paymentProfile->setPaymentProfileId("33211899");
$profileToCharge->setPaymentProfile($paymentProfile);
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureTransaction");
$transactionRequestType->setAmount(100.5);
$transactionRequestType->setProfile($profileToCharge);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$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 Customer Profile APPROVED  :" . "\n";
        echo " Charge Customer Profile AUTH CODE : " . $tresponse->getAuthCode() . "\n";
        echo " Charge Customer Profile TRANS ID  : " . $tresponse->getTransId() . "\n";
use net\authorize\api\controller as AnetController;
define("AUTHORIZENET_LOG_FILE", "phplog");
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$refId = 'ref' . time();
// Create the payment data from a Visa Checkout blob
$op = new AnetAPI\OpaqueDataType();
$op->setDataDescriptor("COMMON.VCO.ONLINE.PAYMENT");
$op->setDataValue("4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248N3fjtyHrHqMuhOkB1BLiSjKWeTM9+BNj3+9nY56d7CsUfIuvVSTaJRhQQSex1dS2Y2Y+/cA5U+3D1pg5YtTmDVUGlsu1simAd3huwPnwD+CG6O8Ml0AmXvYHntmL3vFaJomadMQBy27k8Dbh5eplPBwyawKUVJ7GqTyKLe8aOYkBUHT5ANWkq2hlGps44BOoDHZ26JWjHdorBZtVIqMK1SIyW4Dih5c/Y//w2toA8WBTPILIvt4h6HPPvWZMZCHCqom9D2k4WGH5+BCEY2jHI7gfYV6xRx54i5vitsYTKm3CyA0C5+l0FNDkfUFHDvVUG9FVzRWVd0TXYhDwfa2pcfI68eYvkEfeT+ZNJ24ZXKPrJo6KZ3x6eZAhzgAMFiC+tPsiygb2zQy5PVoYoBIGj/NGNRqmhZTOEajcO3ZjWxfAnLZAmvMi+pEwJCMmuIY4qRU3RfcaXhAoaUPpDxqrSxR1m+CUKYVdt3nnnQeVaVqf+RaeV9cyFJvILeBPXTBVC50AckVLS37UuBWgWaWcchjRPk9mriDu2KlHQwdR4zu0jnLh4i3tbxV416QBcYLO6AF2Ixlm3GzqGE6QcVssgFCUAhklBWGNLP62O1jtyV4NgTD36QhvHEHby7o4XBB+mjlY6xSEXR+IW9u64AzfDCsTxWiAOE65le6cSk4NDV8DrtYeIozILivWu6wFSpy1gMfiDot4Ndv3C9xCFvH0Bzlky7NoZrvSolKTVNTs8W8UqMFV19qGl6SRaNUEhCqgso/FkdO0eGXFMdQPuP11wQzK/9F3yB9gS2rpXi9sy8DrCqnJ9EXMmliSstKuQl5+yfGc8K3Urot3t+BmNoOvzM9Aha/PzmbLnuKBN6/DUbIw5mhNMCvIA1ByispKpjeV682jl4uslkRsitGLcIOBREFXvGaLxRb37HJkXCHk+jorpDz7LUQhVkClN+hW0vXtgdHQFCIOL7uREdbvk6BZbQlFsuVEKGZxPbKPEJfqMbH54B4a4P5XNQHm4Yt4haH4T0JuYgzoSo76uuXD3g5IuUvy7x8Ykuja1rwW/k//SZAiGaZraRIIAEnzHiUP8dcufb/RonHGnJcYXIEWeIF1lX980bDA+H4vlO8/nN/Mj+EL6tT95MfRDiQHUW69qkqotQd7FJ5uWT+NtetzqDsN5s3sIhwkLKIn9EDLIav5v4SXKxkG+ycMJmGFcfhs7Td9O6hl+Om/JD3he3rgfClaFi/ZR7AVY6fWbAAm9QftKijQ6rskPDYL9Y3gVSA9rdduSg97fUHC+FdfyQXGH552cDLs2ZgzYw6KluXHEuwhACgNotxToPYTTdZxxNr1vPoqYCqHDL2dL8dkuO59/sbZE1m4ektKvUC2wz0UdTDVbHN8HSrLPn2hf/xQp5bKeDDjYkWvNKuwy+aug9H+Uu/m1LuPK/YdogVv9l25y/c2Qbj3dAJ9xTuKjmiJLKlRh4SUI9+05HjDF+i84AoUZ8LuC7LGtrN8ReYIktLhaXq9+XDh5fv4NYhnuYgWkUioKtx1dmfOMHjpLm4aE8Ra1gpJQcZAgwnqYubQvnYy0nY4VaykNix7m3vZwItpKOLqxDYxa3q0qUw25X9zafAM61kPW6EP+4idPzHNww6r1FD4Ihq644dCnCXwoSQ531DW6oAPot8iLZ/xXwoWwrW05k9t2RHjjLbw1L5r1CKgShJQfX7nkJxfGyuw1RmqoQDuNt/tj9M/dHOnoPnOYZZN0JX+Al8PI5zs+LLajw1imu9YcSpwMz3ZlfQqTfI0fjSCc8Is6qVYDMvKD0TweY4hiIxkzs+RyQmPgIeIWqf7Su5+RcnXitb3OuFibBGCjdDeG0ESG8qeiBQKZ3wEyZG09eDAfhuUR5kfZCG4Q01u2YDoRzObxLd8Ruf7HNvtefucFLubciWvOSzbDUisoz0wwOSgJGHucC3IR+1mb/4gz/dI2wvWFInhKcQz4ivkuHaFj8XwvZMcpkwPKtg3pRGTleX/gfjbHcx2VcWRcMPdlDMgTgst9ouN763TZUHHLxjECyB9pkLrR1nhG0cS/aig8Bq1+AH7tvl1wLVxm1Z77DVX4aUIxBH2YUcOgpe6mrWFi6LK3im4/grZECsL/XC4tsTEHjO/U3SazUuhP+6LiCYqp50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2");
$op->setDataKey("JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V");
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setOpaqueData($op);
//create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureTransaction");
$transactionRequestType->setAmount(151);
$transactionRequestType->setCallId("9004180129978687101");
$transactionRequestType->setPayment($paymentOne);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$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 " AUTH CODE : " . $tresponse->getAuthCode() . "\n";
        echo " TRANS ID  : " . $tresponse->getTransId() . "\n";
$authTransId = "0";
if ($response != null) {
    $tresponse = $response->getTransactionResponse();
    $authTransId = $tresponse->getTransId();
    if ($tresponse != null && $tresponse->getResponseCode() == "1") {
        echo "AUTH CODE : " . $tresponse->getAuthCode() . "\n";
        echo "TRANS ID  : " . $authTransId . "\n";
    } else {
        echo "Authorization : Invalid response\n";
    }
} else {
    echo "Authorization NULL Response Error\n";
}
// Now capture the previously authorized  amount
echo "Capturing the Authorization with transaction ID : " . $authTransId . "\n";
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("priorAuthCaptureTransaction");
$transactionRequestType->setAmount(5.0);
$transactionRequestType->setRefTransId($authTransId);
$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 "Successful." . "\n";
        echo "Capture Previously Authorized Amount TRANS ID  : " . $tresponse->getTransId() . "\n";
    } else {
        echo " Capture Previously Authorized Amount: Invalid response\n";
use net\authorize\api\controller as AnetController;
define("AUTHORIZENET_LOG_FILE", "phplog");
echo "PayPal Authorize Only Continue Transaction\n";
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$refId = 'ref' . time();
$paypal_type = new AnetAPI\PayPalType();
$paypal_type->setPayerID("JJLRRB29QC7RU");
$paypal_type->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
$paypal_type->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
$payment_type = new AnetAPI\PaymentType();
$payment_type->setPayPal($paypal_type);
//create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authOnlyContinueTransaction");
$transactionRequestType->setRefTransId("2241711631");
$transactionRequestType->setAmount(125.34);
$transactionRequestType->setPayment($payment_type);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$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 " RESULT CODE : " . $response->getResultCode() . "\n";
        echo " TRANS ID  : " . $tresponse->getTransId() . "\n";
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 (Paypal compatible merchant)
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$refId = 'ref' . time();
// Create the payment data for a paypal account
$payPalType = new AnetAPI\PayPalType();
$payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
$payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setPayPal($payPalType);
//create a auth-only transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authOnlyTransaction");
$transactionRequestType->setAmount(921);
$transactionRequestType->setPayment($paymentOne);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$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 && $response->getMessages()->getResultCode() == "Ok") {
        echo "Received response code: " . $tresponse->getResponseCode() . "\n";
        //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent\n";
        echo "Secure acceptance URL: " . $tresponse->getSecureAcceptance()->getSecureAcceptanceUrl() . "\n";
$request->setCustomerProfileId($customerProfileId);
$paymentprofile2 = new AnetAPI\CustomerPaymentProfileType();
$paymentprofile2->setCustomerType('business');
$paymentprofile2->setBillTo($billto);
$paymentprofile2->setPayment($paymentTwo);
$paymentprofiles2[] = $paymentprofile2;
$request->setPaymentProfile($paymentprofile2);
$controller = new AnetController\CreateCustomerPaymentProfileController($request);
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
if ($response != null && $response->getMessages()->getResultCode() == "Ok") {
    echo "CreateCustomerPaymentProfileRequest SUCCESS: PROFILE ID : " . $response->getCustomerPaymentProfileId() . "\n";
    $customerProfileId = $response->getCustomerPaymentProfileId();
} else {
    echo "CreateCustomerPaymentProfileRequest ERROR :  Invalid response\n";
}
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureTransaction");
$transactionRequestType->setAmount(100.5);
$transactionRequestType->setPayment($paymentprofile2->getPayment());
$transactionRequestType->setOrder($order);
$transactionRequestType->addToLineItems($lineitem);
$transactionRequestType->setTax($tax);
//$transactionRequestType->setPoNumber($ponumber);
//$transactionRequestType->setCustomer($customer);
$transactionRequestType->setBillTo($billto);
$transactionRequestType->setShipTo($shipto);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$request->setTransactionRequest($transactionRequestType);
$controller = new AnetController\CreateTransactionController($request);
示例#15
0
 $creditCard->setCardNumber("{$cc_info_array['number']}");
 $creditCard->setExpirationDate("{$cc_info_array['exp_yr']}-{$cc_info_array['exp_mo']}");
 //$creditCard->setCardCode("{$cc_info_array['cvv']}");
 $paymentOne = new AnetAPI\PaymentType();
 $paymentOne->setCreditCard($creditCard);
 // Bill To
 $billto = new AnetAPI\CustomerAddressType();
 $billto->setFirstName("{$cc_info_array['name_first']}");
 $billto->setLastName("{$cc_info_array['name_last']}");
 $billto->setAddress("{$cc_info_array['address1']} {$cc_info_array['address2']}");
 $billto->setCity("{$cc_info_array['city']}");
 $billto->setState("{$cc_info_array['state']}");
 $billto->setZip("{$cc_info_array['pos_code']}");
 $billto->setCountry("USA");
 //create a transaction
 $transactionRequestType = new AnetAPI\TransactionRequestType();
 $transactionRequestType->setTransactionType("authCaptureTransaction");
 $transactionRequestType->setAmount($payment_amount);
 $transactionRequestType->setPayment($paymentOne);
 $transactionRequestType->setBillTo($billto);
 $request = new AnetAPI\CreateTransactionRequest();
 $request->setMerchantAuthentication($merchantAuthentication);
 $request->setRefId($refId);
 $request->setTransactionRequest($transactionRequestType);
 $controller = new AnetController\CreateTransactionController($request);
 if ($anet_sandbox_flag === false) {
     $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION);
 } else {
     $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
 }
 // end elseif sandbox flag is on
示例#16
0
<?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");
echo "PayPal Get Details Transaction\n";
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$refId = 'ref' . time();
//create a transaction of type get details
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("getDetailsTransaction");
//replace following transaction ID with your transaction ID for which the details are required
$transactionRequestType->setRefTransId("2241687090");
//create a transaction request
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$request->setTransactionRequest($transactionRequestType);
$controller = new AnetController\CreateTransactionController($request);
//execute the api call to get transaction details
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
if ($response != null) {
    $tresponse = $response->getTransactionResponse();
    if ($tresponse != null) {
        if ($tresponse->getResponseCode() == "1") {
            //parse the shipping information from response
            $shipping_response = $tresponse->getShipTo();
 public function process()
 {
     $this->layout = 'ajax';
     //        $this->loadModel('PaidCustomer');
     //        $sql = "SELECT name, transactionkey ,card_no, exp_date FROM paid_customers ";
     //        $cardinfo = $this->PaidCustomer->query($sql);
     //        // Common setup for API credentials
     //        $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
     //        $merchantAuthentication->setName("95x9PuD6b2"); // testing mode
     //        //$merchantAuthentication->setName("42UHbr9Qa9B"); // live mode
     //        $merchantAuthentication->setTransactionKey("547z56Vcbs3Nz9R9");  // testing mode
     ////        $merchantAuthentication->setTransactionKey("6468X36RkrKGm3k6"); // live mode
     //        $refId = 'ref' . time();
     //
     //        // Create the payment data for a credit card
     //        $creditCard = new AnetAPI\CreditCardType();
     //        $creditCard->setCardNumber("4111111111111111"); // testing
     //        $creditCard->setExpirationDate("2038-12"); // testing
     //
     //      //  $creditCard->setCardNumber("4117733943147221"); // live
     //       // $creditCard->setExpirationDate("07-2019"); //live
     //        $paymentOne = new AnetAPI\PaymentType();
     //        $paymentOne->setCreditCard($creditCard);
     //
     //        // Order info
     //        $order = new AnetAPI\OrderType();
     //        $order->setInvoiceNumber("101");
     //        $order->setDescription("Golf Shirts");
     //
     //        // Line Item Info
     //        $lineitem = new AnetAPI\LineItemType();
     //        $lineitem->setItemId("Shirts");
     //        $lineitem->setName("item1");
     //        $lineitem->setDescription("golf shirt");
     //        $lineitem->setQuantity("1");
     //        $lineitem->setUnitPrice(1.00);
     //        $lineitem->setTaxable(false);
     //
     //        // Tax info
     ////        $tax = new AnetAPI\ExtendedAmountType();
     ////        $tax->setName("level 2 tax name");
     ////        $tax->setAmount(4.50);
     ////        $tax->setDescription("level 2 tax");
     //        // Customer info
     ////        $customer = new AnetAPI\CustomerDataType();
     ////        $customer->setId("15");
     ////        $customer->setEmail("*****@*****.**");
     //        // PO Number
     //        $ponumber = "15";
     //        //Ship To Info
     //        $shipto = new AnetAPI\NameAndAddressType();
     //        //$shipto->setFirstName("Bayles");
     //        // $shipto->setLastName("China");
     //        // $shipto->setCompany("Thyme for Tea");
     //        //  $shipto->setAddress("12 Main Street");
     //        // $shipto->setCity("Pecan Springs");
     //        //  $shipto->setState("TX");
     //        $shipto->setZip("11554");
     //        //  $shipto->setCountry("USA");
     //        // Bill To
     ////        $billto = new AnetAPI\CustomerAddressType();
     ////        $billto->setFirstName("Ellen");
     ////        $billto->setLastName("Johnson");
     ////        $billto->setCompany("Souveniropolis");
     ////        $billto->setAddress("14 Main Street");
     ////        $billto->setCity("Pecan Springs");
     ////        $billto->setState("TX");
     ////        $billto->setZip("44628");
     ////        $billto->setCountry("USA");
     //        //create a transaction
     //        $transactionRequestType = new AnetAPI\TransactionRequestType();
     //        $transactionRequestType->setTransactionType("authCaptureTransaction");
     //        $transactionRequestType->setAmount(1.00);
     ////        $transactionRequestType->setPayment($paymentOne);
     ////        $transactionRequestType->setOrder($order);
     ////        $transactionRequestType->addToLineItems($lineitem);
     ////        $transactionRequestType->setTax($tax);
     ////        $transactionRequestType->setPoNumber($ponumber);
     ////        $transactionRequestType->setCustomer($customer);
     ////        $transactionRequestType->setBillTo($billto);
     ////        $transactionRequestType->setShipTo($shipto);
     //
     //        $request = new AnetAPI\CreateTransactionRequest();
     //        $request->setMerchantAuthentication($merchantAuthentication);
     //        $request->setRefId($refId);
     //        $request->setTransactionRequest($transactionRequestType);
     //        $controller = new AnetController\CreateTransactionController($request);
     //        $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); //Testing
     //       // $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION); // live
     //
     //        pr($response);
     //        exit;
     //
     //        $msg = '';
     //        if ($response != null) {
     //            $tresponse = $response->getTransactionResponse();
     //
     //            if (($tresponse != null) && ($tresponse->getResponseCode() == "1")) {
     //                $msg = "Transaction Successful ! : " . "<br/>";
     //                $msg .= "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "<br/>";
     //                $msg .= "Charge Credit Card TRANS ID  : " . $tresponse->getTransId() . "<br/>";
     //            } else {
     //                $msg = "Charge Credit Card ERROR :  Invalid response\n";
     //            }
     //        } else {
     //            $msg = "Charge Credit card Null response returned";
     //        }
     // Common setup for API credentials
     $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
     // $merchantAuthentication->setName("95x9PuD6b2"); // testing mode
     $merchantAuthentication->setName("42UHbr9Qa9B");
     // live mode
     //$merchantAuthentication->setTransactionKey("547z56Vcbs3Nz9R9");  // testing mode
     $merchantAuthentication->setTransactionKey("6468X36RkrKGm3k6");
     // live mode
     $refId = 'ref' . time();
     // Create the payment data for a credit card
     $creditCard = new AnetAPI\CreditCardType();
     $this->loadModel('PaidCustomer');
     $this->loadModel('Transaction');
     $pcustomers = $this->PaidCustomer->find('all');
     //        pr($pcustomers);
     //        exit;
     $msg = '<ul>';
     foreach ($pcustomers as $pcustomer) {
         $pc = $pcustomer['PaidCustomer'];
         $creditCard->setCardNumber($pc['card_no']);
         // testing
         $creditCard->setExpirationDate($pc['exp_date']);
         // testing
         //     $creditCard->setCardNumber("4117733943147221"); // live
         //  $creditCard->setExpirationDate("07-2019"); //live
         $paymentOne = new AnetAPI\PaymentType();
         $paymentOne->setCreditCard($creditCard);
         $transactionData['paid_customer_id'] = $pc['id'];
         //    Bill To
         $billto = new AnetAPI\CustomerAddressType();
         $billto->setFirstName($pc['fname']);
         $billto->setLastName($pc['lname']);
         // $billto->setCompany("Souveniropolis");
         //$billto->setAddress("14 Main Street");
         //$billto->setCity("Pecan Springs");
         //$billto->setState("TX");
         $billto->setZip($pc['zip_code']);
         //$billto->setCountry("USA");
         // Create a transaction
         $transactionRequestType = new AnetAPI\TransactionRequestType();
         $transactionRequestType->setTransactionType("authCaptureTransaction");
         $transactionRequestType->setAmount($pc['amount']);
         $transactionRequestType->setPayment($paymentOne);
         $request = new AnetAPI\CreateTransactionRequest();
         $request->setMerchantAuthentication($merchantAuthentication);
         $request->setRefId($refId);
         $request->setTransactionRequest($transactionRequestType);
         $controller = new AnetController\CreateTransactionController($request);
         //   $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); //Testing
         $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION);
         // live
         //  pr($response); exit;
         $transactionData['error_msg'] = '';
         $transactionData['status'] = '';
         $transactionData['trx_id'] = '';
         $transactionData['auth_code'] = '';
         if ($response != null) {
             $tresponse = $response->getTransactionResponse();
             // pr($tresponse ); exit;
             if ($tresponse != null && $tresponse->getResponseCode() == "1") {
                 $transactionData['status'] = 'success';
                 $transactionData['trx_id'] = $tresponse->getTransId();
                 $transactionData['auth_code'] = $tresponse->getAuthCode();
                 $msg .= '<li> Transaction for ' . $pc['fname'] . ' ' . $pc['lname'] . ' successfull</li>';
             } else {
                 $transactionData['status'] = 'error';
                 $transactionData['error_msg'] = "Charge Credit Card ERROR :  Invalid response";
                 $msg .= '<li> Transaction for ' . $pc['fname'] . ' ' . $pc['lname'] . ' failed for Charge Credit Card ERROR</li>';
             }
         } else {
             $transactionData['status'] = 'error';
             $transactionData['error_msg'] = "Charge Credit card Null response returned";
             $msg .= '<li> Transaction for ' . $pc['fname'] . ' ' . $pc['lname'] . ' failed for Charge Credit card Null response</li>';
         }
         $this->Transaction->create();
         $this->Transaction->save($transactionData);
     }
     $msg .= '</ul>';
     $this->set(compact('msg'));
 }
$lineitem->setDescription("golf shirt");
$lineitem->setQuantity("1");
$lineitem->setUnitPrice(20.95);
$lineitem->setTaxable(false);
// Bill To
$billto = new AnetAPI\CustomerAddressType();
$billto->setFirstName("Ellen");
$billto->setLastName("Johnson");
$billto->setCompany("Souveniropolis");
$billto->setAddress("14 Main Street");
$billto->setCity("Pecan Springs");
$billto->setState("TX");
$billto->setZip("44628");
$billto->setCountry("USA");
//create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureTransaction");
$transactionRequestType->setAmount(151.51);
$transactionRequestType->setPayment($paymentOne);
$transactionRequestType->setOrder($order);
$transactionRequestType->addToLineItems($lineitem);
$transactionRequestType->setBillTo($billto);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$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") {
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("556KThWQ6vf2");
$merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq");
$refId = 'ref' . time();
// Create the payment data for a Bank Account
$bankAccount = new AnetAPI\BankAccountType();
//$bankAccount->setAccountType('CHECKING');
$bankAccount->setEcheckType('WEB');
$bankAccount->setRoutingNumber('121042882');
$bankAccount->setAccountNumber('123456789123');
$bankAccount->setNameOnAccount('Jane Doe');
$bankAccount->setBankName('Bank of the Earth');
$paymentBank = new AnetAPI\PaymentType();
$paymentBank->setBankAccount($bankAccount);
//create a debit card Bank transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureTransaction");
$transactionRequestType->setAmount(250.75);
$transactionRequestType->setPayment($paymentBank);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$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 "Debit Bank Account APPROVED  :" . "\n";
        echo " Debit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n";
        echo " Debit Banlk Account TRANS ID  : " . $tresponse->getTransId() . "\n";
示例#20
0
// Common setup for API credentials (Paypal compatible merchant)
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
// $merchantAuthentication->setName("mbld_api_-g9yGXH6");
// $merchantAuthentication->setTransactionKey("8b948Sk5Tk5jBB6w");
$merchantAuthentication->setName("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$refId = 'ref' . time();
$refTransId = "2241762126";
// Create the payment data for a paypal account
$payPalType = new AnetAPI\PayPalType();
$payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
$payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setPayPal($payPalType);
//create a refund transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("refundTransaction");
$transactionRequestType->setAmount(181);
$transactionRequestType->setPayment($paymentOne);
///refTransId of successfully settled transaction
$transactionRequestType->setRefTransId($refTransId);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$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 && $response->getMessages()->getResultCode() == "Ok") {
        echo "Credit SUCCESS AUTH CODE : " . $tresponse->getAuthCode() . "\n";
 protected function processPayment(Application $app, $cardInfo, $amount, $user, $students, $bill_address)
 {
     define("AUTHORIZENET_LOG_FILE", "../authorize.net.log");
     // Common setup for API credentials
     $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
     $merchantAuthentication->setName($app['authrize.net.name']);
     $merchantAuthentication->setTransactionKey($app['authrize.net.key']);
     $refId = 'ref' . time();
     // Create the payment data for a credit card
     $creditCard = new AnetAPI\CreditCardType();
     $creditCard->setCardNumber($cardInfo->card_num);
     $creditCard->setExpirationDate($cardInfo->exp);
     $creditCard->setCardCode($cardInfo->code);
     $paymentOne = new AnetAPI\PaymentType();
     $paymentOne->setCreditCard($creditCard);
     // Order info
     // $order = new AnetAPI\OrderType();
     // $order->setInvoiceNumber($order->getInvoiceNumber());
     // $order->setDescription('Payment for '.implode(' ', $students));
     // Line Item Info
     // $lineitem = new AnetAPI\LineItemType();
     // $lineitem->setItemId("Shirts");
     // $lineitem->setName("item1");
     // $lineitem->setDescription("golf shirt");
     // $lineitem->setQuantity("1");
     // $lineitem->setUnitPrice(20.95);
     // $lineitem->setTaxable("Y");
     // Tax info
     // $tax =  new AnetAPI\ExtendedAmountType();
     // $tax->setName("level 2 tax name");
     // $tax->setAmount(4.50);
     // $tax->setDescription("level 2 tax");
     // Customer info
     $customer = new AnetAPI\CustomerDataType();
     $customer->setId($user->getUserId());
     $customer->setEmail($user->getEmail());
     // PO Number
     // $ponumber = "15";
     //Ship To Info
     // $shipto = new AnetAPI\NameAndAddressType();
     // $shipto->setFirstName("Bayles");
     // $shipto->setLastName("China");
     // $shipto->setCompany("Thyme for Tea");
     // $shipto->setAddress("12 Main Street");
     // $shipto->setCity("Pecan Springs");
     // $shipto->setState("TX");
     // $shipto->setZip("44628");
     // $shipto->setCountry("USA");
     // Bill To
     $billto = new AnetAPI\CustomerAddressType();
     $billto->setFirstName($user->getFirstName());
     $billto->setLastName($user->getLastName());
     $billto->setCompany("");
     $billto->setAddress($bill_address->getStreet());
     $billto->setCity($bill_address->getCity());
     $billto->setState($bill_address->getState());
     $billto->setZip($bill_address->getZip());
     $billto->setCountry("USA");
     //create a transaction
     $transactionRequestType = new AnetAPI\TransactionRequestType();
     $transactionRequestType->setTransactionType("authCaptureTransaction");
     $transactionRequestType->setAmount($amount);
     $transactionRequestType->setPayment($paymentOne);
     // $transactionRequestType->setOrder($order);
     // $transactionRequestType->addToLineItems($lineitem);
     // $transactionRequestType->setTax($tax);
     // $transactionRequestType->setPoNumber($ponumber);
     $transactionRequestType->setCustomer($customer);
     $transactionRequestType->setBillTo($billto);
     // $transactionRequestType->setShipTo($shipto);
     $request = new AnetAPI\CreateTransactionRequest();
     $request->setMerchantAuthentication($merchantAuthentication);
     $request->setRefId($refId);
     $request->setTransactionRequest($transactionRequestType);
     $controller = new AnetController\CreateTransactionController($request);
     $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
     if (null != $response) {
         $tresponse = $response->getTransactionResponse();
         if ($tresponse != null && $tresponse->getResponseCode() == "1") {
             // return array(
             // "AUTH_CODE" => $tresponse->getAuthCode(),
             // "TRANS_ID" => $tresponse->getTransId()
             // );
             return array('approved' => true, 'data' => $tresponse);
         } else {
             return array('approved' => false, 'data' => $tresponse);
         }
     } else {
         return array('approved' => false, 'data' => null);
     }
 }
 public function individual_transaction($id = null)
 {
     $this->layout = 'ajax';
     // Common setup for API credentials
     $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
     $merchantAuthentication->setName("95x9PuD6b2");
     // testing mode
     //$merchantAuthentication->setName("42UHbr9Qa9B"); // live mode
     $merchantAuthentication->setTransactionKey("547z56Vcbs3Nz9R9");
     // testing mode
     //$merchantAuthentication->setTransactionKey("6468X36RkrKGm3k6"); // live mode
     $refId = 'ref' . time();
     // Create the payment data for a credit card
     $creditCard = new AnetAPI\CreditCardType();
     $this->loadModel('PaidCustomer');
     $this->loadModel('Transaction');
     $pcustomers = $this->PaidCustomer->find('first', array('conditions' => array('PaidCustomer.id' => $id)));
     //pr($pcustomers);
     //exit;
     $msg = '<ul>';
     //foreach ($pcustomers as $pcustomer):
     $pc = $pcustomers['PaidCustomer'];
     // pr($pc); exit;
     $creditCard->setCardNumber($pc['card_no']);
     // testing
     $creditCard->setExpirationDate($pc['exp_date']);
     // testing
     //     $creditCard->setCardNumber("4117733943147221"); // live
     //  $creditCard->setExpirationDate("07-2019"); //live
     $paymentOne = new AnetAPI\PaymentType();
     $paymentOne->setCreditCard($creditCard);
     $transactionData['paid_customer_id'] = $pc['id'];
     //    Bill To
     $billto = new AnetAPI\CustomerAddressType();
     $billto->setFirstName($pc['fname']);
     $billto->setLastName($pc['lname']);
     // $billto->setCompany("Souveniropolis");
     //$billto->setAddress("14 Main Street");
     //$billto->setCity("Pecan Springs");
     //$billto->setState("TX");
     $billto->setZip($pc['zip_code']);
     //$billto->setCountry("USA");
     // Create a transaction
     $transactionRequestType = new AnetAPI\TransactionRequestType();
     $transactionRequestType->setTransactionType("authCaptureTransaction");
     $transactionRequestType->setAmount($pc['amount']);
     $transactionRequestType->setPayment($paymentOne);
     $request = new AnetAPI\CreateTransactionRequest();
     $request->setMerchantAuthentication($merchantAuthentication);
     $request->setRefId($refId);
     $request->setTransactionRequest($transactionRequestType);
     $controller = new AnetController\CreateTransactionController($request);
     $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
     //Testing
     //$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION); // live
     //  pr($response); exit;
     $transactionData['error_msg'] = '';
     $transactionData['status'] = '';
     $transactionData['trx_id'] = '';
     $transactionData['auth_code'] = '';
     if ($response != null) {
         $tresponse = $response->getTransactionResponse();
         // pr($tresponse ); exit;
         if ($tresponse != null && $tresponse->getResponseCode() == "1") {
             $transactionData['status'] = 'success';
             $transactionData['trx_id'] = $tresponse->getTransId();
             $transactionData['auth_code'] = $tresponse->getAuthCode();
             $msg .= '<li> Transaction for ' . $pc['fname'] . ' ' . $pc['lname'] . ' successfull</li>';
         } else {
             $transactionData['status'] = 'error';
             $transactionData['error_msg'] = "Charge Credit Card ERROR :  Invalid response";
             $msg .= '<li> Transaction for ' . $pc['fname'] . ' ' . $pc['lname'] . ' failed for Charge Credit Card ERROR</li>';
         }
     } else {
         $transactionData['status'] = 'error';
         $transactionData['error_msg'] = "Charge Credit card Null response returned";
         $msg .= '<li> Transaction for ' . $pc['fname'] . ' ' . $pc['lname'] . ' failed for Charge Credit card Null response</li>';
     }
     $this->Transaction->create();
     $this->Transaction->save($transactionData);
     // endforeach;
     //$msg .='</ul>';
     $msg1 = '<div class="alert alert-success">
     <button type="button" class="close" data-dismiss="alert">&times;</button>
     <strong>' . $msg . '</strong>
 </div>';
     $this->Session->setFlash($msg1);
     return $this->redirect($this->referer());
     //$this->set(compact('msg'));
 }
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("556KThWQ6vf2");
$merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq");
$refId = "123456";
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("4111111111111111");
$creditCard->setExpirationDate("2038-12");
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("captureOnlyTransaction");
$transactionRequestType->setAmount(5.0);
$transactionRequestType->setPayment($paymentOne);
//Auth code of the previously authorized  amount
$transactionRequestType->setAuthCode("ROHNFQ");
$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 "Successful." . "\n";
        echo "Capture funds authorized through another channel TRANS ID  : " . $tresponse->getTransId() . "\n";
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("556KThWQ6vf2");
$merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq");
$refId = 'ref' . time();
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("4111111111111111");
$creditCard->setExpirationDate("2038-12");
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
//create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("voidTransaction");
$transactionRequestType->setPayment($paymentOne);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$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 "Void transaction SUCCESS AUTH CODE: " . $tresponse->getAuthCode() . "\n";
        echo "Void transaction SUCCESS TRANS ID  : " . $tresponse->getTransId() . "\n";
    } else {
        echo "void transaction ERROR : " . $tresponse->getResponseCode() . "\n";
示例#25
0
// obtained from a system other than authorize.net for example a
// verbal authorization over the telephone
//====================================================================
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("4111111111111111");
$creditCard->setExpirationDate("2038-12");
//$creditCard->setCardCode("999");
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
// Order info
$order = new AnetAPI\OrderType();
$order->setInvoiceNumber("INV-12345");
$order->setDescription("Product Description");
//create a captureOnly transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("captureOnlyTransaction");
$transactionRequestType->setAmount(151);
// This is the Auth Code from another payment channel
$transactionRequestType->setAuthCode("ABC123");
$transactionRequestType->setPayment($paymentOne);
$transactionRequestType->setOrder($order);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$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") {
$merchantAuthentication->setName("556KThWQ6vf2");
$merchantAuthentication->setTransactionKey("9ac2932kQ7kN2Wzq");
$refId = 'ref' . time();
// Create the payment data for a Bank Account
$bankAccount = new AnetAPI\BankAccountType();
$bankAccount->setRoutingNumber('125000024');
$bankAccount->setAccountNumber('12345678');
$bankAccount->setNameOnAccount('John Doe');
$paymentBank = new AnetAPI\PaymentType();
$paymentBank->setBankAccount($bankAccount);
// Order info
$order = new AnetAPI\OrderType();
$order->setInvoiceNumber("101");
$order->setDescription("Golf Shirts");
//create a debit card Bank transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("refundTransaction");
$transactionRequestType->setAmount(250.75);
$transactionRequestType->setPayment($paymentBank);
$transactionRequestType->setOrder($order);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$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 "Credit Bank Account APPROVED  :" . "\n";
        echo "Credit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n";
示例#27
0
$shipto->setCity("Pecan Springs");
$shipto->setState("TX");
$shipto->setZip("44628");
$shipto->setCountry("USA");
// Bill To
$billto = new AnetAPI\CustomerAddressType();
$billto->setFirstName("Ellen");
$billto->setLastName("Johnson");
$billto->setCompany("Souveniropolis");
$billto->setAddress("14 Main Street");
$billto->setCity("Pecan Springs");
$billto->setState("TX");
$billto->setZip("44628");
$billto->setCountry("USA");
//create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureTransaction");
$transactionRequestType->setAmount(151.51);
$transactionRequestType->setPayment($paymentOne);
$transactionRequestType->setOrder($order);
$transactionRequestType->addToLineItems($lineitem);
$transactionRequestType->setTax($tax);
$transactionRequestType->setPoNumber($ponumber);
$transactionRequestType->setCustomer($customer);
$transactionRequestType->setBillTo($billto);
$transactionRequestType->setShipTo($shipto);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$request->setTransactionRequest($transactionRequestType);
$controller = new AnetController\CreateTransactionController($request);
示例#28
0
 function makeRefund2($amount, $card_last_four, $exp_date, $trans_id)
 {
     $merchantAuthentication = $this->sandbox_authorize();
     $refId = 'ref' . time();
     $date = $this->prepareExpirationDate($exp_date);
     /*
     * 
      $transaction = new AuthorizeNetTransaction;
      $transaction->amount = $amount;
      $transaction->customerProfileId = $customerProfileId;
      $transaction->customerPaymentProfileId = $paymentProfileId;
      $transaction->transId = $transid; // original transaction ID
     
      $response = $request->createCustomerProfileTransaction("Refund", $transaction);
      $transactionResponse = $response->getTransactionResponse();
     
      $transactionId = $transactionResponse->transaction_id;
     * 
     */
     // Create the payment data for a credit card
     $creditCard = new AnetAPI\CreditCardType();
     //$creditCard->setCardNumber(base64_decode($card_last_four));
     $creditCard->setCardNumber($card_last_four);
     $creditCard->setExpirationDate($date);
     $paymentOne = new AnetAPI\PaymentType();
     $paymentOne->setCreditCard($creditCard);
     //create a transaction
     $transactionRequest = new AnetAPI\TransactionRequestType();
     $transactionRequest->setTransactionType("refundTransaction");
     $transactionRequest->setAmount($amount);
     $transactionRequest->setRefTransId($trans_id);
     $transactionRequest->setPayment($paymentOne);
     $request = new AnetAPI\CreateTransactionRequest();
     $request->setMerchantAuthentication($merchantAuthentication);
     $request->setRefId($refId);
     $request->setTransactionRequest($transactionRequest);
     $controller = new AnetController\CreateTransactionController($request);
     $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
     //$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION);
     if ($response != null) {
         $tresponse = $response->getTransactionResponse();
         echo "Response: <pre>";
         print_r($tresponse);
         echo "</pre>";
         if ($tresponse != null && $tresponse->getResponseCode() == "1") {
             //echo "it is ok ....";
             return TRUE;
         } else {
             $this->save_log($tresponse, $post_order);
             return FALSE;
         }
     } else {
         //echo "Null resposnse .. ...";
         return FALSE;
     }
     return $response;
 }
示例#29
0
 /**
  * Make a one-time charge using the payments processor
  * @method charge
  * @param {double} $amount specify the amount (optional cents after the decimal point)
  * @param {string} [$currency='USD'] set the currency, which will affect the amount
  * @param {array} [$options=array()] Any additional options
  * @param {string} [$options.description=null] description of the charge, to be sent to customer
  * @param {string} [$options.metadata=null] any additional metadata to store with the charge
  * @param {string} [$options.subscription=null] if this charge is related to a subscription stream
  * @param {string} [$options.subscription.publisherId]
  * @param {string} [$options.subscription.streamName]
  * @throws Assets_Exception_DuplicateTransaction
  * @throws Assets_Exception_HeldForReview
  * @throws Assets_Exception_ChargeFailed
  * @return {string} The customerId of the Assets_Customer that was successfully charged
  */
 function charge($amount, $currency = 'USD', $options = array())
 {
     $customerId = $this->customerId();
     $paymentProfileId = $this->paymentProfileId($customerId);
     $options = array_merge($this->options, $options);
     // Common setup for API credentials
     $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
     $merchantAuthentication->setName($options['authname']);
     $merchantAuthentication->setTransactionKey($options['authkey']);
     $refId = 'ref' . time();
     $paymentProfile = new AnetAPI\PaymentProfileType();
     $paymentProfile->setPaymentProfileId($paymentProfileId);
     $profileToCharge = new AnetAPI\CustomerProfilePaymentType();
     $profileToCharge->setCustomerProfileId($customerId);
     $profileToCharge->setPaymentProfile($paymentProfile);
     $transactionRequestType = new AnetAPI\TransactionRequestType();
     $transactionRequestType->setTransactionType("authCaptureTransaction");
     $transactionRequestType->setAmount($amount);
     $transactionRequestType->setProfile($profileToCharge);
     $request = new AnetAPI\CreateTransactionRequest();
     $request->setMerchantAuthentication($merchantAuthentication);
     $request->setRefId($refId);
     $request->setTransactionRequest($transactionRequestType);
     $controller = new AnetController\CreateTransactionController($request);
     $response = $controller->executeWithApiResponse($options['server']);
     if (!isset($response)) {
         throw new Assets_Exception_InvalidResponse(array('response' => 'empty response'));
     }
     $tresponse = $response->getTransactionResponse();
     if (!isset($tresponse)) {
         throw new Assets_Exception_ChargeFailed();
     }
     switch ($tresponse->getResponseCode()) {
         case '1':
             return $customerId;
         case '3':
             throw new Assets_Exception_DuplicateTransaction();
         case '4':
             throw new Assets_Exception_HeldForReview();
         default:
             throw new Assets_Exception_ChargeFailed();
     }
 }
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
define("AUTHORIZENET_LOG_FILE", "phplog");
// Put the values of the Payer ID and Ref. Transaction ID generated in Authorization and Capture
$payerID = "6ZSCSYG33VP8Q";
$refTransId = "2241708986";
// Common setup for API credentials (with PayPal compatible merchant credentials)
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$payPalType = new AnetAPI\PayPalType();
$payPalType->setPayerID($payerID);
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setPayPal($payPalType);
// Create an authorize and capture continue transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureContinueTransaction");
$transactionRequestType->setPayment($paymentOne);
$transactionRequestType->setRefTransId($refTransId);
$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) {
        echo "Transaction Response...\n";
        echo "Received response code: " . $tresponse->getResponseCode() . "\n";
        //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent
        echo "Secure acceptance URL: " . $tresponse->getSecureAcceptance()->getSecureAcceptanceUrl() . "\n";