Giter Site home page Giter Site logo

sdk-php's Introduction

Authorize.Net PHP SDK

To use the SDK in your app, create a composer.json file with the following require section and run composer update

"require": {
    "php": ">=5.2.0",
    "ext-curl": "*",
    "authorizenet/authorizenet": "1.8.0"
}

##Requirements: - cURL PHP Extension - PHP 5.2+ - An Authorize.Net Merchant Account or Sandbox Account. You can get a free sandbox account at http://developer.authorize.net/sandbox/

##Usage Examples: See below for basic usage examples. View the tests/ folder for more examples of each API.

###AuthorizeNetAIM.php Quick Usage Example: amount = "5.99"; $sale->card_num = '6011000000000012'; $sale->exp_date = '04/15'; $response = $sale->authorizeAndCapture(); if ($response->approved) { $transaction_id = $response->transaction_id; } ?>

###AuthorizeNetAIM.php Advanced Usage Example: <?php require_once 'anet_php_sdk/AuthorizeNet.php'; define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN"); define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY"); define("AUTHORIZENET_SANDBOX", true); $auth = new AuthorizeNetAIM; $auth->amount = "45.00";

// Use eCheck:
$auth->setECheck(
    '121042882',
    '123456789123',
    'CHECKING',
    'Bank of Earth',
    'Jane Doe',
    'WEB'
);

// Set multiple line items:
$auth->addLineItem('item1', 'Golf tees', 'Blue tees', '2', '5.00', 'N');
$auth->addLineItem('item2', 'Golf shirt', 'XL', '1', '40.00', 'N');

// Set Invoice Number:
$auth->invoice_num = time();

// Set a Merchant Defined Field:
$auth->setCustomField("entrance_source", "Search Engine");

// Authorize Only:
$response  = $auth->authorizeOnly();

if ($response->approved) {
    $auth_code = $response->transaction_id;
    
    // Now capture:
    $capture = new AuthorizeNetAIM;
    $capture_response = $capture->priorAuthCapture($auth_code);
    
    // Now void:
    $void = new AuthorizeNetAIM;
    $void_response = $void->void($capture_response->transaction_id);
}
?>

###AuthorizeNetARB.php Usage Example: <?php require_once 'anet_php_sdk/AuthorizeNet.php'; define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN"); define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY"); $subscription = new AuthorizeNet_Subscription; $subscription->name = "PHP Monthly Magazine"; $subscription->intervalLength = "1"; $subscription->intervalUnit = "months"; $subscription->startDate = "2011-03-12"; $subscription->totalOccurrences = "12"; $subscription->amount = "12.99"); $subscription->creditCardCardNumber = "6011000000000012"; $subscription->creditCardExpirationDate= "2018-10"; $subscription->creditCardCardCode = "123"; $subscription->billToFirstName = "Rasmus"; $subscription->billToLastName = "Doe";

// Create the subscription.
$request = new AuthorizeNetARB;
$response = $request->createSubscription($subscription);
$subscription_id = $response->getSubscriptionId();
?>

###AuthorizeNetCIM.php Usage Example: description = "Description of customer"; $customerProfile->merchantCustomerId= time(); $customerProfile->email = "[email protected]"; $response = $request->createCustomerProfile($customerProfile); if ($response->isOk()) { $customerProfileId = $response->getCustomerProfileId(); } ?>

###AuthorizeNetSIM.php Usage Example: isAuthorizeNet()) { $transactionId = $message->transaction_id; } ?>

###AuthorizeNetDPM.php Usage Example:

###AuthorizeNetCP.php Usage Example: amount = '59.99'; $sale->device_type = '4'; $sale->setTrack1Data('%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?'); $response = $sale->authorizeAndCapture(); $trans_id = $response->transaction_id; ?>

###AuthorizeNetTD.php Usage Example: getTransactionDetails("12345"); echo $response->xml->transaction->transactionStatus; ?>

##Test Credit Card Numbers: - Set the expiration date to anytime in the future. - American Express Test Card=> 370000000000002 - Discover Test Card => 6011000000000012 - Visa Test Card => 4007000000027 - Second Visa Test Card => 4012888818888 - JCB => 3088000000000017 - Diners Club/ Carte Blanche=> 38000000000006

##PHPDoc: To autogenerate PHPDocs run: phpdoc -t phpdocs/ -f AuthorizeNet.php -d lib

sdk-php's People

Contributors

ncpga avatar brianmc avatar trevorw avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.