PHP code example of ramzyvirani / yii2-authorizenet
1. Go to this page and download the library: Download ramzyvirani/yii2-authorizenet library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ramzyvirani / yii2-authorizenet example snippets
use AuthorizeNetAIM;
define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
define("AUTHORIZENET_SANDBOX", true);
$sale = new AuthorizeNetAIM;
$sale->amount = "5.99";
$sale->card_num = '4111111111111111';
$sale->exp_date = '0418';
$response = $sale->authorizeAndCapture();
if ($response->approved) {
echo "Success! Transaction ID:" . $response->transaction_id;
} else {
echo "ERROR:" . $response->error_message;
}
php composer.phar