dev-master
9999999-dev http://github.com/speckcommerce/SpeckAuthnetA generic module for adding Authorize.net support to a ZF2 application.
The Requires
- php >=5.3.3
- zendframework/zendframework 2.*
zf2
A generic module for adding Authorize.net support to a ZF2 application.
A generic module for adding Authorize.net Payments support to a ZF2 application., (*1)
SpeckAuthnet is a module that can be utilized outside of Speck Commerce to accept payments via the Authorize.net payment gateway. This module currently supports Authorize.net AIM API Operations., (*2)
To get started visit the Authorize.net Development Center, (*3)
To integrate with this module you will want to sign up for an account on Authorize.net. See the developer website for instructions., (*4)
This module currently supports the following AIM calls with API version 3.1: * AUTH_CAPTURE and AUTH_ONLY * CREDIT * VOID * ECHECK * PRIOR_AUTH_CAPTURE * CAPTURE_ONLY, (*5)
The dependencies for SpeckCommerce are set up as Git submodules so you should not hav, (*6)
Join us on the Freenode IRC network: #speckcommerce. Our numbers are few right now, but we're a dedicated small group working on this project full time., (*7)
Move the module.config.php.dist to module.config.php and replace the following values with your own., (*8)
sandbox
or live
SpeckAuth API Name: SpeckAuthnet\Client
, (*9)
The SpeckAuthnet module works off a single Client. You will utilize this client to access the API's and make your calls to the Authnet endpoints. The Client provides a fluent interface allowing you to chain method calls., (*10)
//start by getting an instance of the client, in this example I will be leveraging the ServiceManager. $client = $sm->get('SpeckAuthnet\Client');
There are 3 ways to interact with the APIs via the client.
* use Client::setData($data)
to set a preconfigured array of key/value pairs on the API. The keys are the same as the fields in the Authorize.net AIM documentation minus the x_
* proxy calls to the API via the client
* act on the API itself calling Client::getApi()
, (*11)
SpeckAuthnet API Name: Aim\CreditCard
, (*12)
By default the authorization type of the CreditCard API is AUTH_ONLY
, this can also be configured to be an AUTH_CAPTURE
call to Authorize.net. The SpeckAuthnet module contains support for all available fields, for a complete list you can look at the unit tests included with the module or consult the documentation available on the Authorize.net developer website., (*13)
$paymentInfo = array( 'amount' => '20.00', 'card_num' => '4111111111111111', 'exp_date' => '122012', 'address' => '2065 nestall rd', 'city' => 'laguna beach', 'state' => 'california', 'zip' => '92656', 'country' => 'US', 'first_name' => 'steve', 'last_name' => 'rizzo' ); //Authorize Only $response = $client->api('Aim\CreditCard') ->setData($paymentInfo) ->send(); //Authorize Capture $response = $client->api('Aim\CreditCard') ->setData($paymentInfo) ->setType('AUTH_CAPTURE') ->send(); echo $response->isApproved();
SpeckAuthnet API Name Aim\PriorAuthCapture
, (*14)
Calling AUTH_ONLY
and PRIOR_AUTH_CAPTURE
represent a single complete transaction. When you are ready to capture an authorized only transaction you will utilize this API call. In addition this API supports splitting captures across multiple authorization requests: @see split tender in the AIM API documentation for details., (*15)
$response = $client->api('Aim\PriorAuthCapture') ->setAmount($amountToCapture) ->setTransactionId($transactionId) ->send(); echo $response->isSucces();
SpeckAuthnet API Name: Aim\ECheck
, (*16)
Process check tranasctions with this API., (*17)
NOTE: this requires additional set up within Authorize.net., (*18)
$response = $client->api('Aim\ECheck') ->setAmount('20.00') ->setBankAbaCode('160000000001') ->setBankAcctNum('1234567890') ->setBankAcctType('CHECKING') ->setBankName('Bank of America') ->send(); echo $response->isApproved();
SpeckAuthnet API Name: Aim\Void
, (*19)
In order to void a transaction you will need the transaction id returned from the original authorization., (*20)
// $response = $client->api('Aim\Void') ->setTransactionid($transactionId) ->send(); echo $response->isSuccess();
SpeckAuthnet API Name: Aim\Credit
, (*21)
Credits cannot be applied to Authorization-Only transactions. You can use the full card number, a masked last 4 digit number or simply a last 4 digit number (4111111111111111, XXXX4111, 4111)., (*22)
NOTE: A credit can only be applied to a settled transaction unless you are doing an unlinked credit., (*23)
NOTE: The default credit method is CC
, this will automatically change to ECHECK
if bankAbaCode or bankAcctNum is set, likewise you can change the method by calling setMethod($method);
, (*24)
NOTE: Unlinked Credits must exclude the transaction id and provide a full credit card number and expiration date., (*25)
$response = $client->api('Aim\Credit') ->setCardNum($accountNum) ->transactionId($transactionId) ->send(); echo $response->isSuccess();
A generic module for adding Authorize.net support to a ZF2 application.
zf2