Skip to content

Commit c6e622a

Browse files
authored
Merge pull request #241 from adavidw/readme
Standardize readme format and info across repos
2 parents a80937b + 7bb2e09 commit c6e622a

6 files changed

Lines changed: 68 additions & 79 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ vendor
44
phpunit.xml
55
tests/log
66
build
7+
phplog
78

89
# Ignore eclipse project files
910
.buildpath
File renamed without changes.

README.md

Lines changed: 59 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
Authorize.Net PHP SDK
2-
======================
1+
#Authorize.Net PHP SDK
32

43
[![Travis](https://img.shields.io/travis/AuthorizeNet/sdk-php/master.svg)](https://travis-ci.org/AuthorizeNet/sdk-php)
54
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/AuthorizeNet/sdk-php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/AuthorizeNet/sdk-php/?branch=master)
65
[![Packagist](https://img.shields.io/packagist/v/authorizenet/authorizenet.svg)](https://packagist.org/packages/authorizenet/authorizenet)
76

87

9-
## License
10-
Proprietary, see the provided `license.md`.
11-
12-
138
## Requirements
14-
- PHP 5.6+
15-
- cURL PHP Extension
16-
- JSON PHP Extension
17-
- SimpleXML PHP Extension
18-
- An Authorize.Net Merchant account or Sandbox account (You can get a
19-
free sandbox account at http://developer.authorize.net/hello_world/sandbox/).
20-
- TLS 1.2 capable versions of libcurl and OpenSSL (or its equivalent)
9+
* PHP 5.6+
10+
* cURL PHP Extension
11+
* JSON PHP Extension
12+
* An Authorize.Net account (see _Registration & Configuration_ section below)
13+
* TLS 1.2 capable versions of libcurl and OpenSSL (or its equivalent)
2114

2215
### TLS 1.2
23-
The Authorize.Net APIs only support connections using the TLS 1.2 security protocol. This PHP SDK communicates with the Authorize.Net API using `libcurl` and `OpenSSL` (or equivalent crypto library). It's important to make sure you have new enough versions of these components to support TLS 1.2. Additionally, it's very important to keep these components up to date going forward to mitigate the risk of any security flaws that may be discovered in these libraries.
16+
The Authorize.Net APIs only support connections using the TLS 1.2 security protocol. This SDK communicates with the Authorize.Net API using `libcurl` and `OpenSSL` (or equivalent crypto library). It's important to make sure you have new enough versions of these components to support TLS 1.2. Additionally, it's very important to keep these components up to date going forward to mitigate the risk of any security flaws that may be discovered in these libraries.
2417

2518
To test whether your current installation is capable of communicating to our servers using TLS 1.2, run the following PHP code and examine the output for the TLS version:
2619
```php
@@ -44,27 +37,31 @@ $json = json_decode($data);
4437
echo "Connection uses " . $json->tls_version ."\n";
4538
```
4639

40+
41+
## Installation
4742

48-
## Autoloading
49-
We recommend using [`Composer`](http://getcomposer.org) *(note we never recommend you
50-
override the new secure-http default setting)*. Don't forget to require its autoloader
51-
in your script or bootstrap file:
52-
```php
53-
require 'vendor/autoload.php';
54-
```
43+
### Composer
44+
We recommend using [`Composer`](http://getcomposer.org). *(Note: we never recommend you
45+
override the new secure-http default setting)*.
5546
*Update your composer.json file as per the example below and then run
5647
`composer update`.*
5748

5849
```json
5950
{
6051
"require": {
6152
"php": ">=5.6",
62-
"ext-curl": "*",
6353
"authorizenet/authorizenet": "~1.9"
6454
}
6555
}
6656
```
6757

58+
After installation through Composer,
59+
don't forget to require its autoloader in your script or bootstrap file:
60+
```php
61+
require 'vendor/autoload.php';
62+
```
63+
64+
### Custom SPL Autoloader
6865
Alternatively, we provide a custom `SPL` autoloader for you to reference from within your PHP file:
6966
```php
7067
require 'path/to/anet_php_sdk/autoload.php';
@@ -75,12 +72,16 @@ You can run composer locally or on another system to build the directory, then c
7572
`vendor` directory to the desired system.
7673

7774

78-
## Authentication
79-
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.
75+
## Registration & Configuration
76+
Use of this SDK and the Authorize.Net APIs requires having an account on our system. You can find these details in the Settings section.
8077
If you don't currently have a production Authorize.Net account and need a sandbox account for testing, you can easily sign up for one [here](https://developer.authorize.net/sandbox/).
8178

82-
Once you have your keys simply load them into the appropriate variables in your code, as per the below sample code dealing with the authentication part of the flow.
79+
### Authentication
80+
To authenticate with the Authorize.Net API you will need to use your account's API Login ID and Transaction Key. If you don't have these values, you can obtain them from our Merchant Interface site. Access the Merchant Interface for production accounts at (https://account.authorize.net/) or sandbox accounts at (https://sandbox.authorize.net).
8381

82+
Once you have your keys simply load them into the appropriate variables in your code, as per the below sample code dealing with the authentication part of the API request.
83+
84+
#### To set your API credentials for an API request:
8485
...
8586
```php
8687
use net\authorize\api\contract\v1 as AnetAPI;
@@ -102,34 +103,54 @@ $request->setMerchantAuthentication($merchantAuthentication);
102103

103104
You should never include your Login ID and Transaction Key directly in a PHP file that's in a publically accessible portion of your website. A better practice would be to define these in a constants file, and then reference those constants in the appropriate place in your code.
104105

106+
### Switching between the sandbox environment and the production environment
107+
Authorize.Net maintains a complete sandbox environment for testing and development purposes. This sandbox environment is an exact duplicate of our production environment with the transaction authorization and settlement process simulated. By default, this SDK is configured to communicate with the sandbox environment. To switch to the production environment, replace the environment constant in the execute method. For example:
108+
```php
109+
// For PRODUCTION use
110+
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION);
111+
```
112+
113+
API credentials are different for each environment, so be sure to switch to the appropriate credentials when switching environments.
114+
105115

106116
## SDK Usage Examples and Sample Code
107-
Apart from this README, we have comprehensive sample code for all common uses of our API:
108-
- [Github Sample Code Repositories](https://github.com/AuthorizeNet/sample-code-php)
117+
To get started using this SDK, it's highly recommended to download our sample code repository:
118+
* [Authorize.Net PHP Sample Code Repository (on GitHub)](https://github.com/AuthorizeNet/sample-code-php)
109119

110-
Additionally, you can find details and examples of using the SDK in our API Reference Guide:
111-
- [Developer Center API Reference](http://developer.authorize.net/api/reference/index.html)
120+
In that respository, we have comprehensive sample code for all common uses of our API:
112121

122+
Additionally, you can find details and examples of how our API is structured in our API Reference Guide:
123+
* [Developer Center API Reference](http://developer.authorize.net/api/reference/index.html)
124+
125+
The API Reference Guide provides examples of what information is needed for a particular request and how that information would be formatted. Using those examples, you can easily determine what methods would be necessary to include that information in a request using this SDK.
113126

114-
### Setting Production Environment
115-
To change from the sandbox environment to the production environment, replace the environment constant in the execute method. For example, in the method above:
116-
```php
117-
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::PRODUCTION);
118-
```
119127

128+
## Building & Testing the SDK
129+
Integration tests for the AuthorizeNet SDK are in the `tests` directory. These tests
130+
are mainly for SDK development. However, you can also browse through them to find
131+
more usage examples for the various APIs.
132+
133+
- Run `composer update --dev` to load the `PHPUnit` test library.
134+
- Copy the `phpunit.xml.dist` file to `phpunit.xml` and enter your merchant
135+
credentials in the constant fields.
136+
- Run `vendor/bin/phpunit` to run the test suite.
137+
138+
*You'll probably want to disable emails on your sandbox account.*
139+
140+
### Testing Guide
141+
For additional help in testing your own code, Authorize.Net maintains a [comprehensive testing guide](http://developer.authorize.net/hello_world/testing_guide/) that includes test credit card numbers to use and special triggers to generate certain responses from the sandbox environment.
142+
120143

121144
## Logging
122145
The SDK generates a log with masking for sensitive data like credit card, expiration dates. The provided levels for logging are
123146
`debug`, `info`, `warn`, `error`. Add ````use \net\authorize\util\LogFactory;````. Logger can be initialized using `$logger = LogFactory::getLog(get_class($this));`
124147
The default log file `phplog` gets generated in the current folder. The subsequent logs are appended to the same file, unless the execution folder is changed, and a new log file is generated.
125148

126-
127149
### Usage Examples
128150
- Logging a string message `$logger->debug("Sending 'XML' Request type");`
129151
- Logging xml strings `$logger->debug($xmlRequest);`
130152
- Logging using formatting `$logger->debugFormat("Integer: %d, Float: %f, Xml-Request: %s\n", array(100, 1.29f, $xmlRequest));`
131153

132-
133154
### Customizing Sensitive Tags
134155
A local copy of [AuthorizedNetSensitiveTagsConfig.json](/lib/net/authorize/util/ANetSensitiveFields.php) gets generated when code invoking the logger first gets executed. The local file can later be edited by developer to re-configure what is masked and what is visible. (*Do not edit the JSON in the SDK*).
135156
- For each element of the `sensitiveTags` array,
@@ -144,42 +165,5 @@ A local copy of [AuthorizedNetSensitiveTagsConfig.json](/lib/net/authorize/util/
144165
**For any regex, no starting or ending '/' or any other delimiter should be defined. The '/' delimiter and unicode flag is added in the code.**
145166

146167

147-
## Testing
148-
Integration tests for the AuthorizeNet SDK are in the `tests` directory. These tests
149-
are mainly for SDK development. However, you can also browse through them to find
150-
more usage examples for the various APIs.
151-
152-
- Run `composer update --dev` to load the `PHPUnit` test library.
153-
- Copy the `phpunit.xml.dist` file to `phpunit.xml` and enter your merchant
154-
credentials in the constant fields.
155-
- Run `vendor/bin/phpunit` to run the test suite.
156-
157-
*You'll probably want to disable emails on your sandbox account.*
158-
159-
160-
### Test Credit Card Numbers
161-
162-
| Card Type | Card Number |
163-
|----------------------------|------------------|
164-
| American Express Test Card | 370000000000002 |
165-
| Discover Test Card | 6011000000000012 |
166-
| Visa Test Card | 4007000000027 |
167-
| Second Visa Test Card | 4012888818888 |
168-
| JCB | 3088000000000017 |
169-
| Diners Club/ Carte Blanche | 38000000000006 |
170-
171-
*Set the expiration date to anytime in the future.*
172-
173-
174-
## PHPDoc
175-
176-
Add PhpDocumentor to your composer.json and run `composer update --dev`:
177-
```json
178-
"require-dev": {
179-
"phpdocumentor/phpdocumentor": "*"
180-
}
181-
```
182-
To autogenerate PHPDocs run:
183-
```shell
184-
vendor/bin/phpdoc -t doc/api/ -d lib
185-
```
168+
## License
169+
This repository is distributed under a proprietary license. See the provided [`LICENSE.txt`](/license.txt) file.

doc/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This documentation and the objects it documents have been deprecated
2+
3+
For the README for this repository, see README.md in the root level of the repository. For examples of how to interact with the current Authorize.Net API, see our new sample code GitHub repository at https://github.com/AuthorizeNet/sample-code-php.

doc/readme.md

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
Old Usage Examples (Of Deprecated SDK Functionality)
22
=======================================
33

4-
**PLEASE NOTE: These examples are for deprecated functionality. Refer to the [README](/README.md) in root folder of the SDK for the new examples.**
4+
# This documentation in this directoary and the objects it documents have been deprecated
5+
6+
**For the README for this repository, see `[README.md]`(/README.md) in the root level of the repository. For examples of how to interact with the current Authorize.Net API, see our new sample code GitHub repository at https://github.com/AuthorizeNet/sample-code-php.**
7+
8+
**What follows is the old README pertaining to this deprecated functionality:**
59

610
## Requirements
711

0 commit comments

Comments
 (0)