Skip to content

Commit bc8a536

Browse files
committed
Merge pull request #24 from adear11/patch-1
Thanks for the PR adear1 and thanks to George for the review! Brian
2 parents b2ba0a8 + 9ea39f5 commit bc8a536

File tree

7 files changed

+135
-42
lines changed

7 files changed

+135
-42
lines changed

doc/AIM.markdown

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,45 @@ to the results of the transaction.
1313
Autoloading
1414
-----------------
1515

16+
```PHP
1617
require 'vendor/autoload.php';
18+
```
1719

1820
Setting Merchant Credentials
1921
----------------------------
2022
The easiest way to set credentials is to define constants which the SDK uses:
23+
24+
```PHP
2125
define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
2226
define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
27+
```
2328

2429
You 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

2935
Setting the Transaction Post Location
3036
-------------------------------------
3137

3238
To post transactions to the live Authorize.Net gateway:
39+
40+
```PHP
3341
define("AUTHORIZENET_SANDBOX", false);
42+
```
3443

3544
To post transactions to the Authorize.Net test server:
45+
46+
```PHP
3647
define("AUTHORIZENET_SANDBOX", true);
48+
```
3749

3850
You can also set the location manually per request:
39-
$sale->setSandbox(false);
4051

52+
```PHP
53+
$sale->setSandbox(false);
54+
```
4155

4256
Setting Fields
4357
--------------
@@ -47,17 +61,22 @@ allows you to set these fields in a few different ways depending on your
4761
preference.
4862

4963
Note: 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

5367
1.) 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

6077
2.) 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

7090
3.) By Setting Special Items
7191

7292
To add line items or set custom fields use the respective functions:
7393

7494
Line 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

84107
Custom Fields:
108+
109+
```PHP
85110
$sale->setCustomField("coupon_code", "SAVE2011");
111+
```
86112

87113
4.) By Passing in Objects
88114

89115
Each 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 = "[email protected]";
104131
$customer->cust_id = "55";
105132
$customer->customer_ip = "98.5.5.5";
106133
$sale->setFields($customer);
134+
```
107135

108136
Submitting Transactions
109137
-----------------------
110138
To 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

119149
Each method has optional parameters which highlight the fields required by the
120150
Authorize.Net API for that transaction type.
@@ -125,6 +155,7 @@ eCheck
125155
To submit an electronic check transaction you can set the required fields individually
126156
or 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

141172
Partial Authorization Transactions
142173
----------------------------------
143174
To enable partial authorization transactions set the partial_auth flag
144175
to true:
145176

177+
```PHP
146178
$sale->allow_partial_auth = true;
179+
```
147180

148181
You should receive a split tender id in the response if a partial auth
149182
is made:
150183

184+
```PHP
151185
$split_tender_id = $response->split_tender_id;
152-
186+
```
153187

154188
Itemized Order Information
155189
--------------------------
156190
To 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

168203
Merchant Defined Fields
169204
-----------------------
170205
You 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

176212
Transaction Response
177213
--------------------
178214
When you submit an AIM transaction you receive an AuthorizeNetAIM_Response
179215
object in return. You can access each name/value pair in the response as
180216
you 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+
```

doc/ARB.markdown

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Creating/Updating Subscriptions
1313

1414
To create or update a subscription first create a subscription object:
1515

16+
```PHP
1617
$subscription = new AuthorizeNet_Subscription;
1718
$subscription->name = "Short subscription";
1819
$subscription->intervalLength = "1";
@@ -25,28 +26,37 @@ $subscription->creditCardExpirationDate = "2018-10";
2526
$subscription->creditCardCardCode = "123";
2627
$subscription->billToFirstName = "john";
2728
$subscription->billToLastName = "doe";
29+
```
2830

2931
Then create an AuthorizeNetARB object and call the appropriate method
3032
passing in your subscription object:
3133

34+
```PHP
3235
$request = new AuthorizeNetARB;
3336
$response = $request->createSubscription($subscription);
37+
```
3438

35-
or for updating a subscription:
36-
39+
or for updating a subscription:
40+
41+
```PHP
3742
$response = $request->updateSubscription($subscription_id, $subscription);
43+
```
3844

3945
Getting Subscription Status
4046
---------------------------
4147

4248
Create a new AuthorizeNetARB object and call the getSubscriptionStatus
4349
method with the subscription_id you want the status of as the parameter:
4450

51+
```PHP
4552
$status_request = new AuthorizeNetARB;
4653
$status_response = $status_request->getSubscriptionStatus($subscription_id);
54+
```
4755

4856
Canceling a Subscription
4957
------------------------
5058

59+
```PHP
5160
$cancellation = new AuthorizeNetARB;
5261
$cancel_response = $cancellation->cancelSubscription($subscription_id);
62+
```

0 commit comments

Comments
 (0)