Skip to content

Commit

Permalink
Merge pull request #3 from Gufran/fix/documentation
Browse files Browse the repository at this point in the history
fixed formatting in documentations
  • Loading branch information
cystbear committed May 21, 2014
2 parents 685681d + 88ac490 commit 229365d
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 43 deletions.
56 changes: 46 additions & 10 deletions doc/AIM.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,45 @@ to the results of the transaction.

Including the SDK
-----------------

```
require_once 'anet_php_sdk/AuthorizeNet.php';
```

Setting Merchant Credentials
----------------------------
The easiest way to set credentials is to define constants which the SDK uses:

```
define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
```

You can also set credentials manually per request like so:

```
$sale = new AuthorizeNetAIM("YOUR_API_LOGIN_ID","YOUR_TRANSACTION_KEY");

```

Setting the Transaction Post Location
-------------------------------------

To post transactions to the live Authorize.Net gateway:

```
define("AUTHORIZENET_SANDBOX", false);
```

To post transactions to the Authorize.Net test server:

```
define("AUTHORIZENET_SANDBOX", true);
```

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

```
$sale->setSandbox(false);
```

Setting Fields
--------------
Expand All @@ -47,17 +60,22 @@ allows you to set these fields in a few different ways depending on your
preference.

Note: to make things easier on the developer, the "x_" prefix attached to each
field in the AIM API has been removed. Thus, instead of setting $sale->x_card_num,
set $sale->card_num instead.
field in the AIM API has been removed. Thus, instead of setting `$sale->x_card_num`,
set `$sale->card_num` instead.

1.) By Setting Fields Directly:

```
$sale = new AuthorizeNetAIM;
$sale->amount = "1999.99";
$sale->card_num = '6011000000000012';
$sale->exp_date = '04/15';
$response = $sale->authorizeAndCapture();
```

2.) By Setting Multiple Fields at Once:

```
$sale = new AuthorizeNetAIM;
$sale->setFields(
array(
Expand All @@ -66,12 +84,15 @@ $sale->setFields(
'exp_date' => '0415'
)
);
```

3.) By Setting Special Items

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

Line Items:

```
$sale->addLineItem(
'item1', // Item Id
'Golf tees', // Item Name
Expand All @@ -80,14 +101,18 @@ $sale->addLineItem(
'5.00', // Item Unit Price
'N' // Item taxable
);
```

Custom Fields:

```
$sale->setCustomField("coupon_code", "SAVE2011");
```

4.) By Passing in Objects

Each property will be copied from the object to the AIM request.

```
$sale = new AuthorizeNetAIM;
$customer = (object)array();
$customer->first_name = "Jane";
Expand All @@ -104,17 +129,20 @@ $customer->email = "[email protected]";
$customer->cust_id = "55";
$customer->customer_ip = "98.5.5.5";
$sale->setFields($customer);
```

Submitting Transactions
-----------------------
To submit a transaction call one of the 7 methods:

```
-authorizeAndCapture()
-authorizeOnly()
-priorAuthCapture()
-void()
-captureOnly()
-credit()
```

Each method has optional parameters which highlight the fields required by the
Authorize.Net API for that transaction type.
Expand All @@ -125,6 +153,7 @@ eCheck
To submit an electronic check transaction you can set the required fields individually
or simply use the setECheck method:

```
$sale = new AuthorizeNetAIM;
$sale->amount = "45.00";
$sale->setECheck(
Expand All @@ -136,25 +165,30 @@ $sale->setECheck(
'WEB' // echeck_type
);
$response = $sale->authorizeAndCapture();
```


Partial Authorization Transactions
----------------------------------
To enable partial authorization transactions set the partial_auth flag
to true:

```
$sale->allow_partial_auth = true;
```

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

```
$split_tender_id = $response->split_tender_id;

```

Itemized Order Information
--------------------------
To add itemized order information use the addLineItem method:

```
$auth->addLineItem(
'item1', // Item Id
'Golf tees', // Item Name
Expand All @@ -163,25 +197,27 @@ $auth->addLineItem(
'5.00', // Item Unit Price
'N' // Item taxable
);

```

Merchant Defined Fields
-----------------------
You can use the setCustomField method to set any custom merchant defined field(s):

```
$sale->setCustomField("entrance_source", "Search Engine");
$sale->setCustomField("coupon_code", "SAVE2011");

```

Transaction Response
--------------------
When you submit an AIM transaction you receive an AuthorizeNetAIM_Response
object in return. You can access each name/value pair in the response as
you would normally expect:

```
$response = $sale->authorizeAndCapture();
$response->response_code;
$response->response_subcode;
$response->response_reason_code;
$response->transaction_id;

```
14 changes: 11 additions & 3 deletions doc/ARB.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ Basic Overview
The AuthorizeNetARB class creates a request object for submitting transactions
to the AuthorizeNetARB API.


Creating/Updating Subscriptions
-------------------------------

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

```
$subscription = new AuthorizeNet_Subscription;
$subscription->name = "Short subscription";
$subscription->intervalLength = "1";
Expand All @@ -25,28 +24,37 @@ $subscription->creditCardExpirationDate = "2018-10";
$subscription->creditCardCardCode = "123";
$subscription->billToFirstName = "john";
$subscription->billToLastName = "doe";
```

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

```
$request = new AuthorizeNetARB;
$response = $request->createSubscription($subscription);
```

or for updating a subscription:
or for updating a subscription:

```
$response = $request->updateSubscription($subscription_id, $subscription);
```

Getting Subscription Status
---------------------------

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

```
$status_request = new AuthorizeNetARB;
$status_response = $status_request->getSubscriptionStatus($subscription_id);
```

Canceling a Subscription
------------------------

```
$cancellation = new AuthorizeNetARB;
$cancel_response = $cancellation->cancelSubscription($subscription_id);
```
Loading

0 comments on commit 229365d

Please sign in to comment.