You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- 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)
21
14
22
15
### 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.
24
17
25
18
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:
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)*.
55
46
*Update your composer.json file as per the example below and then run
56
47
`composer update`.*
57
48
58
49
```json
59
50
{
60
51
"require": {
61
52
"php": ">=5.6",
62
-
"ext-curl": "*",
63
53
"authorizenet/authorizenet": "~1.9"
64
54
}
65
55
}
66
56
```
67
57
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
68
65
Alternatively, we provide a custom `SPL` autoloader for you to reference from within your PHP file:
69
66
```php
70
67
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
75
72
`vendor` directory to the desired system.
76
73
77
74
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.
80
77
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/).
81
78
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).
83
81
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:
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.
104
105
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:
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)
109
119
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:
112
121
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.
113
126
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:
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
+
120
143
121
144
## Logging
122
145
The SDK generates a log with masking for sensitive data like credit card, expiration dates. The provided levels for logging are
123
146
`debug`, `info`, `warn`, `error`. Add ````use \net\authorize\util\LogFactory;````. Logger can be initialized using `$logger = LogFactory::getLog(get_class($this));`
124
147
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.
125
148
126
-
127
149
### Usage Examples
128
150
- Logging a string message `$logger->debug("Sending 'XML' Request type");`
129
151
- Logging xml strings `$logger->debug($xmlRequest);`
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*).
135
156
- For each element of the `sensitiveTags` array,
@@ -144,42 +165,5 @@ A local copy of [AuthorizedNetSensitiveTagsConfig.json](/lib/net/authorize/util/
144
165
**For any regex, no starting or ending '/' or any other delimiter should be defined. The '/' delimiter and unicode flag is added in the code.**
145
166
146
167
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.
# 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.
Copy file name to clipboardExpand all lines: lib/README-DeprecatedSamples.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,11 @@
1
1
Old Usage Examples (Of Deprecated SDK Functionality)
2
2
=======================================
3
3
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:**
0 commit comments