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
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
43
If you need a sandbox account you can sign up for one really easily [`here`](https://developer.authorize.net/sandbox/).
44
44
45
-
Once you have your keys simply plug them into the appropriate variables as per the samples below.
45
+
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.
### Quick Usage Example (with Charge Credit Card - Authorize and Capture)
73
+
Note: The following is a php console application. Ensure that you can invoke the php command from command line.
74
+
- Save the below code to a php file named, say, `charge-credit-card.php`
75
+
- 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'` )
76
+
- Update dependecies - e.g., With composer, type `composer update`
77
+
- Type `php [<path to folder containing the php file>\]charge-credit-card.php`
SDK generates log with masking for sensitive data like credit card, expiration dates. The provided levels for logging are
132
+
`debug`, `info`, `warn`, `error`. Add ````use \net\authorize\util\LogFactory;````. Logger can be initialized using `$logger = LogFactory::getLog(get_class($this));`
133
+
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.
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 sdk*).
142
+
- For each element of the `sensitiveTags` array,
143
+
-`tagName` field corresponds to the name of the property in object, or xml-tag that should be hidden entirely ( *XXXX* shown if no replacement specified ) or masked (e.g. showing the last 4 digits of credit card number).
144
+
-`pattern`[<sup>[Note]</sup>](#regex-note) and `replacement`[<sup>[Note]</sup>](#regex-note) can be left `""`, if the default is to be used (as defined in [Log.php](/lib/net/authorize/util/Log.php)). `pattern` gives the regex to identify, while `replacement` defines the visible part.
145
+
-`disableMask` can be set to *true* to allow the log to fully display that property in an object, or tag in a xml string.
146
+
-`sensitiveStringRegexes`[<sup>[Note]</sup>](#regex-note) has list of credit-card regexes. So if credit-card number is not already masked, it would get entirely masked.
147
+
- Take care of non-ascii characters (refer [manual](http://php.net/manual/en/regexp.reference.unicode.php)) while defining the regex, e.g. use
148
+
`"pattern": "(\\p{N}+)(\\p{N}{4})"` instead of `"pattern": "(\\d+)(\\d{4})"`. Also note `\\` escape sequence is used.
**For any regex, no starting or ending '/' or any other delimiter should be defined. The '/' delimiter and unicode flag is added in the code.**
204
152
205
153
## Testing
206
154
@@ -240,83 +188,3 @@ To autogenerate PHPDocs run:
240
188
```shell
241
189
vendor/bin/phpdoc -t doc/api/ -d lib
242
190
```
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! Here’s an example of a server side call with ApplePay data in the new model.
247
-
248
-
### Apple Pay Example
249
-
You'll need to introduce some new dependencies into composer.json
250
-
````json
251
-
{
252
-
253
-
"require": {
254
-
"php": ">=5.2.0",
255
-
"ext-curl": "*",
256
-
"authorizenet/authorizenet": "1.8.3",
257
-
"jms/serializer": "xsd2php-dev as 0.18.0"
258
-
},
259
-
"require-dev": {
260
-
"goetas/xsd2php": "2.*@dev",
261
-
"goetas/xsd-reader": "2.*@dev"
262
-
},
263
-
"repositories": [{
264
-
"type": "vcs",
265
-
"url": "https://github.com/goetas/serializer.git"
266
-
}]
267
-
268
-
}
269
-
````
270
-
271
-
Here's the PHP code :
272
-
273
-
````php
274
-
<?php
275
-
require 'vendor/autoload.php';
276
-
277
-
use net\authorize\api\contract\v1 as AnetAPI;
278
-
use net\authorize\api\controller as AnetController;
279
-
280
-
define("AUTHORIZENET_LOG_FILE", "phplog");
281
-
282
-
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
0 commit comments