Skip to content

Commit

Permalink
Merge pull request #338 from khaaldrogo/future
Browse files Browse the repository at this point in the history
Changes for release 1.9.8
  • Loading branch information
ashtru authored Oct 11, 2018
2 parents 0cb5494 + 9507f6d commit bdb5577
Show file tree
Hide file tree
Showing 38 changed files with 399 additions and 35 deletions.
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Thanks for contributing to the Authorize.Net PHP SDK.

Before you submit a pull request, we ask that you consider the following:

- Submit an issue to state the problem your pull request solves or the funtionality that it adds. We can then advise on the feasability of the pull request, and let you know if there are other possible solutions.
- Part of the SDK is auto-generated based on the XML schema. Due to this auto-generation, we cannot merge contributions for request or response classes. You are welcome to open an issue to report problems or suggest improvements. Auto-generated classes include all files inside [contract/v1](https://github.com/AuthorizeNet/sdk-php/tree/master/lib/net/authorize/api/contract/v1) and [controller](https://github.com/AuthorizeNet/sdk-php/tree/master/lib/net/authorize/api/controller) folders, except [controller/base](https://github.com/AuthorizeNet/sdk-php/tree/master/lib/net/authorize/api/controller/base).
- Files marked as deprecated are no longer supported. Issues and pull requests for changes to these deprecated files will be closed.
- Recent changes will be in future branch. Check the code in *future* branch first to see if a fix has already been merged, before suggesting changes to a file.
- **Always create pull request to the future branch.** The pull request will be merged to future, and later pushed to master as part of the next release.
85 changes: 85 additions & 0 deletions MIGRATING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Migrating from Legacy Authorize.Net Classes

Authorize.Net no longer supports several legacy classes, including AuthorizeNetAIM.php, AuthorizenetSIM.php, and others listed below, as part of PHP-SDK. If you are using any of these, we recommend that you update your code to use the new Authorize.Net API classes.

**For details on the deprecation and replacement of legacy Authorize.Net APIs, visit https://developer.authorize.net/api/upgrade_guide/.**

## Full list of classes that are no longer supported
| Class | New Feature | Sample Codes directory/repository |
|----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| AuthorizeNetAIM.php | [PaymentTransactions](https://developer.authorize.net/api/reference/index.html#payment-transactions) | [sample-code-php/PaymentTransactions](https://github.com/AuthorizeNet/sample-code-php/tree/master/PaymentTransactions) |
| AuthorizeNetARB.php | [RecurringBilling](https://developer.authorize.net/api/reference/index.html#recurring-billing) | [sample-code-php/RecurringBilling](https://github.com/AuthorizeNet/sample-code-php/tree/master/RecurringBilling) |
| AuthorizeNetCIM.php | [CustomerProfiles](https://developer.authorize.net/api/reference/index.html#customer-profiles) | [sample-code-php/CustomerProfiles](https://github.com/AuthorizeNet/sample-code-php/tree/master/CustomerProfiles) |
| Hosted CIM | [Accept Customer](https://developer.authorize.net/content/developer/en_us/api/reference/features/customer_profiles.html#Using_the_Accept_Customer_Hosted_Form) | Not available |
| AuthorizeNetCP.php | [PaymentTransactions](https://developer.authorize.net/api/reference/index.html#payment-transactions) | [sample-code-php/PaymentTransactions](https://github.com/AuthorizeNet/sample-code-php/tree/master/PaymentTransactions) |
| AuthorizeNetDPM.php | [Accept.JS](https://developer.authorize.net/api/reference/features/acceptjs.html) | [Sample Accept Application](https://github.com/AuthorizeNet/accept-sample-app) |
| AuthorizeNetSIM.php | [Accept Hosted](https://developer.authorize.net/content/developer/en_us/api/reference/features/accept_hosted.html) | Not available |
| AuthorizeNetSOAP.php | [PaymentTransactions](https://developer.authorize.net/api/reference/index.html#payment-transactions) | [sample-code-php/PaymentTransactions](https://github.com/AuthorizeNet/sample-code-php/tree/master/PaymentTransactions) |
| AuthorizeNetTD.php | [TransactionReporting](https://developer.authorize.net/api/reference/index.html#transaction-reporting) | [sample-code-php/TransactionReporting/](https://github.com/AuthorizeNet/sample-code-php/tree/master/TransactionReporting) |

## Example
#### Old AuthorizeNetAIM example:
```php
define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
define("AUTHORIZENET_SANDBOX", true);
$sale = new AuthorizeNetAIM;
$sale->amount = "5.99";
$sale->card_num = '6011000000000012';
$sale->exp_date = '04/15';
$response = $sale->authorizeAndCapture();
if ($response->approved) {
$transaction_id = $response->transaction_id;
}
```
#### Corresponding new model code (charge-credit-card):
```php
require 'vendor/autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;

define("AUTHORIZENET_LOG_FILE", "phplog");
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("YOURLOGIN");
$merchantAuthentication->setTransactionKey("YOURKEY");
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("6011000000000012");
$creditCard->setExpirationDate("2015-04");
$creditCard->setCardCode("123");

// Add the payment data to a paymentType object
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);

$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureTransaction");
$transactionRequestType->setAmount("5.99");
$transactionRequestType->setPayment($paymentOne);

// Assemble the complete transaction request
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setTransactionRequest($transactionRequestType);

// Create the controller and get the response
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);

if ($response != null) {
// Check to see if the API request was successfully received and acted upon
if ($response->getMessages()->getResultCode() == "Ok") {
// Since the API request was successful, look for a transaction response
// and parse it to display the results of authorizing the card
$tresponse = $response->getTransactionResponse();

if ($tresponse != null && $tresponse->getMessages() != null) {
echo " Successfully created transaction with Transaction ID: " . $tresponse->getTransId() . "\n";
echo " Transaction Response Code: " . $tresponse->getResponseCode() . "\n";
echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "\n";
echo " Auth Code: " . $tresponse->getAuthCode() . "\n";
echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "\n";
}
}
}
```
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
* An Authorize.Net account (see _Registration & Configuration_ section below)
* TLS 1.2 capable versions of libcurl and OpenSSL (or its equivalent)

### Migrating from older versions
Since August 2018, the Authorize.Net API has been reorganized to be more merchant focused. AuthorizeNetAIM, AuthorizeNetARB, AuthorizeNetCIM, Reporting and AuthorizeNetSIM classes have all been deprecated in favor of `net\authorize\api` . To see the full list of mapping of new features corresponding to the deprecated features, you can see [MIGRATING.md](MIGRATING.md).

### Contribution
- If you need information or clarification about any Authorize.Net features, please create an issue for it. Also you can search in the [Authorize.Net developer community](https://community.developer.authorize.net/).
- Before creating pull requests, please read [CONTRIBUTING.md](CONTRIBUTING.md)

### TLS 1.2
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.

Expand Down Expand Up @@ -50,7 +57,7 @@ override the new secure-http default setting)*.
{
"require": {
"php": ">=5.6",
"authorizenet/authorizenet": "~1.9.7"
"authorizenet/authorizenet": "~1.9.8"
}
}
```
Expand Down
7 changes: 7 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<?php
/**
* @deprecated since version 1.9.8
* @deprecated Always use composer generated autoload.php, by requiring vendor/autoload.php instead of autoload.php
* @deprecated require "autoload.php"; --> require "vendor/autoload.php";
*/
trigger_error('Custom autoloader is deprecated, use composer generated "vendor/autoload.php" instead of "autoload.php" .', E_USER_DEPRECATED);

/**
* Custom SPL autoloader for the AuthorizeNet SDK
*
Expand Down
38 changes: 22 additions & 16 deletions classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

$baseDir = __DIR__ ;
$libDir = $baseDir . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR;
$sharedDir = $libDir . 'shared' . DIRECTORY_SEPARATOR;
$deprecated = $libDir . DIRECTORY_SEPARATOR . 'deprecated' . DIRECTORY_SEPARATOR;
$sharedDir = $deprecated . DIRECTORY_SEPARATOR . 'shared' . DIRECTORY_SEPARATOR;
$vendorDir = $baseDir . '/vendor';

return array(
Expand Down Expand Up @@ -44,6 +45,8 @@
'JMS\Parser\SimpleLexer' => $vendorDir . '/jms/parser-lib/src/JMS/Parser/SimpleLexer.php',
'JMS\Parser\SyntaxErrorException' => $vendorDir . '/jms/parser-lib/src/JMS/Parser/SyntaxErrorException.php',
'JMS\Serializer\AbstractVisitor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/AbstractVisitor.php',
'JMS\Serializer\Accessor\AccessorStrategyInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Accessor/AccessorStrategyInterface.php',
'JMS\Serializer\Accessor\DefaultAccessorStrategy' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Accessor/DefaultAccessorStrategy.php',
'JMS\Serializer\ArrayTransformerInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/ArrayTransformerInterface.php',
'JMS\Serializer\Context' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Context.php',
'JMS\Serializer\ContextFactory\CallableContextFactory' => $vendorDir . '/jms/serializer/src/JMS/Serializer/ContextFactory/CallableContextFactory.php',
Expand All @@ -52,13 +55,16 @@
'JMS\Serializer\ContextFactory\DefaultDeserializationContextFactory' => $vendorDir . '/jms/serializer/src/JMS/Serializer/ContextFactory/DefaultDeserializationContextFactory.php',
'JMS\Serializer\ContextFactory\DefaultSerializationContextFactory' => $vendorDir . '/jms/serializer/src/JMS/Serializer/ContextFactory/DefaultSerializationContextFactory.php',
'JMS\Serializer\ContextFactory\DeserializationContextFactoryInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/ContextFactory/DeserializationContextFactoryInterface.php',
'JMS\Serializer\ContextFactory\SerializationContextFactoryInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/ContextFactory/SerializationContextFactoryInterface.php',
'JMS\Serializer\ContextFactory\SerializationContextFactoryInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/ContextFactory/SerializationContextFactoryInterface.php',
'JMS\Serializer\DeserializationContext' => $vendorDir . '/jms/serializer/src/JMS/Serializer/DeserializationContext.php',
'JMS\Serializer\GenericDeserializationVisitor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/GenericDeserializationVisitor.php',
'JMS\Serializer\GenericSerializationVisitor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/GenericSerializationVisitor.php',
'JMS\Serializer\GraphNavigator' => $vendorDir . '/jms/serializer/src/JMS/Serializer/GraphNavigator.php',
'JMS\Serializer\GraphNavigatorInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/GraphNavigatorInterface.php',
'JMS\Serializer\Handler\StdClassHandler' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Handler/StdClassHandler.php',
'JMS\Serializer\JsonDeserializationVisitor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/JsonDeserializationVisitor.php',
'JMS\Serializer\JsonSerializationVisitor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/JsonSerializationVisitor.php',
'JMS\Serializer\NullAwareVisitorInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/NullAwareVisitorInterface.php',
'JMS\Serializer\SerializationContext' => $vendorDir . '/jms/serializer/src/JMS/Serializer/SerializationContext.php',
'JMS\Serializer\Serializer' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Serializer.php',
'JMS\Serializer\SerializerBuilder' => $vendorDir . '/jms/serializer/src/JMS/Serializer/SerializerBuilder.php',
Expand Down Expand Up @@ -196,30 +202,30 @@
'Symfony\Component\Yaml\Parser' => $vendorDir . '/symfony/yaml/Parser.php',
'Symfony\Component\Yaml\Inline' => $vendorDir . '/symfony/yaml/Inline.php',

'AuthorizeNetAIM' => $libDir . 'AuthorizeNetAIM.php',
'AuthorizeNetAIM_Response' => $libDir . 'AuthorizeNetAIM.php',
'AuthorizeNetARB' => $libDir . 'AuthorizeNetARB.php',
'AuthorizeNetARB_Response' => $libDir . 'AuthorizeNetARB.php',
'AuthorizeNetAIM' => $deprecated . 'AuthorizeNetAIM.php',
'AuthorizeNetAIM_Response' => $deprecated . 'AuthorizeNetAIM.php',
'AuthorizeNetARB' => $deprecated . 'AuthorizeNetARB.php',
'AuthorizeNetARB_Response' => $deprecated . 'AuthorizeNetARB.php',
'AuthorizeNetAddress' => $sharedDir . 'AuthorizeNetTypes.php',
'AuthorizeNetBankAccount' => $sharedDir . 'AuthorizeNetTypes.php',
'AuthorizeNetCIM' => $libDir . 'AuthorizeNetCIM.php',
'AuthorizeNetCIM_Response' => $libDir . 'AuthorizeNetCIM.php',
'AuthorizeNetCP' => $libDir . 'AuthorizeNetCP.php',
'AuthorizeNetCP_Response' => $libDir . 'AuthorizeNetCP.php',
'AuthorizeNetCIM' => $deprecated . 'AuthorizeNetCIM.php',
'AuthorizeNetCIM_Response' => $deprecated . 'AuthorizeNetCIM.php',
'AuthorizeNetCP' => $deprecated . 'AuthorizeNetCP.php',
'AuthorizeNetCP_Response' => $deprecated . 'AuthorizeNetCP.php',
'AuthorizeNetCreditCard' => $sharedDir . 'AuthorizeNetTypes.php',
'AuthorizeNetCustomer' => $sharedDir . 'AuthorizeNetTypes.php',
'AuthorizeNetDPM' => $libDir . 'AuthorizeNetDPM.php',
'AuthorizeNetDPM' => $deprecated . 'AuthorizeNetDPM.php',
'AuthorizeNetException' => $sharedDir . 'AuthorizeNetException.php',
'AuthorizeNetLineItem' => $sharedDir . 'AuthorizeNetTypes.php',
'AuthorizeNetPayment' => $sharedDir . 'AuthorizeNetTypes.php',
'AuthorizeNetPaymentProfile' => $sharedDir . 'AuthorizeNetTypes.php',
'AuthorizeNetRequest' => $sharedDir . 'AuthorizeNetRequest.php',
'AuthorizeNetResponse' => $sharedDir . 'AuthorizeNetResponse.php',
'AuthorizeNetSIM' => $libDir . 'AuthorizeNetSIM.php',
'AuthorizeNetSIM_Form' => $libDir . 'AuthorizeNetSIM.php',
'AuthorizeNetSOAP' => $libDir . 'AuthorizeNetSOAP.php',
'AuthorizeNetTD' => $libDir . 'AuthorizeNetTD.php',
'AuthorizeNetTD_Response' => $libDir . 'AuthorizeNetTD.php',
'AuthorizeNetSIM' => $deprecated . 'AuthorizeNetSIM.php',
'AuthorizeNetSIM_Form' => $deprecated . 'AuthorizeNetSIM.php',
'AuthorizeNetSOAP' => $deprecated . 'AuthorizeNetSOAP.php',
'AuthorizeNetTD' => $deprecated . 'AuthorizeNetTD.php',
'AuthorizeNetTD_Response' => $deprecated . 'AuthorizeNetTD.php',
'AuthorizeNetTransaction' => $sharedDir . 'AuthorizeNetTypes.php',
'AuthorizeNetXMLResponse' => $sharedDir . 'AuthorizeNetXMLResponse.php',
'AuthorizeNet_Subscription' => $sharedDir . 'AuthorizeNetTypes.php',
Expand Down
10 changes: 10 additions & 0 deletions lib/AuthorizeNetAIM.php → lib/deprecated/AuthorizeNetAIM.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<?php
/**
* @deprecated since version 1.9.8
* @deprecated We have reorganized and simplified the Authorize.Net API to ease integration and to focus on merchants' needs.
* @deprecated We have deprecated AIM, ARB, CIM, and Reporting as separate options, in favor of AuthorizeNet::API.
* @deprecated We have also deprecated SIM as a separate option, in favor of Accept Hosted. See https://developer.authorize.net/api/reference/features/accept_hosted.html for details on Accept Hosted.
* @deprecated For details on the deprecation and replacement of legacy Authorize.Net methods, visit https://developer.authorize.net/api/upgrade_guide/.
* @deprecated For AIM, refer examples in https://github.com/AuthorizeNet/sample-code-php/tree/master/PaymentTransactions
*/
trigger_error('AuthorizeNetAIM is deprecated, use AuthorizeNet::API instead. For AIM, see examples in https://github.com/AuthorizeNet/sample-code-php/tree/master/PaymentTransactions .', E_USER_DEPRECATED);

/**
* Easily interact with the Authorize.Net AIM API.
*
Expand Down
10 changes: 10 additions & 0 deletions lib/AuthorizeNetARB.php → lib/deprecated/AuthorizeNetARB.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<?php
/**
* @deprecated since version 1.9.8
* @deprecated We have reorganized and simplified the Authorize.Net API to ease integration and to focus on merchants' needs.
* @deprecated We have deprecated AIM, ARB, CIM, and Reporting as separate options, in favor of AuthorizeNet::API.
* @deprecated We have also deprecated SIM as a separate option, in favor of Accept Hosted. See https://developer.authorize.net/api/reference/features/accept_hosted.html for details on Accept Hosted.
* @deprecated For details on the deprecation and replacement of legacy Authorize.Net methods, visit https://developer.authorize.net/api/upgrade_guide/.
* @deprecated For ARB, refer examples in https://github.com/AuthorizeNet/sample-code-php/tree/master/RecurringBilling
*/
trigger_error('AuthorizeNetARB is deprecated, use AuthorizeNet::API instead. For ARB, see examples in https://github.com/AuthorizeNet/sample-code-php/tree/master/RecurringBilling .', E_USER_DEPRECATED);

/**
* Easily interact with the Authorize.Net ARB XML API.
*
Expand Down
Loading

0 comments on commit bdb5577

Please sign in to comment.