Skip to content

Commit 8d42489

Browse files
committed
Create README_OLD.md
1 parent aae4506 commit 8d42489

1 file changed

Lines changed: 251 additions & 0 deletions

File tree

README_OLD.md

Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
Authorize.Net PHP SDK
2+
======================
3+
4+
[![Build Status] (https://travis-ci.org/AuthorizeNet/sdk-php.png?branch=master)]
5+
(https://travis-ci.org/AuthorizeNet/sdk-php)
6+
7+
8+
## License
9+
Proprietary, see the provided `license.md`.
10+
11+
## Requirements
12+
13+
- PHP 5.3+ *(>=5.3.10 recommended)*
14+
- cURL PHP Extension
15+
- JSON PHP Extension
16+
- SimpleXML PHP Extension
17+
- An Authorize.Net Merchant Account or Sandbox Account. You can get a
18+
free sandbox account at http://developer.authorize.net/sandbox/
19+
20+
## Autoloading
21+
22+
[`Composer`](http://getcomposer.org) currently has a [MITM](https://github.com/composer/composer/issues/1074)
23+
security vulnerability. However, if you wish to use it, require its autoloader in
24+
your script or bootstrap file:
25+
```php
26+
require 'vendor/autoload.php';
27+
```
28+
*Note: you'll need a composer.json file with the following require section and to run
29+
`composer update`.*
30+
```json
31+
"require": {
32+
"authorizenet/authorizenet": "~1.8"
33+
}
34+
```
35+
36+
Alternatively, we provide a custom `SPL` autoloader:
37+
```php
38+
require 'path/to/anet_php_sdk/autoload.php';
39+
```
40+
41+
## Authentication
42+
To authenticate with the Authorize.Net API you will need to retrieve your API Login ID and Transaction Key from the [`Merchant Interface`](https://account.authorize.net/). You can find these details in the Settings section.
43+
If you need a sandbox account you can sign up for one really easily [`here`](https://developer.authorize.net/sandbox/).
44+
45+
Once you have your keys simply plug them into the appropriate variables as per the samples below.
46+
47+
````php
48+
define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
49+
define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
50+
````
51+
52+
## Usage Examples
53+
54+
See below for basic usage examples. View the `tests/` folder for more examples of
55+
each API. Additional documentation is in the `docs/` folder.
56+
57+
### AuthorizeNetAIM.php Quick Usage Example
58+
59+
```php
60+
define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
61+
define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
62+
define("AUTHORIZENET_SANDBOX", true);
63+
$sale = new AuthorizeNetAIM;
64+
$sale->amount = "5.99";
65+
$sale->card_num = '6011000000000012';
66+
$sale->exp_date = '04/15';
67+
$response = $sale->authorizeAndCapture();
68+
if ($response->approved) {
69+
$transaction_id = $response->transaction_id;
70+
}
71+
```
72+
73+
### AuthorizeNetAIM.php Advanced Usage Example
74+
75+
```php
76+
define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
77+
define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
78+
define("AUTHORIZENET_SANDBOX", true);
79+
$auth = new AuthorizeNetAIM;
80+
$auth->amount = "45.00";
81+
82+
// Use eCheck:
83+
$auth->setECheck(
84+
'121042882',
85+
'123456789123',
86+
'CHECKING',
87+
'Bank of Earth',
88+
'Jane Doe',
89+
'WEB'
90+
);
91+
92+
// Set multiple line items:
93+
$auth->addLineItem('item1', 'Golf tees', 'Blue tees', '2', '5.00', 'N');
94+
$auth->addLineItem('item2', 'Golf shirt', 'XL', '1', '40.00', 'N');
95+
96+
// Set Invoice Number:
97+
$auth->invoice_num = time();
98+
99+
// Set a Merchant Defined Field:
100+
$auth->setCustomField("entrance_source", "Search Engine");
101+
102+
// Authorize Only:
103+
$response = $auth->authorizeOnly();
104+
105+
if ($response->approved) {
106+
$auth_code = $response->transaction_id;
107+
108+
// Now capture:
109+
$capture = new AuthorizeNetAIM;
110+
$capture_response = $capture->priorAuthCapture($auth_code);
111+
112+
// Now void:
113+
$void = new AuthorizeNetAIM;
114+
$void_response = $void->void($capture_response->transaction_id);
115+
}
116+
```
117+
118+
### AuthorizeNetARB.php Usage Example
119+
120+
```php
121+
define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
122+
define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
123+
$subscription = new AuthorizeNet_Subscription;
124+
$subscription->name = "PHP Monthly Magazine";
125+
$subscription->intervalLength = "1";
126+
$subscription->intervalUnit = "months";
127+
$subscription->startDate = "2011-03-12";
128+
$subscription->totalOccurrences = "12";
129+
$subscription->amount = "12.99";
130+
$subscription->creditCardCardNumber = "6011000000000012";
131+
$subscription->creditCardExpirationDate= "2018-10";
132+
$subscription->creditCardCardCode = "123";
133+
$subscription->billToFirstName = "Rasmus";
134+
$subscription->billToLastName = "Doe";
135+
136+
// Create the subscription.
137+
$request = new AuthorizeNetARB;
138+
$response = $request->createSubscription($subscription);
139+
$subscription_id = $response->getSubscriptionId();
140+
```
141+
142+
### AuthorizeNetCIM.php Usage Example
143+
144+
```php
145+
define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
146+
define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
147+
$request = new AuthorizeNetCIM;
148+
// Create new customer profile
149+
$customerProfile = new AuthorizeNetCustomer;
150+
$customerProfile->description = "Description of customer";
151+
$customerProfile->merchantCustomerId = time();
152+
$customerProfile->email = "test@domain.com";
153+
$response = $request->createCustomerProfile($customerProfile);
154+
if ($response->isOk()) {
155+
$customerProfileId = $response->getCustomerProfileId();
156+
}
157+
```
158+
159+
### AuthorizeNetSIM.php Usage Example
160+
161+
```php
162+
define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
163+
define("AUTHORIZENET_MD5_SETTING", "");
164+
$message = new AuthorizeNetSIM;
165+
if ($message->isAuthorizeNet()) {
166+
$transactionId = $message->transaction_id;
167+
}
168+
```
169+
170+
### AuthorizeNetDPM.php Usage Example
171+
172+
```php
173+
$url = "http://YOUR_DOMAIN.com/direct_post.php";
174+
$api_login_id = 'YOUR_API_LOGIN_ID';
175+
$transaction_key = 'YOUR_TRANSACTION_KEY';
176+
$md5_setting = 'YOUR_MD5_SETTING'; // Your MD5 Setting
177+
$amount = "5.99";
178+
AuthorizeNetDPM::directPostDemo($url, $api_login_id, $transaction_key, $amount, $md5_setting);
179+
```
180+
181+
### AuthorizeNetCP.php Usage Example
182+
183+
```php
184+
define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
185+
define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
186+
define("AUTHORIZENET_MD5_SETTING", "");
187+
$sale = new AuthorizeNetCP;
188+
$sale->amount = '59.99';
189+
$sale->device_type = '4';
190+
$sale->setTrack1Data('%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?');
191+
$response = $sale->authorizeAndCapture();
192+
$trans_id = $response->transaction_id;
193+
```
194+
195+
### AuthorizeNetTD.php Usage Example
196+
197+
```php
198+
define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
199+
define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
200+
$request = new AuthorizeNetTD;
201+
$response = $request->getTransactionDetails("12345");
202+
echo $response->xml->transaction->transactionStatus;
203+
```
204+
205+
## Testing
206+
207+
Integration tests for the AuthorizeNet SDK are in the `tests` directory. These tests
208+
are mainly for SDK development. However, you can also browse through them to find
209+
more usage examples for the various APIs.
210+
211+
- Run `composer update --dev` to load the `PHPUnit` test library.
212+
- Copy the `phpunit.xml.dist` file to `phpunit.xml` and enter your merchant
213+
credentials in the constant fields.
214+
- Run `vendor/bin/phpunit` to run the test suite.
215+
216+
*You'll probably want to disable emails on your sandbox account.*
217+
218+
### Test Credit Card Numbers
219+
220+
| Card Type | Card Number |
221+
|----------------------------|------------------|
222+
| American Express Test Card | 370000000000002 |
223+
| Discover Test Card | 6011000000000012 |
224+
| Visa Test Card | 4007000000027 |
225+
| Second Visa Test Card | 4012888818888 |
226+
| JCB | 3088000000000017 |
227+
| Diners Club/ Carte Blanche | 38000000000006 |
228+
229+
*Set the expiration date to anytime in the future.*
230+
231+
## PHPDoc
232+
233+
Add PhpDocumentor to your composer.json and run `composer update --dev`:
234+
```json
235+
"require-dev": {
236+
"phpdocumentor/phpdocumentor": "*"
237+
}
238+
```
239+
To autogenerate PHPDocs run:
240+
```shell
241+
vendor/bin/phpdoc -t doc/api/ -d lib
242+
```
243+
244+
## New Model
245+
246+
We’re exploring a new model of maintaining the SDKs which allows us to be more responsive to API changes. This model is consistent across the different SDK languages, which is great for us, however we do not want to sacrifice your productivity by losing the inherent efficiencies in the PHP language or our object model. To this end we’re introducing the new model as purely “experimental” at this time and we would appreciate your feedback. Let us know what you really think!
247+
248+
You can find examples of using the new model in the following places:
249+
- [Developer Center Reference](http://developer.authorize.net/api/reference/index.html)
250+
- [Github Sample Code Repositories](http://developer.authorize.net/api/samplecode/), [php](https://github.com/AuthorizeNet/sample-code-php)
251+
- [SDK README (New Version)](README.md)

0 commit comments

Comments
 (0)