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
-Formatting and wording changes for clarity
-Specify 5.6 as min php version
-composer.json instructions are more flexible so we don't have to remember to change the readme with every release (until 2.0)
-remove sample code from readme in favor of more clearly directing to the sample-code repo
Copy file name to clipboardExpand all lines: README.md
+30-72Lines changed: 30 additions & 72 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,19 +9,20 @@ Authorize.Net PHP SDK
9
9
## License
10
10
Proprietary, see the provided `license.md`.
11
11
12
-
## Requirements
13
12
14
-
- PHP 5.5+
13
+
## Requirements
14
+
- PHP 5.6+
15
15
- cURL PHP Extension
16
16
- JSON PHP Extension
17
17
- SimpleXML PHP Extension
18
18
- An Authorize.Net Merchant Account or Sandbox Account. You can get a
19
19
free sandbox account at http://developer.authorize.net/hello_world/sandbox/
20
20
21
+
21
22
## Autoloading
22
-
23
-
We recommend using [`Composer`](http://getcomposer.org)*(note we never recommend you override the new secure-http default setting)*, don't forget to require its autoloader in
24
-
your script or bootstrap file:
23
+
We recommend using [`Composer`](http://getcomposer.org)*(note we never recommend you
24
+
override the new secure-http default setting)*. Don't forget to require its autoloader
Alternatively, we provide a custom `SPL` autoloader:
42
+
Alternatively, we provide a custom `SPL` autoloader for you to reference from within your PHP file:
42
43
```php
43
44
require 'path/to/anet_php_sdk/autoload.php';
44
45
```
46
+
This autoloader still requires the `vendor` directory and all of its dependencies to exist.
47
+
However, this is a possible solution for cases where composer can't be run on a given system.
48
+
You can run composer locally or on another system to build the directory, then copy the
49
+
`vendor` directory to the desired system.
50
+
45
51
46
52
## Authentication
47
53
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.
48
-
If you need a sandbox account you can sign up for one really easily[`here`](https://developer.authorize.net/sandbox/).
54
+
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/).
49
55
50
-
Once you have your keys simply plug them into the appropriate variables, as per the below code dealing with the authentication part of the flow.
56
+
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.
51
57
52
58
...
53
59
```php
54
60
use net\authorize\api\contract\v1 as AnetAPI;
55
61
```
56
62
...
63
+
57
64
```php
58
65
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
59
66
$merchantAuthentication->setName("YOURLOGIN");
@@ -66,87 +73,36 @@ $request = new AnetAPI\CreateTransactionRequest();
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.
69
77
70
-
## Usage Examples
71
78
72
-
Apart from this README, you can find details and examples of using the SDK in the following places:
73
-
-[Developer Center Reference](http://developer.authorize.net/api/reference/index.html)
79
+
## SDK Usage Examples and Sample Code
80
+
Apart from this README, we have comprehensive sample code for all common uses of our API:
### Quick Usage Example (with Charge Credit Card - Authorize and Capture)
78
-
Note: The following is a php console application. Ensure that you can invoke the php command from command line.
79
-
- Save the below code to a php file named, say, `charge-credit-card.php`
80
-
- Open command prompt and navigate to your SDK folder ( if want to run from a different folder, modify the `require` statement to have the full path to the SDK e.g. `require 'c:/anet-sdk-php/vendor/autoload.php'` in place of `require 'vendor/autoload.php'` )
81
-
- Update dependecies - e.g., With composer, type `composer update`
82
-
- Type `php [<path to folder containing the php file>\]charge-credit-card.php`
83
82
84
-
```php
85
-
require 'vendor/autoload.php';
86
-
use net\authorize\api\contract\v1 as AnetAPI;
87
-
use net\authorize\api\controller as AnetController;
88
-
define("AUTHORIZENET_LOG_FILE", "phplog");
89
-
90
-
// Common setup for API credentials
91
-
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
Replace the environment constant in the execute method. For example, in the method above:
88
+
To change from the sandbox environment to the production environment, replace the environment constant in the execute method. For example, in the method above:
The SDK generates a log with masking for sensitive data like credit card, expiration dates. The provided levels for logging are
142
96
`debug`, `info`, `warn`, `error`. Add ````use \net\authorize\util\LogFactory;````. Logger can be initialized using `$logger = LogFactory::getLog(get_class($this));`
143
97
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.
144
98
99
+
145
100
### Usage Examples
146
101
- Logging a string message `$logger->debug("Sending 'XML' Request type");`
147
102
- 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*).
152
108
- For each element of the `sensitiveTags` array,
@@ -160,8 +116,8 @@ A local copy of [AuthorizedNetSensitiveTagsConfig.json](/lib/net/authorize/util/
160
116
**<aname="regex-note">Note</a>:**
161
117
**For any regex, no starting or ending '/' or any other delimiter should be defined. The '/' delimiter and unicode flag is added in the code.**
162
118
163
-
## Testing
164
119
120
+
## Testing
165
121
Integration tests for the AuthorizeNet SDK are in the `tests` directory. These tests
166
122
are mainly for SDK development. However, you can also browse through them to find
167
123
more usage examples for the various APIs.
@@ -172,7 +128,8 @@ more usage examples for the various APIs.
172
128
- Run `vendor/bin/phpunit` to run the test suite.
173
129
174
130
*You'll probably want to disable emails on your sandbox account.*
175
-
131
+
132
+
176
133
### Test Credit Card Numbers
177
134
178
135
| Card Type | Card Number |
@@ -186,6 +143,7 @@ more usage examples for the various APIs.
186
143
187
144
*Set the expiration date to anytime in the future.*
188
145
146
+
189
147
## PHPDoc
190
148
191
149
Add PhpDocumentor to your composer.json and run `composer update --dev`:
0 commit comments