From 9ebe3336e470a0510f942f344e9d3277b3e73549 Mon Sep 17 00:00:00 2001 From: Kaushik Date: Mon, 14 Jan 2019 17:17:16 +0530 Subject: [PATCH] Adding CONTRIBUTING.md & MIGRATING.md from v1.9.8 --- CONTRIBUTING.md | 9 ++++++ MIGRATING.md | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ genclass.sh | 76 ------------------------------------------- 3 files changed, 94 insertions(+), 76 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 MIGRATING.md delete mode 100644 genclass.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..c28b27e6 --- /dev/null +++ b/CONTRIBUTING.md @@ -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. diff --git a/MIGRATING.md b/MIGRATING.md new file mode 100644 index 00000000..c35b01d0 --- /dev/null +++ b/MIGRATING.md @@ -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"; + } + } +} +``` diff --git a/genclass.sh b/genclass.sh deleted file mode 100644 index acbe2465..00000000 --- a/genclass.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash - -# sudo apt-get install php5-curl -# composer install - -#create directories that do not exist -apidir=lib/net/authorize/api/contract/v1 -#net.authorize.api.contract.v1. -if [ -d "$apidir" ]; then - rm -r "$apidir" -fi -mkdir -p "$apidir" -echo Make sure the ns-dest uses destination as: $apidir -logfile=./xsdgen.log -echo `date` > $logfile -echo Generating PHP Classes >> $logfile -vendor/goetas/xsd2php/bin/xsd2php convert:php \ - --ns-dest='net.authorize.api.contract.v1.;lib/net/authorize/api/contract/v1' \ - --ns-map='http://www.w3.org/2001/XMLSchema;W3/XMLSchema/2001/' \ - --ns-map='AnetApi/xml/v1/schema/AnetApiSchema.xsd;net.authorize.api.contract.v1' \ - ./AnetApiSchema.xsd >> $logfile 2>> $logfile -echo Generation of PHP Classes complete >> $logfile - -jmsdir=lib/net/authorize/api/yml/v1 -if [ -d "$jmsdir" ]; then - rm -r "$jmsdir" -fi -mkdir -p "$jmsdir" -echo Generating Serializers for Classes >> $logfile -vendor/goetas/xsd2php/bin/xsd2php convert:jms-yaml \ - --ns-dest='net.authorize.api.contract.v1.;lib/net/authorize/api/yml/v1' \ - --ns-map='http://www.w3.org/2001/XMLSchema;W3/XMLSchema/2001/' \ - --ns-map='AnetApi/xml/v1/schema/AnetApiSchema.xsd;net.authorize.api.contract.v1' \ - ./AnetApiSchema.xsd >> $logfile -echo Generator output is in file: $logfile - -#GOOD -# vendor/goetas/xsd2php/bin/xsd2php.php convert:php \ - # --ns-dest='net.authorize.api.contract.v1.;lib/net/authorize/api/contract/v1' \ - # --ns-map='http://www.w3.org/2001/XMLSchema;W3/XMLSchema/2001/' \ - # --ns-map='AnetApi/xml/v1/schema/AnetApiSchema.xsd;net.authorize.api.contract.v1' \ - # /home/ramittal/AnetApiSchema.xsd >> $logfile -#Old good -# vendor/goetas/xsd2php/bin/xsd2php.php convert:php \ - # --ns-dest='net.authorize.api.contract.v1.;lib/net/authorize/api/contract/v1' \ - # --ns-map='http://www.w3.org/2001/XMLSchema;W3/XMLSchema/2001/' \ - # --ns-map='AnetApi/xml/v1/schema/AnetApiSchema.xsd;net.authorize.api.contract.v1' \ - # /home/ramittal/AnetApiSchema.xsd -# -# jmsdir=lib/net/authorize/api/jms/v1 -# mkdir -p $jmsdir -# rm -r $jmsdir\* -# Do not want JMS serializer -# echo Generating Serializers for Classes >> $logfile -# vendor/goetas/xsd2php/bin/xsd2php.php convert:jms-yaml \ - # --ns-dest='net.authorize.api.contract.v1.;lib/net/authorize/api/jms/v1' \ - # --ns-map='http://www.w3.org/2001/XMLSchema;W3/XMLSchema/2001/' \ - # --ns-map='AnetApi/xml/v1/schema/AnetApiSchema.xsd;net.authorize.api.contract.v1' \ - # /home/ramittal/AnetApiSchema.xsd >> $logfile -#DOOG - - -#--alias-map='Vendor/Project/CustomDateClass; http://www.opentravel.org/OTA/2003/05#CustomOTADateTimeFormat' - -# symfony/console suggests installing symfony/event-dispatcher () -# symfony/console suggests installing psr/log (For using the console logger) -# phpunit/php-code-coverage suggests installing ext-xdebug (>=2.2.1) -# phpunit/phpunit suggests installing phpunit/php-invoker (~1.1) -# symfony/dependency-injection suggests installing symfony/proxy-manager-bridge (Generate service proxies to lazy load them) - -# ---------------- -# zendframework/zend-stdlib suggests installing zendframework/zend-serializer (Zend\Serializer component) -# zendframework/zend-stdlib suggests installing zendframework/zend-servicemanager (To support hydrator plugin manager usage) -# zendframework/zend-code suggests installing doctrine/common (Doctrine\Common >=2.1 for annotation features) -# symfony/console suggests installing symfony/event-dispatcher () -# symfony/console suggests installing psr/log (For using the console logger)