├── .editorconfig ├── .github └── workflows │ └── php.yml ├── CHANGELOG ├── CONTRIBUTING.md ├── HELP.md ├── README.md ├── SECURITY.md ├── build ├── coverage │ └── .keep ├── insights │ └── .keep ├── phpcs │ └── .keep └── phpmd │ └── .keep ├── composer.json ├── config.inc.php.dist ├── examples ├── acceptjs │ ├── getHostedPaymentPageRequest.php │ ├── getHostedProfilePageRequest.php │ └── selfHostedPaymentForm.php ├── aim │ ├── authenticateTestRequest.php │ ├── createTransactionRequest_authCapture.php │ ├── createTransactionRequest_authOnly.php │ ├── createTransactionRequest_captureOnly.php │ ├── createTransactionRequest_partialAuth.php │ ├── createTransactionRequest_paypalAuthCapture.php │ ├── createTransactionRequest_paypalAuthCaptureContinue.php │ ├── createTransactionRequest_paypalAuthOnly.php │ ├── createTransactionRequest_paypalAuthOnlyContinue.php │ ├── createTransactionRequest_paypalGetDetails.php │ ├── createTransactionRequest_paypalPriorAuthCapture.php │ ├── createTransactionRequest_paypalRefund.php │ ├── createTransactionRequest_paypalVoid.php │ ├── createTransactionRequest_priorAuthCapture.php │ ├── createTransactionRequest_refund.php │ ├── createTransactionRequest_visaCheckout.php │ ├── createTransactionRequest_void.php │ ├── decryptPaymentDataRequest.php │ └── sendCustomerTransactionReceiptRequest.php ├── arb │ ├── ARBCancelSubscriptionRequest.php │ ├── ARBCreateSubscriptionRequest.php │ ├── ARBCreateSubscriptionRequestFromProfile.php │ ├── ARBGetSubscriptionListRequest.php │ ├── ARBGetSubscriptionRequest.php │ ├── ARBGetSubscriptionStatusRequest.php │ └── ARBUpdateSubscriptionRequest.php ├── cim │ ├── createCustomerPaymentProfileRequest.php │ ├── createCustomerProfileRequest.php │ ├── createCustomerProfileRequestMultiplePayAccounts.php │ ├── createCustomerProfileTransactionRequest_authCapture.php │ ├── createCustomerProfileTransactionRequest_authOnly.php │ ├── createCustomerProfileTransactionRequest_captureOnly.php │ ├── createCustomerProfileTransactionRequest_priorAuthCapture.php │ ├── createCustomerProfileTransactionRequest_refund.php │ ├── createCustomerProfileTransactionRequest_void.php │ ├── createCustomerShippingAddressRequest.php │ ├── deleteCustomerPaymentProfileRequest.php │ ├── deleteCustomerProfileRequest.php │ ├── deleteCustomerShippingAddressRequest.php │ ├── getCustomerPaymentProfileRequest.php │ ├── getCustomerProfileIdsRequest.php │ ├── getCustomerProfileRequest.php │ ├── getCustomerShippingAddressRequest.php │ ├── getHostedProfilePageRequest.php │ ├── updateCustomerPaymentProfileRequest.php │ ├── updateCustomerProfileRequest.php │ ├── updateCustomerShippingAddressRequest.php │ ├── updateSplitTenderGroupRequest.php │ └── validateCustomerPaymentProfileRequest.php ├── fraud │ ├── getUnsettledTransactionListRequest.php │ └── updateHeldTransactionRequest.php ├── reporting │ ├── getAUJobDetailsRequest.php │ ├── getAUJobSummaryRequest.php │ ├── getBatchStatisticsRequest.php │ ├── getMerchantDetailsRequest.php │ ├── getSettledBatchListRequest.php │ ├── getTransactionDetailsRequest.php │ ├── getTransactionListRequest.php │ └── getUnsettledTransactionListRequest.php ├── sim │ └── sim.php └── webhooks │ ├── createWebhook.php │ ├── deleteWebhook.php │ ├── getEventTypes.php │ ├── getWebhook.php │ ├── listWebhooks.php │ ├── notificationHistory.php │ ├── ping.php │ └── updateWebhook.php ├── license.txt ├── phpdoc.xml ├── phpunit.xml ├── src └── Authnetjson │ ├── AuthnetAcceptJs.php │ ├── AuthnetApiFactory.php │ ├── AuthnetJson.php │ ├── AuthnetJsonRequest.php │ ├── AuthnetJsonResponse.php │ ├── AuthnetSim.php │ ├── AuthnetWebhook.php │ ├── AuthnetWebhooksRequest.php │ ├── AuthnetWebhooksResponse.php │ ├── Exception │ ├── AuthnetCannotSetParamsException.php │ ├── AuthnetCurlException.php │ ├── AuthnetException.php │ ├── AuthnetInvalidAmountException.php │ ├── AuthnetInvalidCredentialsException.php │ ├── AuthnetInvalidJsonException.php │ ├── AuthnetInvalidServerException.php │ └── AuthnetTransactionResponseCallException.php │ └── TransactionResponse.php └── tests └── Authnetjson ├── AuthnetApiFactoryTest.php ├── AuthnetJsonAimPaypalTest.php ├── AuthnetJsonAimTest.php ├── AuthnetJsonArbTest.php ├── AuthnetJsonCimTest.php ├── AuthnetJsonReportingTest.php ├── AuthnetJsonRequestTest.php ├── AuthnetJsonResponseTest.php ├── AuthnetSimTest.php ├── AuthnetWebhookTest.php ├── AuthnetWebhooksRequestTest.php ├── AuthnetWebhooksResponseTest.php └── TransactionResponseTest.php /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_style = space 7 | indent_size = 4 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.php] 15 | indent_style = space 16 | indent_size = 4 17 | end_of_line = lf 18 | charset = utf-8 19 | trim_trailing_whitespace = true 20 | insert_final_newline = true 21 | max_line_length = 120 22 | -------------------------------------------------------------------------------- /.github/workflows/php.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | 17 | - uses: shivammathur/setup-php@v2 18 | with: 19 | php-version: '7.4' 20 | 21 | - name: Validate composer.json and composer.lock 22 | run: composer validate 23 | 24 | - name: Suppress composer error message 25 | run: composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true 26 | 27 | - name: Install dependencies 28 | run: composer install --prefer-dist --no-progress 29 | 30 | # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" 31 | # Docs: https://getcomposer.org/doc/articles/scripts.md 32 | 33 | - name: Run test suite 34 | run: composer run-script test 35 | 36 | - name: Run PHP Code Sniffer 37 | run: composer run-script phpcs 38 | 39 | - name: Run PHP Mess Detecter 40 | run: composer run-script phpmd 41 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, 4 | email, or any other method with the owners of this repository before making a change. 5 | 6 | Please note we have a code of conduct, please follow it in all your interactions with the project. 7 | 8 | ## Code of Conduct 9 | 10 | ### Our Pledge 11 | 12 | In the interest of fostering an open and welcoming environment, we as 13 | contributors and maintainers pledge to making participation in our project and 14 | our community a harassment-free experience for everyone, regardless of age, body 15 | size, disability, ethnicity, gender identity and expression, level of experience, 16 | nationality, personal appearance, race, religion, or sexual identity and 17 | orientation. 18 | 19 | ### Our Standards 20 | 21 | Examples of behavior that contributes to creating a positive environment 22 | include: 23 | 24 | * Using welcoming and inclusive language 25 | * Being respectful of differing viewpoints and experiences 26 | * Gracefully accepting constructive criticism 27 | * Focusing on what is best for the community 28 | * Showing empathy towards other community members 29 | 30 | Examples of unacceptable behavior by participants include: 31 | 32 | * The use of sexualized language or imagery and unwelcome sexual attention or 33 | advances 34 | * Trolling, insulting/derogatory comments, and personal or political attacks 35 | * Public or private harassment 36 | * Publishing others' private information, such as a physical or electronic 37 | address, without explicit permission 38 | * Other conduct which could reasonably be considered inappropriate in a 39 | professional setting 40 | 41 | ### Our Responsibilities 42 | 43 | Project maintainers are responsible for clarifying the standards of acceptable 44 | behavior and are expected to take appropriate and fair corrective action in 45 | response to any instances of unacceptable behavior. 46 | 47 | Project maintainers have the right and responsibility to remove, edit, or 48 | reject comments, commits, code, wiki edits, issues, and other contributions 49 | that are not aligned to this Code of Conduct, or to ban temporarily or 50 | permanently any contributor for other behaviors that they deem inappropriate, 51 | threatening, offensive, or harmful. 52 | 53 | ### Scope 54 | 55 | This Code of Conduct applies both within project spaces and in public spaces 56 | when an individual is representing the project or its community. Examples of 57 | representing a project or community include using an official project e-mail 58 | address, posting via an official social media account, or acting as an appointed 59 | representative at an online or offline event. Representation of a project may be 60 | further defined and clarified by project maintainers. 61 | 62 | ### Enforcement 63 | 64 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 65 | reported by contacting the project team at stymiee@gmail.com. All 66 | complaints will be reviewed and investigated and will result in a response that 67 | is deemed necessary and appropriate to the circumstances. The project team is 68 | obligated to maintain confidentiality with regard to the reporter of an incident. 69 | Further details of specific enforcement policies may be posted separately. 70 | 71 | Project maintainers who do not follow or enforce the Code of Conduct in good 72 | faith may face temporary or permanent repercussions as determined by other 73 | members of the project's leadership. 74 | 75 | ### Attribution 76 | 77 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 78 | available at [http://contributor-covenant.org/version/1/4][version] 79 | 80 | [homepage]: http://contributor-covenant.org 81 | [version]: http://contributor-covenant.org/version/1/4/ 82 | -------------------------------------------------------------------------------- /HELP.md: -------------------------------------------------------------------------------- 1 | # Help 2 | 3 | Here are some tips, solutions to common problems, and guides for testing. 4 | 5 | ## Tips 6 | 7 | ### Create a Sandbox Account 8 | 9 | Before doing any development for the Authorize.Net suite of APIs, be sure to create a 10 | [Sandbox Account](https://developer.authorize.net/hello_world/sandbox/) with Authorize.Net. With it you can simulate 11 | virtually every aspect of the Authorize.Net production APIs without incurring any fees. 12 | 13 | ### Use a webhook testing site to test webhooks 14 | 15 | Having a full understanding of what a webhook looks like makes working with webhooks easier. You can inspect an 16 | Authorize.Net webhook using a third party service like [webhook.site](https://webhook.site/). 17 | 18 | ## FAQ 19 | 20 | Solutions to common problems when integrating the [AuthnetJSON](https://github.com/stymiee/authnetjson) library into 21 | your project. 22 | 23 | ### php://input is empty, POST is empty, webhook has no data 24 | This may happen because a redirect occurred and steps were not taken to persist that data across the redirect. 25 | Look for redirects to HTTPS or to/from the `www` subdomain in your .htaccess or web.config file. 26 | 27 | ### Class 'authnet\className' not found 28 | - This may happen if you did not include the Composer autoload.php file in your project 29 | 30 | require __DIR__.'/vendor/autoload.php'; 31 | 32 | ## Support 33 | 34 | If you require assistance using this library I can be found at Stack Overflow. Be sure when you 35 | [ask a question](http://stackoverflow.com/questions/ask?tags=php,authorize.net) pertaining to the usage of 36 | this class to tag your question with the **PHP** and **Authorize.Net** tags. Make sure you follow their 37 | [guide for asking a good question](http://stackoverflow.com/help/how-to-ask) as poorly asked questions will be closed 38 | and I will not be able to assist you. 39 | 40 | **Do not use Stack Overflow to report bugs.** Bugs may be reported [here](https://github.com/stymiee/authnetjson/issues/new). 41 | 42 | ## Helpful Links 43 | 44 | * [Authorize.Net Developer Guides](https://developer.authorize.net/api/) 45 | * [Authorize.Net Testing Guide](https://developer.authorize.net/hello_world/testing_guide/) 46 | * [Response Codes](https://developer.authorize.net/api/reference/responseCodes.html) 47 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | The following versions of AuthnetJSON are currently being supported with security updates. 6 | 7 | | Version | Supported | 8 | | ------- | ------------------ | 9 | | 4.0.x | :white_check_mark: | 10 | | 3.1.x | :white_check_mark: | 11 | | < 3.1 | :x: | 12 | 13 | ## Reporting a Vulnerability 14 | 15 | To report a security vulnerability please email me at stymiee@gmail.com. 16 | -------------------------------------------------------------------------------- /build/coverage/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stymiee/authnetjson/17546b05ef98be07cb2e32a16a578ac0b9dd47cf/build/coverage/.keep -------------------------------------------------------------------------------- /build/insights/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stymiee/authnetjson/17546b05ef98be07cb2e32a16a578ac0b9dd47cf/build/insights/.keep -------------------------------------------------------------------------------- /build/phpcs/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stymiee/authnetjson/17546b05ef98be07cb2e32a16a578ac0b9dd47cf/build/phpcs/.keep -------------------------------------------------------------------------------- /build/phpmd/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stymiee/authnetjson/17546b05ef98be07cb2e32a16a578ac0b9dd47cf/build/phpmd/.keep -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stymiee/authnetjson", 3 | "type": "library", 4 | "description": "Library that abstracts Authorize.Net's JSON APIs. This includes the Advanced Integration Method (AIM), Automated Recurring Billing (ARB), Customer Information Manager (CIM), Transaction Reporting, Simple Integration Method (SIM), and Webhooks.", 5 | "keywords": [ 6 | "PHP", 7 | "authnetjson", 8 | "Authorize.Net", 9 | "JSON", 10 | "json-api", 11 | "webhook", 12 | "capture-transaction", 13 | "authorize-net", 14 | "authorizenet", 15 | "authnet", 16 | "payment", 17 | "payment-gateway" 18 | ], 19 | "homepage": "https://github.com/stymiee/authnetjson", 20 | "license": "Apache-2.0", 21 | "authors": [ 22 | { 23 | "name": "John Conde", 24 | "email": "stymiee@gmail.com", 25 | "homepage": "https://stymiee.dev", 26 | "role": "Developer" 27 | } 28 | ], 29 | "require": { 30 | "php": ">=7.2.0", 31 | "curl/curl": "^2", 32 | "ext-curl": "*", 33 | "ext-json": "*" 34 | }, 35 | "require-dev": { 36 | "phpunit/phpunit": "^8", 37 | "squizlabs/php_codesniffer": "3.*", 38 | "phpmd/phpmd" : "@stable", 39 | "nunomaduro/phpinsights": "@stable" 40 | }, 41 | "autoload": { 42 | "psr-4": { 43 | "Authnetjson\\": [ 44 | "src/Authnetjson/" 45 | ] 46 | } 47 | }, 48 | "scripts": { 49 | "test": "phpunit", 50 | "phpcs": "php vendor/squizlabs/php_codesniffer/bin/phpcs ./src --report-file=build/phpcs/report.txt --runtime-set ignore_warnings_on_exit 1 --runtime-set ignore_errors_on_exit 1", 51 | "phpmd": "php vendor/phpmd/phpmd/src/bin/phpmd src/ html cleancode --reportfile build/phpmd/report.html --ignore-violations-on-exit", 52 | "insights": ".\\vendor\\bin\\phpinsights.bat analyse src --format=console > build/insights/report.txt" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /config.inc.php.dist: -------------------------------------------------------------------------------- 1 | getHostedProfilePageRequest([ 65 | "customerProfileId" => "1511887405", 66 | "hostedProfileSettings" => [ 67 | "setting" => [[ 68 | "settingName" => "hostedProfileReturnUrl", 69 | "settingValue" => "https://returnurl.com/return/" 70 | ], [ 71 | "settingName" => "hostedProfileReturnUrlText", 72 | "settingValue" => "Continue to confirmation page." 73 | ], [ 74 | "settingName" => "hostedProfilePageBorderVisible", 75 | "settingValue" => "true" 76 | ]] 77 | ] 78 | ]); 79 | } catch (Exception $e) { 80 | echo $e; 81 | exit; 82 | } 83 | ?> 84 | 85 | 86 | 87 | 88 | 89 | Hosted Accept.js Payment Form 90 | 91 | 92 |
93 | 94 | 95 |
96 | 97 | 98 | -------------------------------------------------------------------------------- /examples/aim/authenticateTestRequest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /************************************************************************************************* 13 | 14 | Use the AIM JSON API to process an Authorization and Capture transaction (Sale) 15 | 16 | SAMPLE REQUEST 17 | -------------------------------------------------------------------------------------------------- 18 | { 19 | "createTransactionRequest":{ 20 | "merchantAuthentication":{ 21 | "name":"5KP3u95bQpv", 22 | "transactionKey":"346HZ32z3fP4hTG2" 23 | } 24 | } 25 | } 26 | 27 | SAMPLE RESPONSE 28 | -------------------------------------------------------------------------------------------------- 29 | { 30 | "messages": { 31 | "resultCode": "Ok", 32 | "message": [ 33 | { 34 | "code": "I00001", 35 | "text": "Successful." 36 | } 37 | ] 38 | } 39 | 40 | *************************************************************************************************/ 41 | 42 | namespace Authnetjson; 43 | 44 | use Exception; 45 | 46 | require '../../config.inc.php'; 47 | 48 | try { 49 | $request = AuthnetApiFactory::getJsonApiHandler( 50 | AUTHNET_LOGIN, 51 | AUTHNET_TRANSKEY, 52 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 53 | ); 54 | $response = $request->authenticateTestRequest(); 55 | } catch (Exception $e) { 56 | echo $e; 57 | exit; 58 | } 59 | ?> 60 | 61 | 62 | 63 | 64 | Authenticate Credentials 65 | 72 | 73 | 74 |

75 | Payment :: Authorize and Capture (AUTH_CAPTURE) 76 |

77 |

78 | Results 79 |

80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | isError()) : ?> 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 |
Responsemessages->resultCode ?>
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Error CodegetErrorCode() ?>
Error MessagegetErrorText() ?>
104 |

105 | Raw Input/Output 106 |

107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /examples/aim/createTransactionRequest_paypalAuthOnly.php: -------------------------------------------------------------------------------- 1 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | /************************************************************************************************* 14 | 15 | Use the AIM JSON API to process an Auth Only transaction through Paypal 16 | 17 | SAMPLE REQUEST 18 | -------------------------------------------------------------------------------------------------- 19 | { 20 | "createTransactionRequest": { 21 | "merchantAuthentication": { 22 | "name": "cnpdev4289", 23 | "transactionKey": "SR2P8g4jdEn7vFLQ" 24 | }, 25 | "transactionRequest": { 26 | "transactionType": "authOnlyTransaction", 27 | "amount": "5", 28 | "payment": { 29 | "payPal": { 30 | "successUrl": "https://my.server.com/success.html", 31 | "cancelUrl": "https://my.server.com/cancel.html" 32 | } 33 | } 34 | } 35 | } 36 | } 37 | 38 | SAMPLE RESPONSE 39 | -------------------------------------------------------------------------------------------------- 40 | { 41 | "transactionResponse": { 42 | "responseCode": "5", 43 | "rawResponseCode": "0", 44 | "transId": "2149186954", 45 | "refTransID": "", 46 | "transHash": "A719785EE9752530FDCE67695E9A56EE", 47 | "testRequest": "0", 48 | "accountType": "PayPal", 49 | "messages": [ 50 | { 51 | "code": "2000", 52 | "description": "Need payer consent." 53 | } 54 | ], 55 | "secureAcceptance": { 56 | "SecureAcceptanceUrl": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-C506B0LGTG2J800OK" 57 | } 58 | }, 59 | "messages": { 60 | "resultCode": "Ok", 61 | "message": [ 62 | { 63 | "code": "I00001", 64 | "text": "Successful." 65 | } 66 | ] 67 | } 68 | } 69 | 70 | *************************************************************************************************/ 71 | 72 | namespace Authnetjson; 73 | 74 | use Exception; 75 | 76 | require '../../config.inc.php'; 77 | 78 | try { 79 | $request = AuthnetApiFactory::getJsonApiHandler( 80 | AUTHNET_LOGIN, 81 | AUTHNET_TRANSKEY, 82 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 83 | ); 84 | $response = $request->createTransactionRequest([ 85 | 'transactionRequest' => [ 86 | 'transactionType' => 'authOnlyTransaction', 87 | 'amount' => 5, 88 | 'payment' => [ 89 | 'payPal' => [ 90 | 'successUrl' => 'https://my.server.com/success.html', 91 | 'cancelUrl' => 'https://my.server.com/cancel.html' 92 | ] 93 | ] 94 | ] 95 | ]); 96 | } catch (Exception $e) { 97 | echo $e; 98 | exit; 99 | } 100 | ?> 101 | 102 | 103 | 104 | 105 | Payment :: Paypal :: Authorize Only 106 | 113 | 114 | 115 |

116 | Payment :: Paypal :: Authorize Only 117 |

118 |

119 | Results 120 |

121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | isSuccessful()) : ?> 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | isError()) : ?> 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 |
Responsemessages->resultCode ?>
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
DescriptiontransactionResponse->messages[0]->description ?>
Authorization CodetransactionResponse->authCode ?>
Transaction IDtransactionResponse->transId ?>
Reference Transaction IDtransactionResponse->refTransID ?>
Transaction HashtransactionResponse->transHash ?>
Is Test Request?transactionResponse->testRequest ? 'yes' : 'no' ?>
Account TypetransactionResponse->accountType ?>
Error CodegetErrorCode() ?>
Error MessagegetErrorText() ?>
174 |

175 | Raw Input/Output 176 |

177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /examples/aim/createTransactionRequest_paypalGetDetails.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /************************************************************************************************* 13 | 14 | Use the AIM JSON API to process a Get Details transaction through Paypal 15 | 16 | SAMPLE REQUEST 17 | -------------------------------------------------------------------------------------------------- 18 | { 19 | "createTransactionRequest": { 20 | "merchantAuthentication": { 21 | "name": "cnpdev4289", 22 | "transactionKey": "SR2P8g4jdEn7vFLQ" 23 | }, 24 | "transactionRequest": { 25 | "transactionType": "getDetailsTransaction", 26 | "refTransId": "128" 27 | } 28 | } 29 | } 30 | 31 | SAMPLE RESPONSE 32 | -------------------------------------------------------------------------------------------------- 33 | { 34 | "transactionResponse": { 35 | "responseCode": "1", 36 | "authCode": "HH5414", 37 | "avsResultCode": "P", 38 | "cvvResultCode": "", 39 | "cavvResultCode": "", 40 | "transId": "2149186848", 41 | "refTransID": "2149186848", 42 | "transHash": "D3A855F0934EB404DE3B13508D0E3826", 43 | "testRequest": "0", 44 | "accountNumber": "XXXX0015", 45 | "accountType": "MasterCard", 46 | "messages": [ 47 | { 48 | "code": "1", 49 | "description": "This transaction has been approved." 50 | } 51 | ] 52 | }, 53 | "refId": "123456", 54 | "messages": { 55 | "resultCode": "Ok", 56 | "message": [ 57 | { 58 | "code": "I00001", 59 | "text": "Successful." 60 | } 61 | ] 62 | } 63 | } 64 | 65 | *************************************************************************************************/ 66 | 67 | namespace Authnetjson; 68 | 69 | use Exception; 70 | 71 | require '../../config.inc.php'; 72 | 73 | try { 74 | $request = AuthnetApiFactory::getJsonApiHandler( 75 | AUTHNET_LOGIN, 76 | AUTHNET_TRANSKEY, 77 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 78 | ); 79 | $response = $request->createTransactionRequest([ 80 | 'transactionRequest' => [ 81 | 'transactionType' => 'getDetailsTransaction', 82 | 'refTransId' => '128' 83 | ] 84 | ]); 85 | } catch (Exception $e) { 86 | echo $e; 87 | exit; 88 | } 89 | ?> 90 | 91 | 92 | 93 | 94 | Payment :: Paypal :: Get Details 95 | 102 | 103 | 104 |

105 | Payment :: Paypal :: Get Details 106 |

107 |

108 | Results 109 |

110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | isSuccessful()) : ?> 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | isError()) : ?> 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 |
Responsemessages->resultCode ?>
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
DescriptiontransactionResponse->messages[0]->description ?>
Authorization CodetransactionResponse->authCode ?>
Transaction IDtransactionResponse->transId ?>
Reference Transaction IDtransactionResponse->refTransID ?>
Transaction HashtransactionResponse->transHash ?>
AVS Result CodetransactionResponse->avsResultCode ?>
CVV Result CodetransactionResponse->cvvResultCode ?>
CAVV Result CodetransactionResponse->cavvResultCode ?>
Is Test Request?transactionResponse->testRequest ? 'yes' : 'no' ?>
Account TypetransactionResponse->accountType ?>
Error CodegetErrorCode() ?>
Error MessagegetErrorText() ?>
175 |

176 | Raw Input/Output 177 |

178 | 179 | 180 | 181 | -------------------------------------------------------------------------------- /examples/aim/createTransactionRequest_paypalRefund.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /************************************************************************************************* 13 | 14 | Use the AIM JSON API to process a Credit transaction through Paypal 15 | 16 | SAMPLE REQUEST 17 | -------------------------------------------------------------------------------------------------- 18 | { 19 | "createTransactionRequest": { 20 | "merchantAuthentication": { 21 | "name": "cnpdev4289", 22 | "transactionKey": "SR2P8g4jdEn7vFLQ" 23 | }, 24 | "transactionRequest": { 25 | "transactionType": "refundTransaction", 26 | "refTransId": "138" 27 | } 28 | } 29 | } 30 | 31 | SAMPLE RESPONSE 32 | -------------------------------------------------------------------------------------------------- 33 | { 34 | "transactionResponse": { 35 | "responseCode": "1", 36 | "transId": "2149186848", 37 | "refTransID": "2149186775", 38 | "transHash": "D6C9036F443BADE785D57DA2B44CD190", 39 | "testRequest": "0", 40 | "accountType": "PayPal", 41 | "messages": [ 42 | { 43 | "code": "1", 44 | "description": "This transaction has been approved." 45 | } 46 | ] 47 | }, 48 | "refId": "123456", 49 | "messages": { 50 | "resultCode": "Ok", 51 | "message": [ 52 | { 53 | "code": "I00001", 54 | "text": "Successful." 55 | } 56 | ] 57 | } 58 | } 59 | 60 | *************************************************************************************************/ 61 | 62 | namespace Authnetjson; 63 | 64 | use Exception; 65 | 66 | require '../../config.inc.php'; 67 | 68 | try { 69 | $request = AuthnetApiFactory::getJsonApiHandler( 70 | AUTHNET_LOGIN, 71 | AUTHNET_TRANSKEY, 72 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 73 | ); 74 | $response = $request->createTransactionRequest([ 75 | 'transactionRequest' => [ 76 | 'transactionType' => 'refundTransaction', 77 | 'refTransId' => '138' 78 | ] 79 | ]); 80 | } catch (Exception $e) { 81 | echo $e; 82 | exit; 83 | } 84 | ?> 85 | 86 | 87 | 88 | 89 | Payment :: Paypal :: Refund 90 | 97 | 98 | 99 |

100 | Payment :: Paypal :: Refund 101 |

102 |

103 | Results 104 |

105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | isSuccessful()) : ?> 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | isError()) : ?> 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 |
Responsemessages->resultCode ?>
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
DescriptiontransactionResponse->messages[0]->description ?>
Authorization CodetransactionResponse->authCode ?>
Transaction IDtransactionResponse->transId ?>
Reference Transaction IDtransactionResponse->refTransID ?>
Transaction HashtransactionResponse->transHash ?>
Account TypetransactionResponse->accountType ?>
Error CodegetErrorCode() ?>
Error MessagegetErrorText() ?>
154 |

155 | Raw Input/Output 156 |

157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /examples/aim/createTransactionRequest_paypalVoid.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /************************************************************************************************* 13 | 14 | Use the AIM JSON API to process a Void transaction through Paypal 15 | 16 | SAMPLE REQUEST 17 | -------------------------------------------------------------------------------------------------- 18 | { 19 | "createTransactionRequest": { 20 | "merchantAuthentication": { 21 | "name": "cnpdev4289", 22 | "transactionKey": "SR2P8g4jdEn7vFLQ" 23 | }, 24 | "transactionRequest": { 25 | "transactionType": "voidTransaction", 26 | "refTransId": "138" 27 | } 28 | } 29 | } 30 | 31 | SAMPLE RESPONSE 32 | -------------------------------------------------------------------------------------------------- 33 | { 34 | "transactionResponse": { 35 | "responseCode": "1", 36 | "authCode": "HH5414", 37 | "avsResultCode": "P", 38 | "cvvResultCode": "", 39 | "cavvResultCode": "", 40 | "transId": "2149186848", 41 | "refTransID": "2149186848", 42 | "transHash": "D3A855F0934EB404DE3B13508D0E3826", 43 | "testRequest": "0", 44 | "accountNumber": "XXXX0015", 45 | "accountType": "MasterCard", 46 | "messages": [ 47 | { 48 | "code": "1", 49 | "description": "This transaction has been approved." 50 | } 51 | ] 52 | }, 53 | "refId": "123456", 54 | "messages": { 55 | "resultCode": "Ok", 56 | "message": [ 57 | { 58 | "code": "I00001", 59 | "text": "Successful." 60 | } 61 | ] 62 | } 63 | } 64 | 65 | *************************************************************************************************/ 66 | 67 | namespace Authnetjson; 68 | 69 | use Exception; 70 | 71 | require '../../config.inc.php'; 72 | 73 | try { 74 | $request = AuthnetApiFactory::getJsonApiHandler( 75 | AUTHNET_LOGIN, 76 | AUTHNET_TRANSKEY, 77 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 78 | ); 79 | $response = $request->createTransactionRequest([ 80 | 'transactionRequest' => [ 81 | 'transactionType' => 'voidTransaction', 82 | 'refTransId' => '138' 83 | ] 84 | ]); 85 | } catch (Exception $e) { 86 | echo $e; 87 | exit; 88 | } 89 | ?> 90 | 91 | 92 | 93 | 94 | Payment :: Paypal :: Void 95 | 102 | 103 | 104 |

105 | Payment :: Paypal :: Void 106 |

107 |

108 | Results 109 |

110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | isSuccessful()) : ?> 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | isError()) : ?> 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 |
Responsemessages->resultCode ?>
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
DescriptiontransactionResponse->messages[0]->description ?>
Authorization CodetransactionResponse->authCode ?>
Transaction IDtransactionResponse->transId ?>
Reference Transaction IDtransactionResponse->refTransID ?>
Transaction HashtransactionResponse->transHash ?>
AVS Result CodetransactionResponse->avsResultCode ?>
CVV Result CodetransactionResponse->cvvResultCode ?>
CAVV Result CodetransactionResponse->cavvResultCode ?>
Is Test Request?transactionResponse->testRequest ? 'yes' : 'no' ?>
Account TypetransactionResponse->accountType ?>
Error CodegetErrorCode() ?>
Error MessagegetErrorText() ?>
175 |

176 | Raw Input/Output 177 |

178 | 179 | 180 | 181 | -------------------------------------------------------------------------------- /examples/aim/createTransactionRequest_priorAuthCapture.php: -------------------------------------------------------------------------------- 1 | createTransactionRequest([ 71 | 'refId' => random_int(1000000, 100000000), 72 | 'transactionRequest' => [ 73 | 'transactionType' => 'priorAuthCaptureTransaction', 74 | 'refTransId' => '2230581333' 75 | ], 76 | ]); 77 | } catch (Exception $e) { 78 | echo $e; 79 | exit; 80 | } 81 | ?> 82 | 83 | 84 | 85 | 86 | Payment :: Prior Authorization Capture 87 | 94 | 95 | 96 |

97 | Payment :: Prior Authorization Capture 98 |

99 |

100 | Results 101 |

102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | isSuccessful()) : ?> 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | isError()) : ?> 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 |
Responsemessages->resultCode ?>
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
DescriptiontransactionResponse->messages[0]->description ?>
Authorization CodetransactionResponse->authCode ?>
Transaction IDtransactionResponse->transId ?>
Reference Transaction IDtransactionResponse->refTransID ?>
Transaction HashtransactionResponse->transHash ?>
AVS Result CodetransactionResponse->avsResultCode ?>
CVV Result CodetransactionResponse->cvvResultCode ?>
CAVV Result CodetransactionResponse->cavvResultCode ?>
Is Test Request?transactionResponse->testRequest ? 'yes' : 'no' ?>
Account TypetransactionResponse->accountType ?>
Error CodegetErrorCode() ?>
Error MessagegetErrorText() ?>
167 |

168 | Raw Input/Output 169 |

170 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /examples/aim/createTransactionRequest_void.php: -------------------------------------------------------------------------------- 1 | createTransactionRequest([ 71 | 'refId' => random_int(1000000, 100000000), 72 | 'transactionRequest' => [ 73 | 'transactionType' => 'voidTransaction', 74 | 'refTransId' => '2230581408' 75 | ], 76 | ]); 77 | } catch (Exception $e) { 78 | echo $e; 79 | exit; 80 | } 81 | ?> 82 | 83 | 84 | 85 | 86 | Payment :: Void 87 | 94 | 95 | 96 |

97 | Payment :: Void 98 |

99 |

100 | Results 101 |

102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | isSuccessful()) : ?> 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | isError()) : ?> 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 |
Responsemessages->resultCode ?>
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
DescriptiontransactionResponse->messages[0]->description ?>
Authorization CodetransactionResponse->authCode ?>
Transaction IDtransactionResponse->transId ?>
Reference Transaction IDtransactionResponse->refTransID ?>
Transaction HashtransactionResponse->transHash ?>
AVS Result CodetransactionResponse->avsResultCode ?>
CVV Result CodetransactionResponse->cvvResultCode ?>
CAVV Result CodetransactionResponse->cavvResultCode ?>
Is Test Request?transactionResponse->testRequest ? 'yes' : 'no' ?>
Account TypetransactionResponse->accountType ?>
Error CodegetErrorCode() ?>
Error MessagegetErrorText() ?>
167 |

168 | Raw Input/Output 169 |

170 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /examples/aim/sendCustomerTransactionReceiptRequest.php: -------------------------------------------------------------------------------- 1 | sendCustomerTransactionReceiptRequest([ 56 | 'refId' => random_int(1000000, 100000000), 57 | 'transId' => '2165665581', 58 | 'customerEmail' => 'user@example.com', 59 | 'emailSettings' => [ 60 | [ 61 | 'settingName' => 'headerEmailReceipt', 62 | 'settingValue' => 'some HEADER stuff' 63 | ], 64 | ], 65 | ]); 66 | } catch (Exception $e) { 67 | echo $e; 68 | exit; 69 | } 70 | ?> 71 | 72 | 73 | 74 | 75 | Payment :: Receipt Request 76 | 83 | 84 | 85 |

86 | Payment :: Receipt Request 87 |

88 |

89 | Results 90 |

91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | isSuccessful()) : ?> 105 | 106 | 107 | 108 | 109 | isError()) : ?> 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 |
Responsemessages->resultCode ?>
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Reference Transaction IDtransactionResponse->refTransID ?>
Error CodegetErrorCode() ?>
Error MessagegetErrorText() ?>
120 |

121 | Raw Input/Output 122 |

123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /examples/arb/ARBCancelSubscriptionRequest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /************************************************************************************************* 13 | 14 | Use the ARB XML API to cancel a subscription 15 | 16 | SAMPLE REQUEST 17 | -------------------------------------------------------------------------------------------------- 18 | { 19 | "ARBCancelSubscriptionRequest":{ 20 | "merchantAuthentication":{ 21 | "name":"", 22 | "transactionKey":"" 23 | }, 24 | "refId":"Sample", 25 | "subscriptionId":"2341621" 26 | } 27 | } 28 | 29 | SAMPLE RESPONSE 30 | -------------------------------------------------------------------------------------------------- 31 | { 32 | "refId":"Sample", 33 | "messages":{ 34 | "resultCode":"Ok", 35 | "message":[ 36 | { 37 | "code":"I00001", 38 | "text":"Successful." 39 | } 40 | ] 41 | } 42 | } 43 | 44 | *************************************************************************************************/ 45 | 46 | namespace Authnetjson; 47 | 48 | use Exception; 49 | 50 | require '../../config.inc.php'; 51 | 52 | try { 53 | $request = AuthnetApiFactory::getJsonApiHandler( 54 | AUTHNET_LOGIN, 55 | AUTHNET_TRANSKEY, 56 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 57 | ); 58 | $response = $request->ARBCancelSubscriptionRequest([ 59 | 'refId' => 'Sample', 60 | 'subscriptionId' => '2341621' 61 | ]); 62 | } catch (Exception $e) { 63 | echo $e; 64 | exit; 65 | } 66 | ?> 67 | 68 | 69 | 70 | 71 | ARB :: Cancel Subscription 72 | 79 | 80 | 81 |

82 | ARB :: Cancel Subscription 83 |

84 |

85 | Results 86 |

87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
109 |

110 | Raw Input/Output 111 |

112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /examples/arb/ARBCreateSubscriptionRequest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /************************************************************************************************* 13 | 14 | Use the ARB JSON API to create a subscription 15 | 16 | SAMPLE REQUEST 17 | -------------------------------------------------------------------------------------------------- 18 | { 19 | "ARBCreateSubscriptionRequest":{ 20 | "merchantAuthentication":{ 21 | "name":"", 22 | "transactionKey":"" 23 | }, 24 | "refId":"Sample", 25 | "subscription":{ 26 | "name":"Sample subscription", 27 | "paymentSchedule":{ 28 | "interval":{ 29 | "length":"1", 30 | "unit":"months" 31 | }, 32 | "startDate":"2012-03-15", 33 | "totalOccurrences":"12", 34 | "trialOccurrences":"1" 35 | }, 36 | "amount":"10.29", 37 | "trialAmount":"0.00", 38 | "payment":{ 39 | "creditCard":{ 40 | "cardNumber":"4111111111111111", 41 | "expirationDate":"2016-08" 42 | } 43 | }, 44 | "billTo":{ 45 | "firstName":"John", 46 | "lastName":"Smith" 47 | } 48 | } 49 | } 50 | } 51 | 52 | SAMPLE RESPONSE 53 | -------------------------------------------------------------------------------------------------- 54 | { 55 | "subscriptionId":"2341621", 56 | "refId":"Sample", 57 | "messages":{ 58 | "resultCode":"Ok", 59 | "message":[ 60 | { 61 | "code":"I00001", 62 | "text":"Successful." 63 | } 64 | ] 65 | } 66 | } 67 | 68 | *************************************************************************************************/ 69 | 70 | namespace Authnetjson; 71 | 72 | use Exception; 73 | 74 | require '../../config.inc.php'; 75 | 76 | try { 77 | $request = AuthnetApiFactory::getJsonApiHandler( 78 | AUTHNET_LOGIN, 79 | AUTHNET_TRANSKEY, 80 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 81 | ); 82 | $response = $request->ARBCreateSubscriptionRequest([ 83 | 'refId' => 'Sample', 84 | 'subscription' => [ 85 | 'name' => 'Sample subscription', 86 | 'paymentSchedule' => [ 87 | 'interval' => [ 88 | 'length' => '1', 89 | 'unit' => 'months' 90 | ], 91 | 'startDate' => '2015-04-18', 92 | 'totalOccurrences' => AuthnetJson::BOUNDLESS_OCCURRENCES, 93 | 'trialOccurrences' => '1' 94 | ], 95 | 'amount' => '10.29', 96 | 'trialAmount' => '0.00', 97 | 'payment' => [ 98 | 'creditCard' => [ 99 | 'cardNumber' => '4111111111111111', 100 | 'expirationDate' => '2016-08' 101 | ] 102 | ], 103 | 'billTo' => [ 104 | 'firstName' => 'John', 105 | 'lastName' => 'Smith' 106 | ] 107 | ] 108 | ]); 109 | } catch (Exception $e) { 110 | echo $e; 111 | exit; 112 | } 113 | ?> 114 | 115 | 116 | 117 | 118 | ARB :: Create Subscription 119 | 126 | 127 | 128 |

129 | ARB :: Create Subscription 130 |

131 |

132 | Results 133 |

134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
Subscription IDsubscriptionId ?>
160 |

161 | Raw Input/Output 162 |

163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /examples/arb/ARBCreateSubscriptionRequestFromProfile.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /************************************************************************************************* 13 | 14 | This request enables you to create a recurring billing subscription from an existing customer profile. NOTE: The 15 | customer payment profile first and last name fields must be populated, these are required for a subscription. 16 | For subscriptions with a monthly interval, whose payments begin on the 31st of a month, payments for months with 17 | fewer than 31 days occur on the last day of the month. 18 | 19 | SAMPLE REQUEST 20 | -------------------------------------------------------------------------------------------------- 21 | { 22 | "ARBCreateSubscriptionRequest": { 23 | "merchantAuthentication": { 24 | "name": "", 25 | "transactionKey": "" 26 | }, 27 | "refId": "123456", 28 | "subscription": { 29 | "name": "Sample subscription", 30 | "paymentSchedule": { 31 | "interval": { 32 | "length": "1", 33 | "unit": "months" 34 | }, 35 | "startDate": "2020-08-30", 36 | "totalOccurrences": "12", 37 | "trialOccurrences": "1" 38 | }, 39 | "amount": "10.29", 40 | "trialAmount": "0.00", 41 | "profile": { 42 | "customerProfileId": "39931060", 43 | "customerPaymentProfileId": "36223863", 44 | "customerAddressId": "37726371" 45 | } 46 | } 47 | } 48 | } 49 | 50 | SAMPLE RESPONSE 51 | -------------------------------------------------------------------------------------------------- 52 | { 53 | "subscriptionId": "158383", 54 | profile": { 55 | "customerProfileId": "39931060", 56 | "customerPaymentProfileId": "36223863", 57 | "customerAddressId": "37726371" 58 | }, 59 | "refId": "123456", 60 | "messages": { 61 | "resultCode": "Ok", 62 | "message": [ 63 | { 64 | "code": "I00001", 65 | "text": "Successful." 66 | } 67 | ] 68 | } 69 | } 70 | 71 | *************************************************************************************************/ 72 | 73 | namespace Authnetjson; 74 | 75 | use Exception; 76 | 77 | require '../../config.inc.php'; 78 | 79 | try { 80 | $request = AuthnetApiFactory::getJsonApiHandler( 81 | AUTHNET_LOGIN, 82 | AUTHNET_TRANSKEY, 83 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 84 | ); 85 | $response = $request->ARBCreateSubscriptionRequest([ 86 | 'refId' => 'Sample', 87 | 'subscription' => [ 88 | 'name' => 'Sample subscription', 89 | 'paymentSchedule' => [ 90 | 'interval' => [ 91 | 'length' => '1', 92 | 'unit' => 'months' 93 | ], 94 | 'startDate' => '2020-07-15', 95 | 'totalOccurrences' => AuthnetJson::BOUNDLESS_OCCURRENCES, 96 | 'trialOccurrences' => '1' 97 | ], 98 | 'amount' => '10.29', 99 | 'trialAmount' => '0.00', 100 | 'profile' => [ 101 | 'customerProfileId' => '1512256927', 102 | 'customerPaymentProfileId' => '1512285006', 103 | ] 104 | ] 105 | ]); 106 | } catch (Exception $e) { 107 | echo $e; 108 | exit; 109 | } 110 | ?> 111 | 112 | 113 | 114 | 115 | ARB :: Create Subscription from Customer Profile 116 | 123 | 124 | 125 |

126 | ARB :: Create Subscription from Customer Profile 127 |

128 |

129 | Results 130 |

131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 163 | 164 |
Responsemessages->resultCode ?>
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
Subscription IDsubscriptionId ?>
Profile 159 | Customer Profile Id: profile->customerProfileId ?>
160 | Customer PaymentProfile Id: profile->customerPaymentProfileId ?>
161 | Customer Address Id: profile->customerAddressId ?>
162 |
165 |

166 | Raw Input/Output 167 |

168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /examples/arb/ARBGetSubscriptionStatusRequest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /************************************************************************************************* 13 | 14 | Use the ARB API to get a subscription's status 15 | 16 | SAMPLE REQUEST 17 | -------------------------------------------------------------------------------------------------- 18 | { 19 | "ARBGetSubscriptionStatusRequest":{ 20 | "merchantAuthentication":{ 21 | "name":"", 22 | "transactionKey":"" 23 | }, 24 | "refId":"Sample", 25 | "subscriptionId":"1207505" 26 | } 27 | } 28 | 29 | SAMPLE RESPONSE 30 | -------------------------------------------------------------------------------------------------- 31 | { 32 | "note":"Status with a capital 'S' is obsolete.", 33 | "status":"canceled", 34 | "Status":"canceled", 35 | "statusSpecified":true, 36 | "StatusSpecified":true, 37 | "refId":"Sample", 38 | "messages":{ 39 | "resultCode":"Ok", 40 | "message":[ 41 | { 42 | "code":"I00001", 43 | "text":"Successful." 44 | } 45 | ] 46 | } 47 | } 48 | 49 | *************************************************************************************************/ 50 | 51 | namespace Authnetjson; 52 | 53 | use Exception; 54 | 55 | require '../../config.inc.php'; 56 | 57 | try { 58 | $request = AuthnetApiFactory::getJsonApiHandler( 59 | AUTHNET_LOGIN, 60 | AUTHNET_TRANSKEY, 61 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 62 | ); 63 | $response = $request->ARBGetSubscriptionStatusRequest([ 64 | 'refId' => 'Sample', 65 | 'subscriptionId' => '1207505' 66 | ]); 67 | } catch (Exception $e) { 68 | echo $e; 69 | exit; 70 | } 71 | ?> 72 | 73 | 74 | 75 | 76 | ARB :: Get Subscription Status 77 | 84 | 85 | 86 |

87 | ARB :: Get Subscription Status 88 |

89 |

90 | Results 91 |

92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 |
Responsemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Message Textmessages->message[0]->text ?>
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Reference IDrefId ?>
Statusstatus ?>
Status SpecifiedstatusSpecified ?>
126 |

127 | Raw Input/Output 128 |

129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /examples/arb/ARBUpdateSubscriptionRequest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /************************************************************************************************* 13 | 14 | Use the ARB JSON API to update a subscription 15 | 16 | SAMPLE REQUEST 17 | -------------------------------------------------------------------------------------------------- 18 | { 19 | "ARBUpdateSubscriptionRequest":{ 20 | "merchantAuthentication":{ 21 | "name":"", 22 | "transactionKey":"" 23 | }, 24 | "refId":"Sample", 25 | "subscriptionId":"2342682", 26 | "subscription":{ 27 | "payment":{ 28 | "creditCard":{ 29 | "cardNumber":"6011000000000012", 30 | "expirationDate":"2016-08" 31 | } 32 | } 33 | } 34 | } 35 | } 36 | 37 | SAMPLE RESPONSE 38 | -------------------------------------------------------------------------------------------------- 39 | { 40 | "refId":"Sample", 41 | "messages":{ 42 | "resultCode":"Ok", 43 | "message":[ 44 | { 45 | "code":"I00001", 46 | "text":"Successful." 47 | } 48 | ] 49 | } 50 | } 51 | 52 | *************************************************************************************************/ 53 | 54 | namespace Authnetjson; 55 | 56 | use Exception; 57 | 58 | require '../../config.inc.php'; 59 | 60 | try { 61 | $request = AuthnetApiFactory::getJsonApiHandler( 62 | AUTHNET_LOGIN, 63 | AUTHNET_TRANSKEY, 64 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 65 | ); 66 | $response = $request->ARBUpdateSubscriptionRequest([ 67 | 'refId' => 'Sample', 68 | 'subscriptionId' => '2342682', 69 | 'subscription' => [ 70 | 'payment' => [ 71 | 'creditCard' => [ 72 | 'cardNumber' => '6011000000000012', 73 | 'expirationDate' => '2016-08' 74 | ], 75 | ], 76 | ], 77 | ]); 78 | } catch (Exception $e) { 79 | echo $e; 80 | exit; 81 | } 82 | ?> 83 | 84 | 85 | 86 | 87 | ARB :: Update Subscription 88 | 95 | 96 | 97 |

98 | ARB :: Update Subscription 99 |

100 |

101 | Results 102 |

103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
Reference IDrefId ?>
129 |

130 | Raw Input/Output 131 |

132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /examples/cim/createCustomerPaymentProfileRequest.php: -------------------------------------------------------------------------------- 1 | createCustomerPaymentProfileRequest([ 71 | 'customerProfileId' => '30582495', 72 | 'paymentProfile' => [ 73 | 'billTo' => [ 74 | 'firstName' => 'John', 75 | 'lastName' => 'Doe', 76 | 'company' => '', 77 | 'address' => '123 Main St.', 78 | 'city' => 'Bellevue', 79 | 'state' => 'WA', 80 | 'zip' => '98004', 81 | 'country' => 'USA', 82 | 'phoneNumber' => '800-555-1234', 83 | 'faxNumber' => '800-555-1234' 84 | ], 85 | 'payment' => [ 86 | 'creditCard' => [ 87 | 'cardNumber' => '4111111111111111', 88 | 'expirationDate' => '2026-08' 89 | ] 90 | ] 91 | ], 92 | 'validationMode' => 'liveMode' 93 | ]); 94 | } catch (Exception $e) { 95 | echo $e; 96 | exit; 97 | } 98 | ?> 99 | 100 | 101 | 102 | 103 | CIM :: Create Payment Profile 104 | 111 | 112 | 113 |

114 | CIM :: Create Payment Profile 115 |

116 |

117 | Results 118 |

119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | isSuccessful()) : ?> 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
customerProfileIdcustomerPaymentProfileId ?>
Transaction Approved?isApproved()) ? 'yes' : 'no' ?>
Authorization CodegetTransactionResponseField('AuthorizationCode') ?>
AVS ResponsegetTransactionResponseField('AVSResponse') ?>
Transaction IDgetTransactionResponseField('TransactionID') ?>
163 |

164 | Raw Input/Output 165 |

166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /examples/cim/createCustomerProfileTransactionRequest_void.php: -------------------------------------------------------------------------------- 1 | createCustomerProfileTransactionRequest([ 56 | 'transaction' => [ 57 | 'profileTransVoid' => [ 58 | 'customerProfileId' => '31390172', 59 | 'customerPaymentProfileId' => '28393490', 60 | 'customerShippingAddressId' => '29366174', 61 | 'transId' => '2230582868' 62 | ] 63 | ], 64 | 'extraOptions' => 'x_customer_ip=100.0.0.1' 65 | ]); 66 | } catch (Exception $e) { 67 | echo $e; 68 | exit; 69 | } 70 | ?> 71 | 72 | 73 | 74 | 75 | CIM :: Void 76 | 83 | 84 | 85 |

86 | CIM :: Void 87 |

88 |

89 | Results 90 |

91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
Transaction Approved?isApproved()) ? 'yes' : 'no' ?>
Authorization CodegetTransactionResponseField('AuthorizationCode') ?>
AVS ResponsegetTransactionResponseField('AVSResponse') ?>
Transaction IDgetTransactionResponseField('TransactionID') ?>
129 |

130 | Raw Input/Output 131 |

132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /examples/cim/createCustomerShippingAddressRequest.php: -------------------------------------------------------------------------------- 1 | createCustomerShippingAddressRequest([ 60 | 'customerProfileId' => '31390172', 61 | 'address' => [ 62 | 'firstName' => 'John', 63 | 'lastName' => 'Doe', 64 | 'company' => '', 65 | 'address' => '123 Main St.', 66 | 'city' => 'Bellevue', 67 | 'state' => 'WA', 68 | 'zip' => '98004', 69 | 'country' => 'USA', 70 | 'phoneNumber' => '800-555-1234', 71 | 'faxNumber' => '800-555-1234' 72 | ] 73 | ]); 74 | } catch (Exception $e) { 75 | echo $e; 76 | exit; 77 | } 78 | ?> 79 | 80 | 81 | 82 | 83 | CIM :: Create Shipping Profile 84 | 91 | 92 | 93 |

94 | CIM :: Create Shipping Profile 95 |

96 |

97 | Results 98 |

99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | isSuccessful()) : ?> 121 | 122 | 123 | 124 | 125 | 126 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
Customer Address IDcustomerAddressId ?>
127 |

128 | Raw Input/Output 129 |

130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /examples/cim/deleteCustomerPaymentProfileRequest.php: -------------------------------------------------------------------------------- 1 | deleteCustomerPaymentProfileRequest([ 48 | 'customerProfileId' => '31390172', 49 | 'customerPaymentProfileId' => '28393490' 50 | ]); 51 | } catch (Exception $e) { 52 | echo $e; 53 | exit; 54 | } 55 | ?> 56 | 57 | 58 | 59 | 60 | CIM :: Delete Payment Profile 61 | 68 | 69 | 70 |

71 | CIM :: Delete Payment Profile 72 |

73 |

74 | Results 75 |

76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
98 |

99 | Raw Input/Output 100 |

101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /examples/cim/deleteCustomerProfileRequest.php: -------------------------------------------------------------------------------- 1 | deleteCustomerProfileRequest([ 47 | 'customerProfileId' => '31390172' 48 | ]); 49 | } catch (Exception $e) { 50 | echo $e; 51 | exit; 52 | } 53 | ?> 54 | 55 | 56 | 57 | 58 | CIM :: Delete Customer Profile 59 | 66 | 67 | 68 |

69 | CIM :: Delete Customer Profile 70 |

71 |

72 | Results 73 |

74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
96 |

97 | Raw Input/Output 98 |

99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /examples/cim/deleteCustomerShippingAddressRequest.php: -------------------------------------------------------------------------------- 1 | deleteCustomerShippingAddressRequest([ 48 | 'customerProfileId' => '31390172', 49 | 'customerAddressId' => '29366174' 50 | ]); 51 | } catch (Exception $e) { 52 | echo $e; 53 | exit; 54 | } 55 | ?> 56 | 57 | 58 | 59 | 60 | CIM :: Delete Shipping Profile 61 | 68 | 69 | 70 |

71 | CIM :: Delete Shipping Profile 72 |

73 |

74 | Results 75 |

76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
98 |

99 | Raw Input/Output 100 |

101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /examples/cim/getCustomerPaymentProfileRequest.php: -------------------------------------------------------------------------------- 1 | getCustomerPaymentProfileRequest([ 67 | 'customerProfileId' => '31390172', 68 | 'customerPaymentProfileId' => '28393490' 69 | ]); 70 | } catch (Exception $e) { 71 | echo $e; 72 | exit; 73 | } 74 | ?> 75 | 76 | 77 | 78 | 79 | CIM :: Get Payment Profile 80 | 87 | 88 | 89 |

90 | CIM :: Get Payment Profile 91 |

92 |

93 | Results 94 |

95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
First NamepaymentProfile->billTo->firstName ?>
Last NamepaymentProfile->billTo->lastName ?>
AddresspaymentProfile->billTo->address ?>
CitypaymentProfile->billTo->city ?>
StatepaymentProfile->billTo->state ?>
ZippaymentProfile->billTo->zip ?>
Phone NumberpaymentProfile->billTo->phoneNumber ?>
Customer Payment ProfileIdpaymentProfile->customerPaymentProfileId ?>
Card NumberpaymentProfile->payment->creditCard->cardNumber ?>
Expiration DatepaymentProfile->payment->creditCard->expirationDate ?>
157 |

158 | Raw Input/Output 159 |

160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /examples/cim/getCustomerProfileIdsRequest.php: -------------------------------------------------------------------------------- 1 | getCustomerProfileIdsRequest(); 135 | } catch (Exception $e) { 136 | echo $e; 137 | exit; 138 | } 139 | ?> 140 | 141 | 142 | 143 | 144 | CIM :: Get Customer Profile IDs 145 | 152 | 153 | 154 |

155 | CIM :: Get Customer Profile IDs 156 |

157 |

158 | Results 159 |

160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 186 | 187 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
Profile IDs 184 | ids) ?> 185 |
188 |

189 | Raw Input/Output 190 |

191 | 192 | 193 | 194 | -------------------------------------------------------------------------------- /examples/cim/getCustomerShippingAddressRequest.php: -------------------------------------------------------------------------------- 1 | getCustomerShippingAddressRequest([ 58 | 'customerProfileId' => '31390172', 59 | 'customerAddressId' => '29366174' 60 | ]); 61 | } catch (Exception $e) { 62 | echo $e; 63 | exit; 64 | } 65 | ?> 66 | 67 | 68 | 69 | 70 | CIM :: Get Shipping Address 71 | 78 | 79 | 80 |

81 | CIM :: Get Shipping Address 82 |

83 |

84 | Results 85 |

86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
First Nameaddress->firstName ?>
Last Nameaddress->lastName ?>
Addressaddress->address ?>
Cityaddress->city ?>
Stateaddress->state ?>
Zipaddress->zip ?>
Phone Numberaddress->phoneNumber ?>
Customer Address Idaddress->customerAddressId ?>
140 |

141 | Raw Input/Output 142 |

143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /examples/cim/getHostedProfilePageRequest.php: -------------------------------------------------------------------------------- 1 | getHostedProfilePageRequest([ 54 | 'customerProfileId' => '31390172', 55 | 'hostedProfileSettings' => [ 56 | [ 57 | 'settingName' => 'hostedProfileReturnUrl', 58 | 'settingValue' => 'https://blah.com/blah/', 59 | ], 60 | [ 61 | 'settingName' => 'hostedProfileReturnUrlText', 62 | 'settingValue' => 'Continue to blah.', 63 | ], 64 | [ 65 | 'settingName' => 'hostedProfilePageBorderVisible', 66 | 'settingValue' => 'true', 67 | ] 68 | ] 69 | ]); 70 | } catch (Exception $e) { 71 | echo $e; 72 | exit; 73 | } 74 | ?> 75 | 76 | 77 | 78 | 79 | CIM :: Get Hosted Profile Page 80 | 87 | 88 | 89 |

90 | CIM :: Get Hosted Profile Page 91 |

92 |

93 | Results 94 |

95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
Tokentoken ?>
121 |

122 | Raw Input/Output 123 |

124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /examples/cim/updateCustomerPaymentProfileRequest.php: -------------------------------------------------------------------------------- 1 | updateCustomerPaymentProfileRequest([ 68 | 'customerProfileId' => '31390172', 69 | 'paymentProfile' => [ 70 | 'billTo' => [ 71 | 'firstName' => 'John', 72 | 'lastName' => 'Doe', 73 | 'company' => '', 74 | 'address' => '123 Main St.', 75 | 'city' => 'Bellevue', 76 | 'state' => 'WA', 77 | 'zip' => '98004', 78 | 'country' => 'USA', 79 | 'phoneNumber' => '800-555-1234', 80 | 'faxNumber' => '800-555-1234' 81 | ], 82 | 'payment' => [ 83 | 'creditCard' => [ 84 | 'cardNumber' => '4111111111111111', 85 | 'expirationDate' => '2016-08' 86 | ] 87 | ], 88 | 'customerPaymentProfileId' => '28393490' 89 | ] 90 | ]); 91 | } catch (Exception $e) { 92 | echo $e; 93 | exit; 94 | } 95 | ?> 96 | 97 | 98 | 99 | 100 | CIM :: Update Customer Profile 101 | 108 | 109 | 110 |

111 | CIM :: Update Customer Profile 112 |

113 |

114 | Results 115 |

116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
138 |

139 | Raw Input/Output 140 |

141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /examples/cim/updateCustomerProfileRequest.php: -------------------------------------------------------------------------------- 1 | updateCustomerProfileRequest([ 52 | 'profile' => [ 53 | 'merchantCustomerId' => '12345', 54 | 'description' => 'some description', 55 | 'email' => 'newaddress@example.com', 56 | 'customerProfileId' => '31390172' 57 | ] 58 | ]); 59 | } catch (Exception $e) { 60 | echo $e; 61 | exit; 62 | } 63 | ?> 64 | 65 | 66 | 67 | 68 | CIM :: Update Customer Profile 69 | 76 | 77 | 78 |

79 | CIM :: Update Customer Profile 80 |

81 |

82 | Results 83 |

84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
106 |

107 | Raw Input/Output 108 |

109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /examples/cim/updateCustomerShippingAddressRequest.php: -------------------------------------------------------------------------------- 1 | updateCustomerShippingAddressRequest([ 60 | 'customerProfileId' => '31390172', 61 | 'address' => [ 62 | 'firstName' => 'John', 63 | 'lastName' => 'Doe', 64 | 'company' => '', 65 | 'address' => '123 Main St.', 66 | 'city' => 'Bellevue', 67 | 'state' => 'WA', 68 | 'zip' => '98004', 69 | 'country' => 'USA', 70 | 'phoneNumber' => '800-555-1234', 71 | 'faxNumber' => '800-555-1234', 72 | 'customerAddressId' => '29366174' 73 | ] 74 | ]); 75 | } catch (Exception $e) { 76 | echo $e; 77 | exit; 78 | } 79 | ?> 80 | 81 | 82 | 83 | 84 | CIM :: Update Shipping Address 85 | 92 | 93 | 94 |

95 | CIM :: Update Shipping Address 96 |

97 |

98 | Results 99 |

100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
122 |

123 | Raw Input/Output 124 |

125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /examples/cim/updateSplitTenderGroupRequest.php: -------------------------------------------------------------------------------- 1 | updateSplitTenderGroupRequest([ 48 | 'splitTenderId' => '123456', 49 | 'splitTenderStatus' => 'voided' 50 | ]); 51 | } catch (Exception $e) { 52 | echo $e; 53 | exit; 54 | } 55 | ?> 56 | 57 | 58 | 59 | 60 | CIM :: Update Split Tender Group 61 | 68 | 69 | 70 |

71 | CIM :: Update Split Tender Group 72 |

73 |

74 | Results 75 |

76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
98 |

99 | Raw Input/Output 100 |

101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /examples/cim/validateCustomerPaymentProfileRequest.php: -------------------------------------------------------------------------------- 1 | validateCustomerPaymentProfileRequest([ 51 | 'customerProfileId' => '31390172', 52 | 'customerPaymentProfileId' => '28393490', 53 | 'customerShippingAddressId' => '29366174', 54 | 'validationMode' => 'liveMode' 55 | ]); 56 | } catch (Exception $e) { 57 | echo $e; 58 | exit; 59 | } 60 | ?> 61 | 62 | 63 | 64 | 65 | CIM :: Validate Payment Profile 66 | 73 | 74 | 75 |

76 | CIM :: Validate Payment Profile 77 |

78 |

79 | Results 80 |

81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 |
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Result Codemessages->resultCode ?>
Message Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
Transaction Approved?isApproved()) ? 'yes' : 'no' ?>
Authorization CodegetTransactionResponseField('AuthorizationCode') ?>
AVS ResponsegetTransactionResponseField('AVSResponse') ?>
Transaction IDgetTransactionResponseField('TransactionID') ?>
119 |

120 | Raw Input/Output 121 |

122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /examples/reporting/getAUJobSummaryRequest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /************************************************************************************************* 13 | 14 | Call this function and supply your authentication information to receive merchant details in the response. 15 | The information that is returned is helpful for OAuth and Accept integrations. Generate a PublicClientKey only 16 | if one is not generated or is not active. Only the most recently generated active key is returned. 17 | 18 | SAMPLE REQUEST 19 | -------------------------------------------------------------------------------------------------- 20 | { 21 | "getAUJobSummaryRequest": { 22 | "merchantAuthentication": { 23 | "name": "", 24 | "transactionKey": "" 25 | }, 26 | "refId": "123456", 27 | "month": "2020-04" 28 | } 29 | } 30 | 31 | SAMPLE RESPONSE 32 | -------------------------------------------------------------------------------------------------- 33 | { 34 | "auSummary": 35 | { 36 | "auResponse": 37 | [ 38 | { 39 | "auReasonCode": "ACL", 40 | "profileCount": 11, 41 | "reasonDescription": "AccountClosed" 42 | }, 43 | { 44 | "auReasonCode": "NAN", 45 | "profileCount": 17, 46 | "reasonDescription": "NewAccountNumber" 47 | }, 48 | { 49 | "auReasonCode": "NED", 50 | "profileCount": 23, 51 | "reasonDescription": "NewExpirationDate" 52 | } 53 | ] 54 | }, 55 | "refId": 123456, 56 | "messages": 57 | { 58 | "resultCode": "Ok", 59 | "message": 60 | { 61 | "code": "I00001", 62 | "text": "Successful." 63 | } 64 | } 65 | } 66 | 67 | *************************************************************************************************/ 68 | 69 | namespace Authnetjson; 70 | 71 | use Exception; 72 | 73 | require '../../config.inc.php'; 74 | 75 | try { 76 | $request = AuthnetApiFactory::getJsonApiHandler( 77 | AUTHNET_LOGIN, 78 | AUTHNET_TRANSKEY, 79 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 80 | ); 81 | $response = $request->getAUJobSummaryRequest([ 82 | 'refId' => "123456", 83 | 'month' => "2020-05" 84 | ]); 85 | } catch (Exception $e) { 86 | echo $e; 87 | exit; 88 | } 89 | ?> 90 | 91 | 92 | 93 | 94 | Transaction Detail :: Get Account Updater Job Summary 95 | 102 | 103 | 104 |

105 | Transaction Detail :: Get Account Updater Job Summary 106 |

107 |

108 | Results 109 |

110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | auSummary)) : ?> 136 | auSummary->auResponse as $aujob) : ?> 137 | 138 | 139 | 144 | 145 | 146 | 147 |
Responsemessages->resultCode ?>
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
Reference IDrefId ?>
Response 140 | AU Reason Code: auReasonCode ?>
141 | Profile Count: profileCount ?>
142 | Reason Description: reasonDescription ?> 143 |
148 |

149 | Raw Input/Output 150 |

151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /examples/reporting/getMerchantDetailsRequest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /************************************************************************************************* 13 | 14 | Call this function and supply your authentication information to receive merchant details in the response. 15 | The information that is returned is helpful for OAuth and Accept integrations. Generate a PublicClientKey only 16 | if one is not generated or is not active. Only the most recently generated active key is returned. 17 | 18 | SAMPLE REQUEST 19 | -------------------------------------------------------------------------------------------------- 20 | { 21 | "getMerchantDetailsRequest": { 22 | "merchantAuthentication": { 23 | "name": "", 24 | "transactionKey": "" 25 | } 26 | } 27 | } 28 | 29 | SAMPLE RESPONSE 30 | -------------------------------------------------------------------------------------------------- 31 | { 32 | "isTestMode": false, 33 | "processors": [ 34 | { 35 | "name": "First Data Nashville" 36 | } 37 | ], 38 | "merchantName": "fwHGwSdCaR", 39 | "gatewayId": "565697", 40 | "marketTypes": [ 41 | "eCommerce" 42 | ], 43 | "productCodes": [ 44 | "CNP" 45 | ], 46 | "paymentMethods": [ 47 | "AmericanExpress", 48 | "DinersClub", 49 | "Discover", 50 | "EnRoute", 51 | "JCB", 52 | "Mastercard", 53 | "Visa" 54 | ], 55 | "currencies": [ 56 | "USD" 57 | ], 58 | "publicClientKey": "9aptdYwtHt2F22XLRgr4B9AM4Pkt5eb6b6MC9d2Nn3m3YEptx3RFFuXmpYWDLHev", 59 | "messages": { 60 | "resultCode": "Ok", 61 | "message": [ 62 | { 63 | "code": "I00001", 64 | "text": "Successful." 65 | } 66 | ] 67 | } 68 | } 69 | 70 | *************************************************************************************************/ 71 | 72 | namespace Authnetjson; 73 | 74 | use Exception; 75 | 76 | require '../../config.inc.php'; 77 | 78 | try { 79 | $request = AuthnetApiFactory::getJsonApiHandler( 80 | AUTHNET_LOGIN, 81 | AUTHNET_TRANSKEY, 82 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 83 | ); 84 | $response = $request->getMerchantDetailsRequest(); 85 | } catch (Exception $e) { 86 | echo $e; 87 | exit; 88 | } 89 | ?> 90 | 91 | 92 | 93 | 94 | Transaction Detail :: Get Merchant Details 95 | 102 | 103 | 104 |

105 | Transaction Detail :: Get Merchant Details 106 |

107 |

108 | Results 109 |

110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 |
Responsemessages->resultCode ?>
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
Merchant NamemerchantName ?>
Gateway IdgatewayId ?>
Processors 142 | processors as $processor) : ?> 143 | ', $processor->name) ?> 144 | 145 |
Market TypesmarketTypes) ?>
Product CodesproductCodes) ?>
Payment MethodspaymentMethods) ?>
Currenciescurrencies) ?>
Public Client KeypublicClientKey ?>
168 |

169 | Raw Input/Output 170 |

171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /examples/reporting/getTransactionDetailsRequest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /************************************************************************************************* 13 | 14 | Use the Transaction Details API to get the details of a transaction 15 | 16 | SAMPLE REQUEST 17 | -------------------------------------------------------------------------------------------------- 18 | { 19 | "getTransactionDetailsRequest":{ 20 | "merchantAuthentication":{ 21 | "name":"", 22 | "transactionKey":"" 23 | }, 24 | "transId":"2162566217" 25 | } 26 | } 27 | 28 | SAMPLE RESPONSE 29 | -------------------------------------------------------------------------------------------------- 30 | { 31 | "transaction":{ 32 | "transId":"2162566217", 33 | "submitTimeUTC":"2011-09-01T16:30:49.39Z", 34 | "submitTimeLocal":"2011-09-01T10:30:49.39", 35 | "transactionType":"authCaptureTransaction", 36 | "transactionStatus":"settledSuccessfully", 37 | "responseCode":1, 38 | "responseReasonCode":1, 39 | "responseReasonDescription":"Approval", 40 | "authCode":"JPG9DJ", 41 | "AVSResponse":"Y", 42 | "batch":{ 43 | "batchId":"1221577", 44 | "settlementTimeUTC":"2011-09-01T16:38:54.52Z", 45 | "settlementTimeUTCSpecified":true, 46 | "settlementTimeLocal":"2011-09-01T10:38:54.52", 47 | "settlementTimeLocalSpecified":true, 48 | "settlementState":"settledSuccessfully" 49 | }, 50 | "order":{ 51 | "invoiceNumber":"60", 52 | "description":"Auto-charge for Invoice #60" 53 | }, 54 | "requestedAmountSpecified":false, 55 | "authAmount":1018.88, 56 | "settleAmount":1018.88, 57 | "prepaidBalanceRemainingSpecified":false, 58 | "taxExempt":false, 59 | "taxExemptSpecified":true, 60 | "payment":{ 61 | "creditCard":{ 62 | "cardNumber":"XXXX4444", 63 | "expirationDate":"XXXX", 64 | "cardType":"MasterCard" 65 | } 66 | }, 67 | "customer":{ 68 | "typeSpecified":false, 69 | "id":"4" 70 | }, 71 | "billTo":{ 72 | "phoneNumber":"(619) 274-0494", 73 | "firstName":"Matteo", 74 | "lastName":"Bignotti", 75 | "address":"625 Broadway\nSuite 1025", 76 | "city":"San Diego", 77 | "state":"CA", 78 | "zip":"92101", 79 | "country":"United States" 80 | }, 81 | "recurringBilling":false, 82 | "recurringBillingSpecified":true, 83 | "product":"Card Not Present", 84 | "marketType":"eCommerce" 85 | }, 86 | "messages":{ 87 | "resultCode":"Ok", 88 | "message":[ 89 | { 90 | "code":"I00001", 91 | "text":"Successful." 92 | } 93 | ] 94 | } 95 | } 96 | 97 | *************************************************************************************************/ 98 | 99 | namespace Authnetjson; 100 | 101 | use Exception; 102 | 103 | require '../../config.inc.php'; 104 | 105 | try { 106 | $request = AuthnetApiFactory::getJsonApiHandler( 107 | AUTHNET_LOGIN, 108 | AUTHNET_TRANSKEY, 109 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 110 | ); 111 | $response = $request->getTransactionDetailsRequest([ 112 | 'transId' => '40067511400' 113 | ]); 114 | } catch (Exception $e) { 115 | echo $e; 116 | exit; 117 | } 118 | ?> 119 | 120 | 121 | 122 | 123 | Transaction Detail :: Transaction Details 124 | 131 | 132 | 133 |

134 | Transaction Detail :: Transaction Details 135 |

136 |

137 | Results 138 |

139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 169 | 170 |
Responsemessages->resultCode ?>
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
Transaction 163 | ID: transaction->transId; ?>
164 | Type: transaction->transactionType; ?>
165 | Status: transaction->transactionStatus; ?>
166 | Authorization Code: transaction->authCode; ?>
167 | AVS Response: transaction->AVSResponse; ?>
168 |
171 |

172 | Raw Input/Output 173 |

174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /examples/reporting/getTransactionListRequest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /************************************************************************************************* 13 | 14 | Use the Transaction Details API to get a list of transaction in a batch 15 | 16 | SAMPLE REQUEST 17 | -------------------------------------------------------------------------------------------------- 18 | { 19 | "getTransactionListRequest":{ 20 | "merchantAuthentication":{ 21 | "name":"", 22 | "transactionKey":"" 23 | }, 24 | "batchId":"1221577" 25 | } 26 | } 27 | 28 | SAMPLE RESPONSE 29 | -------------------------------------------------------------------------------------------------- 30 | { 31 | "transactions":[ 32 | { 33 | "transId":"2162566217", 34 | "submitTimeUTC":"2011-09-01T16:30:49Z", 35 | "submitTimeLocal":"2011-09-01T10:30:49", 36 | "transactionStatus":"settledSuccessfully", 37 | "invoiceNumber":"60", 38 | "firstName":"Matteo", 39 | "lastName":"Bignotti", 40 | "accountType":"MasterCard", 41 | "accountNumber":"XXXX4444", 42 | "settleAmount":1018.88, 43 | "marketType":"eCommerce", 44 | "product":"Card Not Present", 45 | "hasReturnedItemsSpecified":false 46 | } 47 | ], 48 | "messages":{ 49 | "resultCode":"Ok", 50 | "message":[ 51 | { 52 | "code":"I00001", 53 | "text":"Successful." 54 | } 55 | ] 56 | } 57 | } 58 | 59 | *************************************************************************************************/ 60 | 61 | namespace Authnetjson; 62 | 63 | use Exception; 64 | 65 | require '../../config.inc.php'; 66 | 67 | try { 68 | $request = AuthnetApiFactory::getJsonApiHandler( 69 | AUTHNET_LOGIN, 70 | AUTHNET_TRANSKEY, 71 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 72 | ); 73 | $response = $request->getTransactionListRequest([ 74 | 'batchId' => '7864228' 75 | ]); 76 | } catch (Exception $e) { 77 | echo $e; 78 | exit; 79 | } 80 | ?> 81 | 82 | 83 | 84 | 85 | Transaction Detail :: Get Transactions List 86 | 93 | 94 | 95 |

96 | Transaction Detail :: Get Transactions List 97 |

98 |

99 | Results 100 |

101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | transactions as $transaction) : ?> 123 | 124 | 125 | 136 | 137 | 138 |
Responsemessages->resultCode ?>
Successful?isSuccessful() ? 'yes' : 'no' ?>
Error?isError() ? 'yes' : 'no' ?>
Codemessages->message[0]->code ?>
Messagemessages->message[0]->text ?>
Transaction 126 | transId: transId; ?>
127 | submitTimeUTC: submitTimeUTC; ?>
128 | submitTimeLocal: submitTimeLocal; ?>
129 | transactionStatus: transactionStatus; ?>
130 | invoiceNumber: invoiceNumber; ?>
131 | firstName: firstName; ?>
132 | accountType: accountType; ?>
133 | accountNumber: accountNumber; ?>
134 | settleAmount: settleAmount; ?>
135 |
139 |

140 | Raw Input/Output 141 |

142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /examples/sim/sim.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /************************************************************************************************* 13 | 14 | Use the SIM tools to create a SIM transaction form 15 | 16 | *************************************************************************************************/ 17 | 18 | namespace Authnetjson; 19 | 20 | use Exception; 21 | 22 | require '../../config.inc.php'; 23 | 24 | try { 25 | $sim = AuthnetApiFactory::getSimHandler( 26 | AUTHNET_LOGIN, 27 | AUTHNET_SIGNATURE, 28 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 29 | ); 30 | $amount = 10.00; 31 | $login = $sim->getLogin(); 32 | $url = $sim->getEndpoint(); 33 | $fingerprint = $sim->getFingerprint($amount); 34 | $sequence = $sim->getSequence(); 35 | $timestamp = $sim->getTimestamp(); 36 | } catch (Exception $e) { 37 | echo $e; 38 | exit; 39 | } 40 | ?> 41 | 42 | 43 | 44 | 45 | SIM (Deprecated) 46 | 47 | 48 |

49 | SIM (Deprecated) 50 |

51 |
52 |         Login: 
53 | Endpoint:
54 | Hash:
55 | Sequence:
56 | Timestamp: 57 |
58 |
59 | 60 | 61 | ' /> 62 | ' /> 63 | 64 | 65 | 66 | 67 | 68 |
69 | 70 | 71 | -------------------------------------------------------------------------------- /examples/webhooks/createWebhook.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | /************************************************************************************************* 12 | 13 | Use the Webhooks API to create a webhook 14 | 15 | SAMPLE REQUEST 16 | -------------------------------------------------------------------------------------------------- 17 | 18 | POST https://apitest.authorize.net/rest/v1/webhooks 19 | 20 | { 21 | "url": "http://localhost:55950/api/webhooks", 22 | "eventTypes": [ 23 | "net.authorize.payment.authcapture.created", 24 | "net.authorize.customer.created", 25 | "net.authorize.customer.paymentProfile.created", 26 | "net.authorize.customer.subscription.expiring" 27 | ], 28 | "status": "active" 29 | } 30 | 31 | 32 | SAMPLE RESPONSE 33 | -------------------------------------------------------------------------------------------------- 34 | 35 | { 36 | "_links": { 37 | "self": { 38 | "href": "/rest/v1/webhooks/72a55c78-66e6-4b1e-a4d6-3f925c00561f" 39 | } 40 | }, 41 | "webhookId": "72a55c78-66e6-4b1e-a4d6-3f925c00561f", 42 | "eventTypes": [ 43 | "net.authorize.payment.authcapture.created", 44 | "net.authorize.customer.created", 45 | "net.authorize.customer.paymentProfile.created", 46 | "net.authorize.customer.subscription.expiring" 47 | ], 48 | "status": "active", 49 | "url": "http://localhost:55950/api/webhooks" 50 | } 51 | 52 | *************************************************************************************************/ 53 | 54 | namespace Authnetjson; 55 | 56 | use Exception; 57 | 58 | require '../../config.inc.php'; 59 | 60 | try { 61 | $request = AuthnetApiFactory::getWebhooksHandler( 62 | AUTHNET_LOGIN, 63 | AUTHNET_TRANSKEY, 64 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 65 | ); 66 | $response = $request->createWebhooks([ 67 | 'net.authorize.customer.created', 68 | 'net.authorize.customer.deleted', 69 | 'net.authorize.customer.updated', 70 | 'net.authorize.customer.paymentProfile.created', 71 | 'net.authorize.customer.paymentProfile.deleted', 72 | 'net.authorize.customer.paymentProfile.updated', 73 | 'net.authorize.customer.subscription.cancelled', 74 | 'net.authorize.customer.subscription.created', 75 | 'net.authorize.customer.subscription.expiring', 76 | 'net.authorize.customer.subscription.suspended', 77 | 'net.authorize.customer.subscription.terminated', 78 | 'net.authorize.customer.subscription.updated', 79 | 'net.authorize.payment.authcapture.created', 80 | 'net.authorize.payment.authorization.created', 81 | 'net.authorize.payment.capture.created', 82 | 'net.authorize.payment.fraud.approved', 83 | 'net.authorize.payment.fraud.declined', 84 | 'net.authorize.payment.fraud.held', 85 | 'net.authorize.payment.priorAuthCapture.created', 86 | 'net.authorize.payment.refund.created', 87 | 'net.authorize.payment.void.created' 88 | ], 'http://requestb.in/', 'active'); 89 | $successful = true; 90 | $error = false; 91 | } catch (Exception $e) { 92 | echo $e; 93 | exit; 94 | } 95 | 96 | ?> 97 | 98 | 99 | 100 | Webhooks :: Create Webhooks 101 | 108 | 109 | 110 |

111 | Webhooks :: Create Webhooks 112 |

113 |

114 | Results 115 |

116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 |
Successful
Event Types 125 | getEventTypes() as $eventType) { 127 | echo $eventType, "
\n"; 128 | } 129 | ?> 130 |
Webhook IDgetWebhooksId() ?>
StatusgetStatus() ?>
URLgetUrl() ?>
Error messageerrorMessage ?>
151 |

152 | Raw Input/Output 153 |

154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /examples/webhooks/deleteWebhook.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | /************************************************************************************************* 12 | 13 | Use the Webhooks API to 14 | 15 | SAMPLE REQUEST 16 | -------------------------------------------------------------------------------------------------- 17 | 18 | DELETE https://apitest.authorize.net/rest/v1/webhooks/ 19 | 20 | 21 | SAMPLE RESPONSE 22 | -------------------------------------------------------------------------------------------------- 23 | 24 | HTTP response code 200 will be returned for a successful deletion 25 | 26 | 27 | *************************************************************************************************/ 28 | 29 | namespace Authnetjson; 30 | 31 | use Exception; 32 | 33 | require '../../config.inc.php'; 34 | 35 | try { 36 | $request = AuthnetApiFactory::getWebhooksHandler( 37 | AUTHNET_LOGIN, 38 | AUTHNET_TRANSKEY, 39 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 40 | ); 41 | $request->deleteWebhook('0550f061-59a1-4f13-a9da-3e8bfc50e80b'); 42 | $successful = true; 43 | $error = false; 44 | } catch (Exception $e) { 45 | echo $e; 46 | exit; 47 | } 48 | 49 | ?> 50 | 51 | 52 | 53 | Webhooks :: Delete Webhooks 54 | 61 | 62 | 63 |

64 | Webhooks :: Delete Webhooks 65 |

66 |

67 | Results 68 |

69 | 70 | 71 | 72 | 73 | 74 | 77 | 78 | 79 | 80 | 81 | 84 |
Successful
Error messageerrorMessage ?>
85 |

86 | Raw Input/Output 87 |

88 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /examples/webhooks/getEventTypes.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | /************************************************************************************************* 12 | 13 | Use the Webhooks API to retreive a list of all available webhooks 14 | 15 | SAMPLE REQUEST 16 | -------------------------------------------------------------------------------------------------- 17 | 18 | GET https://apitest.authorize.net/rest/v1/eventtypes 19 | 20 | 21 | SAMPLE RESPONSE 22 | -------------------------------------------------------------------------------------------------- 23 | 24 | [ 25 | { 26 | "name": "net.authorize.customer.created" 27 | }, 28 | { 29 | "name": "net.authorize.customer.deleted" 30 | }, 31 | { 32 | "name": "net.authorize.customer.updated" 33 | }, 34 | { 35 | "name": "net.authorize.customer.paymentProfile.created" 36 | }, 37 | { 38 | "name": "net.authorize.customer.paymentProfile.deleted" 39 | }, 40 | { 41 | "name": "net.authorize.customer.paymentProfile.updated" 42 | }, 43 | { 44 | "name": "net.authorize.customer.subscription.cancelled" 45 | }, 46 | { 47 | "name": "net.authorize.customer.subscription.created" 48 | }, 49 | { 50 | "name": "net.authorize.customer.subscription.expiring" 51 | }, 52 | { 53 | "name": "net.authorize.customer.subscription.suspended" 54 | }, 55 | { 56 | "name": "net.authorize.customer.subscription.terminated" 57 | }, 58 | { 59 | "name": "net.authorize.customer.subscription.updated" 60 | }, 61 | { 62 | "name": "net.authorize.payment.authcapture.created" 63 | }, 64 | { 65 | "name": "net.authorize.payment.authorization.created" 66 | }, 67 | { 68 | "name": "net.authorize.payment.capture.created" 69 | }, 70 | { 71 | "name": "net.authorize.payment.fraud.approved" 72 | }, 73 | { 74 | "name": "net.authorize.payment.fraud.declined" 75 | }, 76 | { 77 | "name": "net.authorize.payment.fraud.held" 78 | }, 79 | { 80 | "name": "net.authorize.payment.priorAuthCapture.created" 81 | }, 82 | { 83 | "name": "net.authorize.payment.refund.created" 84 | }, 85 | { 86 | "name": "net.authorize.payment.void.created" 87 | } 88 | ] 89 | 90 | *************************************************************************************************/ 91 | 92 | namespace Authnetjson; 93 | 94 | use Exception; 95 | 96 | require '../../config.inc.php'; 97 | 98 | try { 99 | $request = AuthnetApiFactory::getWebhooksHandler( 100 | AUTHNET_LOGIN, 101 | AUTHNET_TRANSKEY, 102 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 103 | ); 104 | $response = $request->getEventTypes(); 105 | $successful = true; 106 | $error = false; 107 | } catch (Exception $e) { 108 | echo $e; 109 | exit; 110 | } 111 | 112 | ?> 113 | 114 | 115 | 116 | Webhooks :: Get Event Types 117 | 124 | 125 | 126 |

127 | Webhooks :: Get Event Types 128 |

129 |

130 | Results 131 |

132 | 133 | 134 | 135 | 136 | 137 | 140 | 141 | 142 | 149 | 150 | 154 | 155 | 156 | 157 | 158 | 161 |
Successful
Event Types 143 | getEventTypes() as $eventType) { 145 | echo $eventType, "
\n"; 146 | } 147 | ?> 148 |
Error messageerrorMessage ?>
162 |

163 | Raw Input/Output 164 |

165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /examples/webhooks/getWebhook.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | /************************************************************************************************* 12 | 13 | Use the Webhooks API to retrieve a webhook 14 | 15 | SAMPLE REQUEST 16 | -------------------------------------------------------------------------------------------------- 17 | 18 | GET https://apitest.authorize.net/rest/v1/webhooks/72a55c78-66e6-4b1e-a4d6-3f925c00561f 19 | 20 | 21 | SAMPLE RESPONSE 22 | -------------------------------------------------------------------------------------------------- 23 | 24 | { 25 | "_links": { 26 | "self": { 27 | "href": "/rest/v1/webhooks/72a55c78-66e6-4b1e-a4d6-3f925c00561f" 28 | } 29 | }, 30 | "webhookId": "72a55c78-66e6-4b1e-a4d6-3f925c00561f", 31 | "eventTypes": [ 32 | "net.authorize.payment.authcapture.created", 33 | "net.authorize.customer.created", 34 | "net.authorize.customer.paymentProfile.created", 35 | "net.authorize.customer.subscription.expiring" 36 | ], 37 | "status": "active", 38 | "url": "http://localhost:55950/api/webhooks" 39 | } 40 | 41 | 42 | *************************************************************************************************/ 43 | 44 | namespace Authnetjson; 45 | 46 | use Exception; 47 | 48 | require '../../config.inc.php'; 49 | 50 | try { 51 | $request = AuthnetApiFactory::getWebhooksHandler( 52 | AUTHNET_LOGIN, 53 | AUTHNET_TRANSKEY, 54 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 55 | ); 56 | $response = $request->getWebhook('cd2c262f-2723-4848-ae92-5d317902441c'); 57 | $successful = true; 58 | $error = false; 59 | } catch (Exception $e) { 60 | echo $e; 61 | exit; 62 | } 63 | 64 | ?> 65 | 66 | 67 | 68 | Webhooks :: Get A Webhook 69 | 76 | 77 | 78 |

79 | Webhooks :: Get A Webhook 80 |

81 |

82 | Results 83 |

84 | 85 | 86 | 87 | 88 | 89 | 92 | 93 | 94 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 118 | 119 | 120 | 121 | 122 | 125 |
Successful
Event Types 95 | getEventTypes() as $eventType) { 97 | echo $eventType, "
\n"; 98 | } 99 | ?> 100 |
Webhook IDgetWebhooksId() ?>
StatusgetStatus() ?>
URLgetUrl() ?>
Error messageerrorMessage ?>
126 |

127 | Raw Input/Output 128 |

129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /examples/webhooks/listWebhooks.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | /************************************************************************************************* 12 | 13 | Use the Webhooks API to list all of my webhooks 14 | 15 | SAMPLE REQUEST 16 | -------------------------------------------------------------------------------------------------- 17 | 18 | GET https://apitest.authorize.net/rest/v1/webhooks 19 | 20 | 21 | SAMPLE RESPONSE 22 | -------------------------------------------------------------------------------------------------- 23 | 24 | [{ 25 | "_links": { 26 | "self": { 27 | "href": "/rest/v1/webhooks/72a55c78-66e6-4b1e-a4d6-3f925c00561f" 28 | } 29 | }, 30 | "webhookId": "72a55c78-66e6-4b1e-a4d6-3f925c00561f", 31 | "eventTypes": [ 32 | "net.authorize.payment.authcapture.created", 33 | "net.authorize.customer.created", 34 | "net.authorize.customer.paymentProfile.created", 35 | "net.authorize.customer.subscription.expiring" 36 | ], 37 | "status": "active", 38 | "url": "http://localhost:55950/api/webhooks" 39 | }, { 40 | "_links": { 41 | "self": { 42 | "href": "/rest/v1/webhooks/7be120d3-2247-4706-b9b1-98931fdfdcce" 43 | } 44 | }, 45 | "webhookId": "7be120d3-2247-4706-b9b1-98931fdfdcce", 46 | "eventTypes": [ 47 | "net.authorize.customer.subscription.expiring", 48 | "net.authorize.customer.paymentProfile.created", 49 | "net.authorize.payment.authcapture.created", 50 | "net.authorize.customer.created" 51 | ], 52 | "status": "inactive", 53 | "url": "http://localhost:55950/api/webhooks" 54 | }, { 55 | "_links": { 56 | "self": { 57 | "href": "/rest/v1/webhooks/62c68677-0d71-43a7-977a-f4dea3827fac" 58 | } 59 | }, 60 | "webhookId": "62c68677-0d71-43a7-977a-f4dea3827fac", 61 | "eventTypes": [ 62 | "net.authorize.customer.subscription.expiring", 63 | "net.authorize.customer.created", 64 | "net.authorize.customer.paymentProfile.created", 65 | "net.authorize.payment.authcapture.created" 66 | ], 67 | "status": "active", 68 | "url": "http://localhost:55950/api/webhooks" 69 | }] 70 | 71 | 72 | *************************************************************************************************/ 73 | 74 | namespace Authnetjson; 75 | 76 | use Exception; 77 | 78 | require '../../config.inc.php'; 79 | 80 | try { 81 | $request = AuthnetApiFactory::getWebhooksHandler( 82 | AUTHNET_LOGIN, 83 | AUTHNET_TRANSKEY, 84 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 85 | ); 86 | $response = $request->getWebhooks(); 87 | $successful = true; 88 | $error = false; 89 | } catch (Exception $e) { 90 | echo $e; 91 | exit; 92 | } 93 | 94 | ?> 95 | 96 | 97 | 98 | Webhooks :: List Webhooks 99 | 106 | 107 | 108 |

109 | Webhooks :: List Webhooks 110 |

111 |

112 | Results 113 |

114 | 115 | 116 | 117 | 118 | 119 | getWebhooks() as $webhook) { 122 | ?> 123 | 124 | 127 | 128 | 129 | 130 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 154 | 155 | 156 | 157 | 158 | 161 |
Successful
125 |
126 |
Event Types 131 | getEventTypes() as $eventType) { 133 | echo $eventType, "
\n"; 134 | } 135 | ?> 136 |
Webhook IDgetWebhooksId() ?>
StatusgetStatus() ?>
URLgetUrl() ?>
Error messageerrorMessage ?>
162 |

163 | Raw Input/Output 164 |

165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /examples/webhooks/notificationHistory.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | /************************************************************************************************* 12 | 13 | Use the Webhooks API to 14 | 15 | SAMPLE REQUEST 16 | -------------------------------------------------------------------------------------------------- 17 | 18 | GET https://apitest.authorize.net/rest/v1/notifications?offset=0&limit=1000 19 | 20 | 21 | SAMPLE RESPONSE 22 | -------------------------------------------------------------------------------------------------- 23 | 24 | { 25 | "_links": { 26 | "self": { 27 | "href": "/rest/v1/notifications?offset=0&limit=100" 28 | } 29 | }, 30 | "notifications": [ 31 | { 32 | "_links": { 33 | "self": { 34 | "href": "/rest/v1/notifications/e35d5ede-27c5-46cc-aabb-131f10154ed3" 35 | } 36 | }, 37 | "notificationId": "e35d5ede-27c5-46cc-aabb-131f10154ed3", 38 | "deliveryStatus": "Delivered", 39 | "eventType": "net.authorize.payment.authcapture.created", 40 | "eventDate": "2017-02-09T19:18:42.167" 41 | } 42 | ] 43 | } 44 | 45 | 46 | *************************************************************************************************/ 47 | 48 | namespace Authnetjson; 49 | 50 | use Exception; 51 | 52 | require '../../config.inc.php'; 53 | 54 | try { 55 | $request = AuthnetApiFactory::getWebhooksHandler( 56 | AUTHNET_LOGIN, 57 | AUTHNET_TRANSKEY, 58 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 59 | ); 60 | $response = $request->getNotificationHistory(); 61 | $successful = true; 62 | $error = false; 63 | } catch (Exception $e) { 64 | echo $e; 65 | exit; 66 | } 67 | 68 | ?> 69 | 70 | 71 | 72 | Webhooks :: Notification History 73 | 80 | 81 | 82 |

83 | Webhooks :: Notification History 84 |

85 |

86 | Results 87 |

88 | 89 | 90 | 91 | 92 | 93 | getNotificationHistory() as $notification) { 96 | ?> 97 | 98 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 123 | 124 | 125 | 126 | 127 | 130 |
Successful
99 |
100 |
Notification IDgetNotificationId() ?>
Delivery StatusgetDeliveryStatus() ?>
Event TypegetEventType() ?>
Event DategetEventDate() ?>
Error messageerrorMessage ?>
131 |

132 | Raw Input/Output 133 |

134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /examples/webhooks/ping.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | /************************************************************************************************* 12 | 13 | Use the Webhooks API to send a test webhook. 14 | 15 | When a webhook is inactive, you can send a test event to the Webhooks endpoint using this method: 16 | 17 | POST https://apitest.authorize.net/rest/v1/webhooks/72a55c78-66e6-4b1e-a4d6-3f925c00561f/pings 18 | 19 | The POST request message body should be empty. Construct the request URL containing the webhook ID that you want to 20 | test. Then, make an HTTP POST request to that URL. Authorize.Net receives the request and sends a notification to 21 | the registered URL for that webhook, emulating the event for that webhook. 22 | 23 | Note: This request works only on webhooks that are inactive. To test an active webhook, you must first set the webhook 24 | status to inactive. 25 | 26 | SAMPLE REQUEST 27 | -------------------------------------------------------------------------------------------------- 28 | 29 | POST https://apitest.authorize.net/rest/v1/webhooks/ba4c73f3-0808-48bf-ae2f-f49064770e60/pings 30 | 31 | 32 | SAMPLE RESPONSE 33 | -------------------------------------------------------------------------------------------------- 34 | 35 | HTTP 200 response for success 36 | HTTP 500 response for connection error 37 | 38 | *************************************************************************************************/ 39 | 40 | namespace Authnetjson; 41 | 42 | use Exception; 43 | 44 | require '../../config.inc.php'; 45 | 46 | try { 47 | $request = AuthnetApiFactory::getWebhooksHandler( 48 | AUTHNET_LOGIN, 49 | AUTHNET_TRANSKEY, 50 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 51 | ); 52 | $request->testWebhook('ba4c73f3-0808-48bf-ae2f-f49064770e60'); 53 | } catch (Exception $e) { 54 | echo $e; 55 | exit; 56 | } 57 | ?> 58 | 59 | 60 | 61 | Webhooks :: Create Webhooks 62 | 69 | 70 | 71 |

72 | Webhooks :: Ping 73 |

74 |

75 | Raw Input/Output 76 |

77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /examples/webhooks/updateWebhook.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | /************************************************************************************************* 12 | 13 | Use the Webhooks API to update a webhook 14 | 15 | SAMPLE REQUEST 16 | -------------------------------------------------------------------------------------------------- 17 | 18 | PUT https://apitest.authorize.net/rest/v1/webhooks/72a55c78-66e6-4b1e-a4d6-3f925c00561f 19 | 20 | { 21 | "url": "http://requestb.in/19okx6x1", 22 | "eventTypes": [ 23 | "net.authorize.payment.authorization.created" 24 | ], 25 | "status": "active" 26 | } 27 | 28 | 29 | SAMPLE RESPONSE 30 | -------------------------------------------------------------------------------------------------- 31 | 32 | { 33 | "_links": { 34 | "self": { 35 | "href": "/rest/v1/webhooks/72a55c78-66e6-4b1e-a4d6-3f925c00561f" 36 | } 37 | }, 38 | "webhookId": "72a55c78-66e6-4b1e-a4d6-3f925c00561f", 39 | "eventTypes": [ 40 | "net.authorize.payment.authcapture.created" 41 | ], 42 | "status": "active", 43 | "url": "http://requestb.in/19okx6x1" 44 | } 45 | 46 | 47 | *************************************************************************************************/ 48 | 49 | namespace Authnetjson; 50 | 51 | use Exception; 52 | 53 | require '../../config.inc.php'; 54 | 55 | try { 56 | $request = AuthnetApiFactory::getWebhooksHandler( 57 | AUTHNET_LOGIN, 58 | AUTHNET_TRANSKEY, 59 | AuthnetApiFactory::USE_DEVELOPMENT_SERVER 60 | ); 61 | $response = $request->updateWebhook('ba4c73f3-0808-48bf-ae2f-f49064770e60', 'http://requestb.in/', [ 62 | 'net.authorize.customer.created', 63 | 'net.authorize.customer.deleted', 64 | 'net.authorize.customer.updated', 65 | 'net.authorize.customer.paymentProfile.created', 66 | 'net.authorize.customer.paymentProfile.deleted', 67 | 'net.authorize.customer.paymentProfile.updated', 68 | 'net.authorize.customer.subscription.cancelled', 69 | 'net.authorize.customer.subscription.created', 70 | 'net.authorize.customer.subscription.expiring', 71 | 'net.authorize.customer.subscription.suspended', 72 | 'net.authorize.customer.subscription.terminated', 73 | 'net.authorize.customer.subscription.updated', 74 | 'net.authorize.payment.authcapture.created', 75 | 'net.authorize.payment.authorization.created', 76 | 'net.authorize.payment.capture.created', 77 | 'net.authorize.payment.fraud.approved', 78 | 'net.authorize.payment.fraud.declined', 79 | 'net.authorize.payment.fraud.held', 80 | 'net.authorize.payment.priorAuthCapture.created', 81 | 'net.authorize.payment.refund.created', 82 | 'net.authorize.payment.void.created' 83 | ], 'active'); 84 | $successful = true; 85 | $error = false; 86 | } catch (Exception $e) { 87 | echo $e; 88 | exit; 89 | } 90 | 91 | ?> 92 | 93 | 94 | 95 | Webhooks :: Update Webhooks 96 | 103 | 104 | 105 |

106 | Webhooks :: Update Webhooks 107 |

108 |

109 | Results 110 |

111 | 112 | 113 | 114 | 115 | 116 | 119 | 120 | 121 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 145 | 146 | 147 | 148 | 149 | 152 |
Successful
Event Types 122 | getEventTypes() as $eventType) { 124 | echo $eventType, "
\n"; 125 | } 126 | ?> 127 |
Webhook IDgetWebhooksId() ?>
StatusgetStatus() ?>
URLgetUrl() ?>
Error message
153 |

154 | Raw Input/Output 155 |

156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /phpdoc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | build/docs 5 | 6 | 7 | build/docs 8 | 9 | 10 | src 11 | tests/* 12 | 13 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 17 | ./tests/ 18 | 19 | 20 | 21 | 22 | ./src 23 | 24 | vendor 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Authnetjson/AuthnetAcceptJs.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | namespace Authnetjson; 15 | 16 | /** 17 | * Contains constant values. 18 | * 19 | * @package AuthnetJSON 20 | * @author John Conde 21 | * @copyright 2015 - 2023 John Conde 22 | * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0 23 | * @link https://github.com/stymiee/authnetjson 24 | * @see https://developer.authorize.net/api/reference/ 25 | */ 26 | class AuthnetAcceptJs 27 | { 28 | /** 29 | * @var string URL for Accept hosted form in the production environment 30 | */ 31 | public const PRODUCTION_HOSTED_PAYMENT_URL = 'https://accept.authorize.net/payment/payment'; 32 | 33 | /** 34 | * @var string URL for Accept hosted form in the sandbox environment 35 | */ 36 | public const SANDBOX_HOSTED_PAYMENT_URL = 'https://test.authorize.net/payment/payment'; 37 | 38 | /** 39 | * @var string URL for Accept hosted form in the production environment 40 | */ 41 | public const PRODUCTION_HOSTED_CIM_URL = 'https://accept.authorize.net/profile/manage'; 42 | 43 | /** 44 | * @var string URL for Accept hosted form in the sandbox environment 45 | */ 46 | public const SANDBOX_HOSTED_CIM_URL = 'https://test.authorize.net/profile/manage'; 47 | } 48 | -------------------------------------------------------------------------------- /src/Authnetjson/AuthnetJson.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | namespace Authnetjson; 15 | 16 | /** 17 | * Contains constant values. 18 | * 19 | * @package AuthnetJSON 20 | * @author John Conde 21 | * @copyright 2015 - 2023 John Conde 22 | * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0 23 | * @link https://github.com/stymiee/authnetjson 24 | * @see https://developer.authorize.net/api/reference/ 25 | */ 26 | class AuthnetJson 27 | { 28 | /** 29 | * @var int Subscription of endless length. 30 | */ 31 | public const BOUNDLESS_OCCURRENCES = 9999; 32 | } 33 | -------------------------------------------------------------------------------- /src/Authnetjson/AuthnetSim.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | namespace Authnetjson; 15 | 16 | use Authnetjson\Exception\AuthnetInvalidAmountException; 17 | use Exception; 18 | 19 | /** 20 | * Wrapper to simplify the creation of SIM data 21 | * 22 | * @author John Conde 23 | * @copyright 2015 - 2023 John Conde 24 | * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0 25 | * @link https://github.com/stymiee/authnetjson 26 | */ 27 | class AuthnetSim 28 | { 29 | /** 30 | * @var string Authorize.Net API login ID 31 | */ 32 | private $login; 33 | 34 | /** 35 | * @var string Authorize.Net API signature key 36 | */ 37 | private $signature; 38 | 39 | /** 40 | * @var string URL endpoint for processing a transaction 41 | */ 42 | private $url; 43 | 44 | /** 45 | * @var int Randomly generated number 46 | */ 47 | private $sequence; 48 | 49 | /** 50 | * @var int Unix timestamp the request was made 51 | */ 52 | private $timestamp; 53 | 54 | /** 55 | * Creates a SIM wrapper by setting the Authorize.Net credentials and URL of the endpoint to be used 56 | * for the API call 57 | * 58 | * @param string $login Authorize.Net API login ID 59 | * @param string $signature Authorize.Net API Transaction Key 60 | * @param string $api_url URL endpoint for processing a transaction 61 | * @throws Exception 62 | */ 63 | public function __construct(string $login, string $signature, string $api_url) 64 | { 65 | $this->login = $login; 66 | $this->signature = $signature; 67 | $this->url = $api_url; 68 | $this->resetParameters(); 69 | } 70 | 71 | /** 72 | * Returns the hash for the SIM transaction 73 | * 74 | * @param float $amount The amount of the transaction 75 | * @return string Hash of five different unique transaction parameters 76 | * @throws AuthnetInvalidAmountException 77 | */ 78 | public function getFingerprint(float $amount): string 79 | { 80 | if (!filter_var($amount, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND)) { 81 | throw new AuthnetInvalidAmountException('You must enter a valid amount greater than zero.'); 82 | } 83 | 84 | return strtoupper( 85 | hash_hmac( 86 | 'sha512', 87 | sprintf( 88 | '%s^%s^%s^%s^', 89 | $this->login, 90 | $this->sequence, 91 | $this->timestamp, 92 | $amount 93 | ), 94 | hex2bin($this->signature) 95 | ) 96 | ); 97 | } 98 | 99 | /** 100 | * Returns the sequence generated for a transaction 101 | * 102 | * @return int Current sequence 103 | */ 104 | public function getSequence(): int 105 | { 106 | return $this->sequence; 107 | } 108 | 109 | /** 110 | * Returns the timestamp for a transaction 111 | * 112 | * @return int Current timestamp 113 | */ 114 | public function getTimestamp(): int 115 | { 116 | return $this->timestamp; 117 | } 118 | 119 | /** 120 | * Returns the account login ID 121 | * 122 | * @return string API login ID 123 | */ 124 | public function getLogin(): string 125 | { 126 | return $this->login; 127 | } 128 | 129 | /** 130 | * Returns the url endpoint for the transaction 131 | * 132 | * @return string url endpoint 133 | */ 134 | public function getEndpoint(): string 135 | { 136 | return $this->url; 137 | } 138 | 139 | /** 140 | * Resets the sequence and timestamp 141 | * 142 | * @throws Exception 143 | */ 144 | public function resetParameters(): void 145 | { 146 | $this->sequence = random_int(1, 1000); 147 | $this->timestamp = time(); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /src/Authnetjson/AuthnetWebhook.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | namespace Authnetjson; 15 | 16 | use Authnetjson\Exception\AuthnetInvalidCredentialsException; 17 | use Authnetjson\Exception\AuthnetInvalidJsonException; 18 | 19 | /** 20 | * Handles a Webhook notification from the Authorize.Net Webhooks API 21 | * 22 | * @package AuthnetJSON 23 | * @author John Conde 24 | * @copyright 2015 - 2023 John Conde 25 | * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0 26 | * @link https://github.com/stymiee/authnetjson 27 | * @see https://developer.authorize.net/api/reference/ 28 | */ 29 | class AuthnetWebhook 30 | { 31 | /** 32 | * @var object SimpleXML object representing the Webhook notification 33 | */ 34 | private $webhook; 35 | 36 | /** 37 | * @var string JSON string that is the Webhook notification sent by Authorize.Net 38 | */ 39 | private $webhookJson; 40 | 41 | /** 42 | * @var array HTTP headers sent with the notification 43 | */ 44 | private $headers; 45 | 46 | /** 47 | * @var string Authorize.Net Signature Key 48 | */ 49 | private $signature; 50 | 51 | /** 52 | * Creates the response object with the response json returned from the API call 53 | * 54 | * @param string $signature Authorize.Net Signature Key 55 | * @param string $payload Webhook Notification sent by Authorize.Net 56 | * @param array $headers HTTP headers sent with Webhook. Optional if PHP is run as an Apache module 57 | * @throws AuthnetInvalidCredentialsException 58 | * @throws AuthnetInvalidJsonException 59 | */ 60 | public function __construct(string $signature, string $payload, array $headers = []) 61 | { 62 | $this->signature = $signature; 63 | $this->webhookJson = $payload; 64 | $this->headers = $headers; 65 | if (empty($this->headers)) { 66 | $this->headers = $this->getAllHeaders(); 67 | } 68 | if (empty($this->signature)) { 69 | throw new AuthnetInvalidCredentialsException('You have not configured your signature properly.'); 70 | } 71 | if (($this->webhook = json_decode($this->webhookJson, false)) === null) { 72 | throw new AuthnetInvalidJsonException('Invalid JSON sent in the Webhook notification'); 73 | } 74 | $this->headers = array_change_key_case($this->headers, CASE_UPPER); 75 | } 76 | 77 | /** 78 | * Outputs the response JSON in a human-readable format 79 | * 80 | * @return string HTML table containing debugging information 81 | */ 82 | public function __toString() 83 | { 84 | $output = '' . "\n"; 85 | $output .= '' . "\n"; 86 | $output .= '' . "\n"; 87 | $output .= '' . "\n"; 90 | $output .= '' . "\n"; 91 | $output .= '' . "\n"; 94 | $output .= '
Authorize.Net Webhook
Response HTTP Headers
' . "\n";
 88 |         $output .= var_export($this->headers, true) . "\n";
 89 |         $output .= '
Response JSON
' . "\n";
 92 |         $output .= $this->webhookJson . "\n";
 93 |         $output .= '
'; 95 | 96 | return $output; 97 | } 98 | 99 | /** 100 | * Gets a response variable from the Webhook notification 101 | * 102 | * @param string $var 103 | * @return string requested variable from the API call response 104 | */ 105 | public function __get(string $var) 106 | { 107 | return $this->webhook->{$var}; 108 | } 109 | 110 | /** 111 | * Validates a webhook signature to determine if the webhook is valid 112 | * 113 | * @return bool 114 | */ 115 | public function isValid(): bool 116 | { 117 | $hashedBody = strtoupper(hash_hmac('sha512', $this->webhookJson, $this->signature)); 118 | return (isset($this->headers['X-ANET-SIGNATURE']) && 119 | strtoupper(explode('=', $this->headers['X-ANET-SIGNATURE'])[1]) === $hashedBody); 120 | } 121 | 122 | /** 123 | * Validates a webhook signature to determine if the webhook is valid 124 | * 125 | * @return string|null 126 | */ 127 | public function getRequestId(): ?string 128 | { 129 | return $this->headers['X-REQUEST-ID'] ?? null; 130 | } 131 | 132 | /** 133 | * Retrieves all HTTP headers of a given request 134 | * 135 | * @return array 136 | */ 137 | protected function getAllHeaders(): array 138 | { 139 | if (function_exists('apache_request_headers')) { 140 | $headers = apache_request_headers(); 141 | } else { 142 | $headers = []; 143 | foreach ($_SERVER as $key => $value) { 144 | if (strpos($key, 'HTTP_') === 0) { 145 | $headers[str_replace('_', '-', substr($key, 5))] = $value; 146 | } 147 | } 148 | } 149 | return $headers ?: []; 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /src/Authnetjson/Exception/AuthnetCannotSetParamsException.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | namespace Authnetjson\Exception; 15 | 16 | /** 17 | * Exception that is throw when client code attempts to set a parameter directly (i.e. using __set()) 18 | * 19 | * echo $response->isError() AuthnetJSON 20 | * 21 | * @author John Conde 22 | * @copyright 2015 - 2023 John Conde 23 | * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0 24 | * @link https://github.com/stymiee/authnetjson 25 | */ 26 | class AuthnetCannotSetParamsException extends AuthnetException 27 | { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/Authnetjson/Exception/AuthnetCurlException.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | namespace Authnetjson\Exception; 15 | 16 | /** 17 | * Exception that is throw when cURL experiences an unexpected error 18 | * 19 | * @author John Conde 20 | * @copyright John Conde 21 | * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0 22 | * @link https://github.com/stymiee/authnetjson 23 | */ 24 | class AuthnetCurlException extends AuthnetException 25 | { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/Authnetjson/Exception/AuthnetException.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | namespace Authnetjson\Exception; 15 | 16 | use Exception; 17 | use Throwable; 18 | 19 | /** 20 | * Generic Exception that may be thrown whenever an unexpect error occurs using the AuthnetJson class 21 | * 22 | * @author John Conde 23 | * @copyright 2015 - 2023 John Conde 24 | * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0 25 | * @link https://github.com/stymiee/authnetjson 26 | */ 27 | class AuthnetException extends Exception 28 | { 29 | public function __construct(string $message = '', int $code = 0, Throwable $previous = null) 30 | { 31 | parent::__construct($message, $code, $previous); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Authnetjson/Exception/AuthnetInvalidAmountException.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | namespace Authnetjson\Exception; 15 | 16 | /** 17 | * Exception that is thrown when invalid amount to pay is provided for a SIM transaction 18 | * 19 | * @author John Conde 20 | * @copyright 2015 - 2023 John Conde 21 | * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0 22 | * @link https://github.com/stymiee/authnetjson 23 | */ 24 | class AuthnetInvalidAmountException extends AuthnetException 25 | { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/Authnetjson/Exception/AuthnetInvalidCredentialsException.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | namespace Authnetjson\Exception; 15 | 16 | /** 17 | * Exception that is throw when invalid Authorize.Net API credentials are provided 18 | * 19 | * @author John Conde 20 | * @copyright 2015 - 2023 John Conde 21 | * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0 22 | * @link https://github.com/stymiee/authnetjson 23 | */ 24 | class AuthnetInvalidCredentialsException extends AuthnetException 25 | { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/Authnetjson/Exception/AuthnetInvalidJsonException.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | namespace Authnetjson\Exception; 15 | 16 | /** 17 | * Exception that is throw when invalid JSON is returned by the API 18 | * 19 | * @author John Conde 20 | * @copyright John Conde 21 | * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0 22 | * @link https://github.com/stymiee/authnetjson 23 | */ 24 | class AuthnetInvalidJsonException extends AuthnetException 25 | { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/Authnetjson/Exception/AuthnetInvalidServerException.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | namespace Authnetjson\Exception; 15 | 16 | /** 17 | * Exception that is throw when an invalid value is given for the $server parameter when 18 | * initiating an instance of the AuthnetJson class 19 | * 20 | * @author John Conde 21 | * @copyright 2015 - 2023 John Conde 22 | * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0 23 | * @link https://github.com/stymiee/authnetjson 24 | */ 25 | class AuthnetInvalidServerException extends AuthnetException 26 | { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/Authnetjson/Exception/AuthnetTransactionResponseCallException.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | namespace Authnetjson\Exception; 15 | 16 | /** 17 | * Exception that is throw when transaction response data is requested on an API call that does not return any 18 | * 19 | * @author John Conde 20 | * @copyright 2015 - 2023 John Conde 21 | * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0 22 | * @link https://github.com/stymiee/authnetjson 23 | */ 24 | class AuthnetTransactionResponseCallException extends AuthnetException 25 | { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/Authnetjson/TransactionResponse.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | namespace Authnetjson; 15 | 16 | /** 17 | * Adapter for the Authorize.Net JSON API 18 | * 19 | * @package AuthnetJSON 20 | * @author John Conde 21 | * @copyright 2015 - 2023 John Conde 22 | * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0 23 | * @link https://github.com/stymiee/authnetjson 24 | * @see https://developer.authorize.net/api/reference/ 25 | */ 26 | class TransactionResponse 27 | { 28 | /** 29 | * @var array Transaction response fields to map to values parsed from a transaction response string 30 | */ 31 | private static $fieldMap = [ 32 | 1 => 'ResponseCode', 33 | 2 => 'ResponseSubcode', 34 | 3 => 'ResponseReasonCode', 35 | 4 => 'ResponseReasonText', 36 | 5 => 'AuthorizationCode', 37 | 6 => 'AVSResponse', 38 | 7 => 'TransactionID', 39 | 8 => 'InvoiceNumber', 40 | 9 => 'Description', 41 | 10 => 'Amount', 42 | 11 => 'Method', 43 | 12 => 'TransactionType', 44 | 13 => 'CustomerID', 45 | 14 => 'FirstName', 46 | 15 => 'LastName', 47 | 16 => 'Company', 48 | 17 => 'Address', 49 | 18 => 'City', 50 | 19 => 'State', 51 | 20 => 'ZipCode', 52 | 21 => 'Country', 53 | 22 => 'Phone', 54 | 23 => 'Fax', 55 | 24 => 'EmailAddress', 56 | 25 => 'ShipToFirstName', 57 | 26 => 'ShipToLastName', 58 | 27 => 'ShipToCompany', 59 | 28 => 'ShipToAddress', 60 | 29 => 'ShipToCity', 61 | 30 => 'ShipToState', 62 | 31 => 'ShipToZip', 63 | 32 => 'ShipToCountry', 64 | 33 => 'Tax', 65 | 34 => 'Duty', 66 | 35 => 'Freight', 67 | 36 => 'TaxExempt', 68 | 37 => 'PurchaseOrderNumber', 69 | 38 => 'MD5Hash', 70 | 39 => 'CardCodeResponse', 71 | 40 => 'CardholderAuthenticationVerificationResponse', 72 | 51 => 'AccountNumber', 73 | 52 => 'CardType', 74 | 53 => 'SplitTenderID', 75 | 54 => 'AmountRequested', 76 | 55 => 'BalanceOnCard' 77 | ]; 78 | 79 | /** 80 | * @var array Transaction response fields to map to values parsed from a transaction response string 81 | */ 82 | private $responseArray; 83 | 84 | /** 85 | * Creates out TransactionResponse object and assigns the response variables to an array 86 | * 87 | * @param string $response Comma delimited transaction response string 88 | */ 89 | public function __construct(string $response) 90 | { 91 | $this->responseArray = array_merge([null], explode(',', $response)); 92 | } 93 | 94 | /** 95 | * Gets the requested value out of the response array using the provided key. The location of that value 96 | * can be accessed via its numerical location in the array (starting at zero) or using the key for that field 97 | * as defined by Authorize.Net and mapped in self::$fieldMap. 98 | * 99 | * @param mixed $field Name or key of the transaction field to be retrieved 100 | * @return string Transaction field to be retrieved 101 | */ 102 | public function getTransactionResponseField($field): ?string 103 | { 104 | $value = null; 105 | if (is_int($field)) { 106 | $value = $this->responseArray[$field] ?? $value; 107 | } elseif ($key = array_search($field, self::$fieldMap, true)) { 108 | $value = $this->responseArray[$key]; 109 | } 110 | return $value; 111 | } 112 | } 113 | --------------------------------------------------------------------------------