@@ -13,31 +13,45 @@ to the results of the transaction.
1313Autoloading
1414-----------------
1515
16+ ``` PHP
1617require 'vendor/autoload.php';
18+ ```
1719
1820Setting Merchant Credentials
1921----------------------------
2022The easiest way to set credentials is to define constants which the SDK uses:
23+
24+ ``` PHP
2125define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
2226define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
27+ ```
2328
2429You can also set credentials manually per request like so:
2530
31+ ``` PHP
2632$sale = new AuthorizeNetAIM("YOUR_API_LOGIN_ID","YOUR_TRANSACTION_KEY");
27-
33+ ```
2834
2935Setting the Transaction Post Location
3036-------------------------------------
3137
3238To post transactions to the live Authorize.Net gateway:
39+
40+ ``` PHP
3341define("AUTHORIZENET_SANDBOX", false);
42+ ```
3443
3544To post transactions to the Authorize.Net test server:
45+
46+ ``` PHP
3647define("AUTHORIZENET_SANDBOX", true);
48+ ```
3749
3850You can also set the location manually per request:
39- $sale->setSandbox(false);
4051
52+ ``` PHP
53+ $sale->setSandbox(false);
54+ ```
4155
4256Setting Fields
4357--------------
@@ -47,17 +61,22 @@ allows you to set these fields in a few different ways depending on your
4761preference.
4862
4963Note: to make things easier on the developer, the "x_ " prefix attached to each
50- field in the AIM API has been removed. Thus, instead of setting $sale->x_card_num,
51- set $sale->card_num instead.
64+ field in the AIM API has been removed. Thus, instead of setting ` $sale->x_card_num ` ,
65+ set ` $sale->card_num ` instead.
5266
53671.) By Setting Fields Directly:
68+
69+ ``` PHP
5470$sale = new AuthorizeNetAIM;
5571$sale->amount = "1999.99";
5672$sale->card_num = '6011000000000012';
5773$sale->exp_date = '04/15';
5874$response = $sale->authorizeAndCapture();
75+ ```
5976
60772.) By Setting Multiple Fields at Once:
78+
79+ ``` PHP
6180$sale = new AuthorizeNetAIM;
6281$sale->setFields(
6382 array(
@@ -66,12 +85,15 @@ $sale->setFields(
6685 'exp_date' => '0415'
6786 )
6887);
88+ ```
6989
70903.) By Setting Special Items
7191
7292To add line items or set custom fields use the respective functions:
7393
7494Line Items:
95+
96+ ``` PHP
7597$sale->addLineItem(
7698 'item1', // Item Id
7799 'Golf tees', // Item Name
@@ -80,14 +102,19 @@ $sale->addLineItem(
80102 '5.00', // Item Unit Price
81103 'N' // Item taxable
82104 );
105+ ```
83106
84107Custom Fields:
108+
109+ ``` PHP
85110$sale->setCustomField("coupon_code", "SAVE2011");
111+ ```
86112
871134.) By Passing in Objects
88114
89115Each property will be copied from the object to the AIM request.
90116
117+ ``` PHP
91118$sale = new AuthorizeNetAIM;
92119$customer = (object)array();
93120$customer->first_name = "Jane";
@@ -104,17 +131,20 @@ $customer->email = "foo@example.com";
104131$customer->cust_id = "55";
105132$customer->customer_ip = "98.5.5.5";
106133$sale->setFields($customer);
134+ ```
107135
108136Submitting Transactions
109137-----------------------
110138To submit a transaction call one of the 7 methods:
111139
112- -authorizeAndCapture()
113- -authorizeOnly()
114- -priorAuthCapture()
115- -void()
116- -captureOnly()
117- -credit()
140+ ``` PHP
141+ AuthorizeNetAIM::authorizeAndCapture()
142+ AuthorizeNetAIM::authorizeOnly()
143+ AuthorizeNetAIM::priorAuthCapture()
144+ AuthorizeNetAIM::void()
145+ AuthorizeNetAIM::captureOnly()
146+ AuthorizeNetAIM::credit()
147+ ```
118148
119149Each method has optional parameters which highlight the fields required by the
120150Authorize.Net API for that transaction type.
@@ -125,6 +155,7 @@ eCheck
125155To submit an electronic check transaction you can set the required fields individually
126156or simply use the setECheck method:
127157
158+ ``` PHP
128159$sale = new AuthorizeNetAIM;
129160$sale->amount = "45.00";
130161$sale->setECheck(
@@ -136,25 +167,29 @@ $sale->setECheck(
136167 'WEB' // echeck_type
137168);
138169$response = $sale->authorizeAndCapture();
139-
170+ ```
140171
141172Partial Authorization Transactions
142173----------------------------------
143174To enable partial authorization transactions set the partial_auth flag
144175to true:
145176
177+ ``` PHP
146178$sale->allow_partial_auth = true;
179+ ```
147180
148181You should receive a split tender id in the response if a partial auth
149182is made:
150183
184+ ``` PHP
151185$split_tender_id = $response->split_tender_id;
152-
186+ ```
153187
154188Itemized Order Information
155189--------------------------
156190To add itemized order information use the addLineItem method:
157191
192+ ``` PHP
158193$auth->addLineItem(
159194 'item1', // Item Id
160195 'Golf tees', // Item Name
@@ -163,25 +198,27 @@ $auth->addLineItem(
163198 '5.00', // Item Unit Price
164199 'N' // Item taxable
165200 );
166-
201+ ```
167202
168203Merchant Defined Fields
169204-----------------------
170205You can use the setCustomField method to set any custom merchant defined field(s):
171206
207+ ``` PHP
172208$sale->setCustomField("entrance_source", "Search Engine");
173209$sale->setCustomField("coupon_code", "SAVE2011");
174-
210+ ```
175211
176212Transaction Response
177213--------------------
178214When you submit an AIM transaction you receive an AuthorizeNetAIM_Response
179215object in return. You can access each name/value pair in the response as
180216you would normally expect:
181217
218+ ``` PHP
182219$response = $sale->authorizeAndCapture();
183220$response->response_code;
184221$response->response_subcode;
185222$response->response_reason_code;
186223$response->transaction_id;
187-
224+ ```
0 commit comments