php - authorize.net hello world Charge Credit Card ERROR : Invalid response -


trying hello world example authorize.net work

composer installed here json. identical example.

{ "require": {     "symfony/console": "^3.3",     "php": ">=5.6",     "ext-curl": "*",     "authorizenet/authorizenet": ">=1.9.3"     } } 

the following cut & pasted ssh

>composer update loading composer repositories package information updating dependencies (including require-dev) nothing install or update writing lock file generating autoload files 

the thing i've changed in hello world php example sandbox login id , transaction key , path vendor/autoload.php.

what missing here example return other

charge credit card error : invalid response

solution problem rather simple. posting solution here pay forward. first, need basic working composer.json

{ "require": {     "symfony/console": "^3.3",     "authorizenet/authorizenet": ">=1.9.3"     } } 

you don't need symphony. way, i'm running php 5.6 , tls 1.2, required.

second, there scope issue in example code. here first few lines of charge credit card example code, works in authorize.net browser sandbox fine.

function chargecreditcard($amount) {  $merchantauthentication = new anetapi\merchantauthenticationtype(); $merchantauthentication->setname(\samplecode\constants::merchant_login_id); $merchantauthentication->settransactionkey(\samplecode\constants::merchant_transaction_key); 

here changed in php script did not work.

    function chargecreditcard(){      $merchantauthentication = new anetapi\merchantauthenticationtype();     $merchantauthentication->setname($authorizeloginid);     $merchantauthentication->settransactionkey($authorizetranskey);  

here changed work.

    function chargecreditcard(){      global $authorizeloginid, $authorizetranskey;      $merchantauthentication = new anetapi\merchantauthenticationtype();     $merchantauthentication->setname($authorizeloginid);     $merchantauthentication->settransactionkey($authorizetranskey);  

kinda mad @ myself not seeing scope issue credentials sooner, figured out process of elimination.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -