@@ -12,32 +12,45 @@ to the results of the transaction.
1212
1313Including the SDK
1414-----------------
15-
15+ ```
1616require_once 'anet_php_sdk/AuthorizeNet.php';
17+ ```
1718
1819Setting Merchant Credentials
1920----------------------------
2021The easiest way to set credentials is to define constants which the SDK uses:
22+
23+ ```
2124define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
2225define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
26+ ```
2327
2428You can also set credentials manually per request like so:
2529
30+ ```
2631$sale = new AuthorizeNetAIM("YOUR_API_LOGIN_ID","YOUR_TRANSACTION_KEY");
27-
32+ ```
2833
2934Setting the Transaction Post Location
3035-------------------------------------
3136
3237To post transactions to the live Authorize.Net gateway:
38+
39+ ```
3340define("AUTHORIZENET_SANDBOX", false);
41+ ```
3442
3543To post transactions to the Authorize.Net test server:
44+
45+ ```
3646define("AUTHORIZENET_SANDBOX", true);
47+ ```
3748
3849You can also set the location manually per request:
39- $sale->setSandbox(false);
4050
51+ ```
52+ $sale->setSandbox(false);
53+ ```
4154
4255Setting Fields
4356--------------
@@ -47,17 +60,22 @@ allows you to set these fields in a few different ways depending on your
4760preference.
4861
4962Note: 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.
63+ field in the AIM API has been removed. Thus, instead of setting ` $sale->x_card_num ` ,
64+ set ` $sale->card_num ` instead.
5265
53661.) By Setting Fields Directly:
67+
68+ ```
5469$sale = new AuthorizeNetAIM;
5570$sale->amount = "1999.99";
5671$sale->card_num = '6011000000000012';
5772$sale->exp_date = '04/15';
5873$response = $sale->authorizeAndCapture();
74+ ```
5975
60762.) By Setting Multiple Fields at Once:
77+
78+ ```
6179$sale = new AuthorizeNetAIM;
6280$sale->setFields(
6381 array(
@@ -66,12 +84,15 @@ $sale->setFields(
6684 'exp_date' => '0415'
6785 )
6886);
87+ ```
6988
70893.) By Setting Special Items
7190
7291To add line items or set custom fields use the respective functions:
7392
7493Line Items:
94+
95+ ```
7596$sale->addLineItem(
7697 'item1', // Item Id
7798 'Golf tees', // Item Name
@@ -80,14 +101,18 @@ $sale->addLineItem(
80101 '5.00', // Item Unit Price
81102 'N' // Item taxable
82103 );
104+ ```
83105
84106Custom Fields:
107+
108+ ```
85109$sale->setCustomField("coupon_code", "SAVE2011");
110+ ```
86111
871124.) By Passing in Objects
88-
89113Each property will be copied from the object to the AIM request.
90114
115+ ```
91116$sale = new AuthorizeNetAIM;
92117$customer = (object)array();
93118$customer->first_name = "Jane";
104129$customer->cust_id = "55";
105130$customer->customer_ip = "98.5.5.5";
106131$sale->setFields($customer);
132+ ```
107133
108134Submitting Transactions
109135-----------------------
110136To submit a transaction call one of the 7 methods:
111137
138+ ```
112139-authorizeAndCapture()
113140-authorizeOnly()
114141-priorAuthCapture()
115142-void()
116143-captureOnly()
117144-credit()
145+ ```
118146
119147Each method has optional parameters which highlight the fields required by the
120148Authorize.Net API for that transaction type.
@@ -125,6 +153,7 @@ eCheck
125153To submit an electronic check transaction you can set the required fields individually
126154or simply use the setECheck method:
127155
156+ ```
128157$sale = new AuthorizeNetAIM;
129158$sale->amount = "45.00";
130159$sale->setECheck(
@@ -136,25 +165,30 @@ $sale->setECheck(
136165 'WEB' // echeck_type
137166);
138167$response = $sale->authorizeAndCapture();
168+ ```
139169
140170
141171Partial Authorization Transactions
142172----------------------------------
143173To enable partial authorization transactions set the partial_auth flag
144174to true:
145175
176+ ```
146177$sale->allow_partial_auth = true;
178+ ```
147179
148180You should receive a split tender id in the response if a partial auth
149181is made:
150182
183+ ```
151184$split_tender_id = $response->split_tender_id;
152-
185+ ```
153186
154187Itemized Order Information
155188--------------------------
156189To add itemized order information use the addLineItem method:
157190
191+ ```
158192$auth->addLineItem(
159193 'item1', // Item Id
160194 'Golf tees', // Item Name
@@ -163,25 +197,27 @@ $auth->addLineItem(
163197 '5.00', // Item Unit Price
164198 'N' // Item taxable
165199 );
166-
200+ ```
167201
168202Merchant Defined Fields
169203-----------------------
170204You can use the setCustomField method to set any custom merchant defined field(s):
171205
206+ ```
172207$sale->setCustomField("entrance_source", "Search Engine");
173208$sale->setCustomField("coupon_code", "SAVE2011");
174-
209+ ```
175210
176211Transaction Response
177212--------------------
178213When you submit an AIM transaction you receive an AuthorizeNetAIM_Response
179214object in return. You can access each name/value pair in the response as
180215you would normally expect:
181216
217+ ```
182218$response = $sale->authorizeAndCapture();
183219$response->response_code;
184220$response->response_subcode;
185221$response->response_reason_code;
186222$response->transaction_id;
187-
223+ ```
0 commit comments