Skip to content

Commit

Permalink
Merge branch 'php72'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
stymiee committed May 8, 2020
2 parents ca848ff + ab43e2e commit 5e4915d
Show file tree
Hide file tree
Showing 100 changed files with 4,777 additions and 5,908 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
28 changes: 25 additions & 3 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
CHANGE LOG

2020-XX-XX - Version 4.0.0
--------------------------------------------
Changed name of Akamai endpoint to be more generic and accurate (CDN); includes tests
Minor fixes for examples
Changed config.inc.php to throw RuntimeException

2020-03-08 - Version 4.0.0-beta
--------------------------------------------
Bumped minimum supported version of PHP to 7.2
If trying to retrieve non-existent response value, NULL is returned in AuthnetJsonResponse::__get()
Added AuthnetJson::BOUNDLESS_OCCURRENCES to indicate an endless subscription
Added support for prepaid cards
Added constructor to Authnet exceptions
Removed unused AuthnetInvalidParameterException class
Updated unit tests for phpunit 8
Removed unneeded require of config file in unit tests
Added phpunit to require-dev
Added CONTRIBUTING.md
Shiny badges for the README
Cleaned up HTML and CSS in examples
Minor formatting changes

2019-06-03 - Version 3.1.9
--------------------------------------------
Returned better error message when creating Webhook
Expand All @@ -8,7 +30,7 @@ Removed unnecessary suppression operators by checking if a variable is set in th
2019-01-26 - Version 3.1.8
--------------------------------------------
Removed not actually missing return statement to AuthnetWebhooksRequest::delete
Reduced complexity of AuthnetApiFactory::getWebServiceURL)(
Reduced complexity of AuthnetApiFactory::getWebServiceURL()
Reduced complexity of AuthnetWebhooksResponse::getEventTypes()
Reduced complexity of AuthnetWebhook::getAllHeaders()

Expand Down Expand Up @@ -135,12 +157,12 @@ Fixed bug where AuthnetInvalidJsonException would not be thrown when invalid JSO

2015-03-30 - Version 1.0.1
--------------------------------------------
Fixed bug where setting the third parameter AuthnetApiFactory::getJsonApiHandler to NULL would default to production server
Fixed bug where setting the third parameter AuthnetApiFactory::getJsonApiHandler to NULL would default to production endpoint
Throws AuthnetInvalidJsonException if response JSON is not valid
Finished adding examples
Added more unit tests
Added more docbloc comments

2015-03-21 - Version 1.0.0
--------------------------------------------
Initial Release
Initial Release
81 changes: 81 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make via issue,
email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

## Code of Conduct

### Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

### Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

### Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

### Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

### Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at stymiee@gmail.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

### Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
22 changes: 17 additions & 5 deletions HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,28 @@ Here are some tips, solutions to common problems, and guides for testing.
### Create a Sandbox Account

Before doing any development for the Authorize.Net suite of APIs, be sure to create a
[Sandbox Account](https://developer.authorize.net/hello_world/sandbox/) with Authorize.Net. With it you can simulate virtually
every aspect of the Authorize.Net production APIs without incurring any fees.
[Sandbox Account](https://developer.authorize.net/hello_world/sandbox/) with Authorize.Net. With it you can simulate
virtually every aspect of the Authorize.Net production APIs without incurring any fees.

### Use a webhook testing site to test webhooks

Having a full understanding of what a webhook looks like makes working with webhooks easier. You can inspect an Authorize.Net
webhook using a third party service like [RequestBin](https://requestbin.fullcontact.com/).
Having a full understanding of what a webhook looks like makes working with webhooks easier. You can inspect an
Authorize.Net webhook using a third party service like [webhook.site](https://webhook.site/).

## FAQ

Solutions to common problems when integrating the [AuthnetJSON](https://github.com/stymiee/authnetjson) library into your project.
Solutions to common problems when integrating the [AuthnetJSON](https://github.com/stymiee/authnetjson) library into
your project.

### php://input is empty, POST is empty, webhook has no data
This may happen because a redirect occurred and steps were not taken to persist that data across the redirect.
Look for redirects to HTTPS or to/from the `www` subdomain in your .htaccess or web.config file.

### Class 'authnet\className' not found
- This may happen if you did not include the Composer autoload.php file in your project

require __DIR__.'/vendor/autoload.php';

## Support

If you require assistance using this library I can be found at Stack Overflow. Be sure when you
Expand All @@ -32,3 +38,9 @@ this class to tag your question with the **PHP** and **Authorize.Net** tags. Mak
and I will not be able to assist you.

**Do not use Stack Overflow to report bugs.** Bugs may be reported [here](https://github.com/stymiee/authnetjson/issues/new).

## Helpful Links

* [Authorize.Net Developer Guides](https://developer.authorize.net/api/)
* [Authorize.Net Testing Guide](https://developer.authorize.net/hello_world/testing_guide/)
* [Response Codes](https://developer.authorize.net/api/reference/responseCodes.html)
60 changes: 33 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
[![Latest Stable Version](https://poser.pugx.org/stymiee/authnetjson/v/stable.svg)](https://packagist.org/packages/stymiee/authnetjson)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/stymiee/authnetjson/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/stymiee/authnetjson/?branch=master)
[![Total Downloads](https://poser.pugx.org/stymiee/authnetjson/downloads)](https://packagist.org/packages/stymiee/authnetjson)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/stymiee/authnetjson/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/stymiee/authnetjson/?branch=php72)
[![Build Status](https://scrutinizer-ci.com/g/stymiee/authnetjson/badges/build.png?b=php72)](https://scrutinizer-ci.com/g/stymiee/authnetjson/build-status/php72)
[![Code Coverage](https://scrutinizer-ci.com/g/stymiee/authnetjson/badges/coverage.png?b=php72)](https://scrutinizer-ci.com/g/stymiee/authnetjson/?branch=php72)
[![Maintainability](https://api.codeclimate.com/v1/badges/5847da924af47933e25f/maintainability)](https://codeclimate.com/github/stymiee/authnetjson/maintainability)

[![License](https://poser.pugx.org/stymiee/authnetjson/license)](https://packagist.org/packages/stymiee/authnetjson)
# AuthnetJSON

Library that abstracts [Authorize.Net](http://www.authorize.net/)'s [JSON APIs](http://developer.authorize.net/api/reference/).

## Requirements

- PHP 5.4+ (Supports PHP 5.4.0 - 7.4.*)
- PHP 7.2+ (Support for PHP 7.2.0 - 7.4.*)
- cURL PHP Extension
- JSON PHP Extension
- An Authorize.Net account
- TLS 1.2 capable versions of libcurl and OpenSSL or equivalent

**NOTE:** AuthnetJSON 4.0 will not be backwards compatible with PHP 5 and the minimum PHP version will be 7.2.

## Installation

Simply add a dependency on `stymiee/authnetjson` to your project's `composer.json` file if you use [Composer](http://getcomposer.org/)
to manage the dependencies of your project.

Here is a minimal example of a `composer.json` file that just defines a dependency on AuthnetJson:
Here is a minimal example of a `composer.json` file that just defines a dependency on AuthnetJSON:

{
"require": {
"stymiee/authnetjson": "3.1.*"
"stymiee/authnetjson": "~4.0"
}
}

Expand All @@ -52,10 +52,11 @@ The format of the array to be passed during the API call follows the structure o

## Using the Authorize.Net Development Server

Authorize.Net provides a development environment for developers to test their integration against. To use this server
Authorize.Net provides a development environment for developers to test their integration against. To use this endpoint
(as opposed to their production endpoint) set the optional third parameter of `AuthnetApiFactory::getJsonApiHandler()` to be `1` or use the built in class constant `AuthnetApiFactory::USE_DEVELOPMENT_SERVER`:

$json = AuthnetApiFactory::getJsonApiHandler(AUTHNET_LOGIN, AUTHNET_TRANSKEY, AuthnetApiFactory::USE_DEVELOPMENT_SERVER);
$json = AuthnetApiFactory::getJsonApiHandler(AUTHNET_LOGIN, AUTHNET_TRANSKEY,
AuthnetApiFactory::USE_DEVELOPMENT_SERVER);

## Usage Examples

Expand All @@ -68,14 +69,14 @@ transaction ID).

$request = AuthnetApiFactory::getJsonApiHandler(AUTHNET_LOGIN, AUTHNET_TRANSKEY);
$response = $request->createTransactionRequest([
'refId' => rand(1000000, 100000000],
'refId' => rand(1000000, 100000000),
'transactionRequest' => [
'transactionType' => 'authCaptureTransaction',
'amount' => 5,
'payment' => [
'creditCard' => [
'cardNumber' => '4111111111111111',
'expirationDate' => '122016',
'expirationDate' => '122026',
'cardCode' => '999',
]
]
Expand All @@ -89,14 +90,14 @@ transaction ID).

$request = AuthnetApiFactory::getJsonApiHandler(AUTHNET_LOGIN, AUTHNET_TRANSKEY);
$response = $request->createTransactionRequest([
'refId' => rand(1000000, 100000000],
'refId' => rand(1000000, 100000000),
'transactionRequest' => [
'transactionType' => 'authCaptureTransaction',
'amount' => 5,
'payment' => [
'creditCard' => [
'cardNumber' => '4111111111111111',
'expirationDate' => '122016',
'expirationDate' => '122026',
'cardCode' => '999',
],
],
Expand Down Expand Up @@ -189,12 +190,14 @@ transaction ID).
],
'userFields' => [
'userField' => [
'name' => 'MerchantDefinedFieldName1',
'value' => 'MerchantDefinedFieldValue1',
],
'userField' => [
'name' => 'favorite_color',
'value' => 'blue',
0 => [
'name' => 'MerchantDefinedFieldName1',
'value' => 'MerchantDefinedFieldValue1',
],
1 => [
'name' => 'favorite_color',
'value' => 'blue',
],
],
],
],
Expand Down Expand Up @@ -224,7 +227,7 @@ transaction ID).
'payment' => [
'creditCard' => [
'cardNumber' => '4111111111111111',
'expirationDate' => '2016-08',
'expirationDate' => '2026-08',
],
],
],
Expand Down Expand Up @@ -257,7 +260,7 @@ transaction ID).
'length' => '1',
'unit' => 'months'
],
'startDate' => '2015-04-18',
'startDate' => '2020-04-18',
'totalOccurrences' => '12',
'trialOccurrences' => '1'
],
Expand Down Expand Up @@ -285,8 +288,8 @@ transaction ID).
$request = AuthnetApiFactory::getJsonApiHandler(AUTHNET_LOGIN, AUTHNET_TRANSKEY);
$response = $request->getSettledBatchListRequest([
'includeStatistics' => 'true',
'firstSettlementDate' => '2015-01-01T08:15:30',
'lastSettlementDate' => '2015-01-30T08:15:30',
'firstSettlementDate' => '2020-01-01T08:15:30',
'lastSettlementDate' => '2020-01-30T08:15:30',
]);

if ($response->isSuccessful()) {
Expand Down Expand Up @@ -349,7 +352,7 @@ If `apache_request_headers()`/`getallheaders()` are not available to you, you ca
## Debugging

To assist with debugging the `__toString()` method has been overridden to output important elements pertaining to the
usage of this library. Simple `echo` your AuthnetJson object to see:
usage of this library. Simple `echo` your AuthnetJSON object to see:

- The API Login ID used
- The API transaction Key used
Expand All @@ -365,9 +368,12 @@ usage of this library. Simple `echo` your AuthnetJson object to see:

## Support

If you require assistance using this library I can be found at Stack Overflow. Be sure when you
If you require assistance using this library start by viewing the [HELP.md](HELP.md) file included in this package. It
includes common problems and their solutions.

If you need additional assistance, I can be found at Stack Overflow. Be sure when you
[ask a question](http://stackoverflow.com/questions/ask?tags=php,authorize.net) pertaining to the usage of
this class to tag your question with the **PHP** and **Authorize.Net** tags. Make sure you follow their
this class be sure to tag your question with the **PHP** and **Authorize.Net** tags. Make sure you follow their
[guide for asking a good question](http://stackoverflow.com/help/how-to-ask) as poorly asked questions will be closed
and I will not be able to assist you.

Expand Down
23 changes: 16 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
"capture-transaction",
"authorize-net",
"authorizenet",
"authnet",
"payment",
"payment-gateway"
],
"homepage": "http://github.com/stymiee/authnetjson",
"homepage": "https://github.com/stymiee/authnetjson",
"license": "Apache-2.0",
"authors": [
{
Expand All @@ -26,14 +27,22 @@
}
],
"require": {
"php": ">=5.4.0",
"curl/curl": "^1.5",
"php": ">=7.2.0",
"curl/curl": "^2",
"ext-curl": "*",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^9",
"squizlabs/php_codesniffer": "3.*",
"phpmd/phpmd" : "@stable"
},
"autoload": {
"classmap": [
"src/"
]
"psr-4": {
"JohnConde\\Authnet\\": [
"src/authnet/",
"src/exceptions/"
]
}
}
}
}
Loading

0 comments on commit 5e4915d

Please sign in to comment.