Reply
Member
Posts: 8
Registered: ‎03-11-2019

Re: TOKEN RECEIVED NEXT STEPS ?

[ Edited ]

NO pure PHP, and the API via   And I do get a token back, then post page as per docs to

https://apitest.authorize.net/xml/v1/request.api

 

function get_an_token(AnetAPI\MerchantAuthenticationType $ma,$invoice,AnetAPI\TransactionR
equestType $an_obj,array $stary = null)
    {
       if(is_null($stary))
       {
           $stary = $this->get_form_option();
       }
       //-----------------------------------------------------------
       //
       //-----------------------------------------------------------
       $ma = $this->merchant_authenticate();

       $request = new AnetAPI\GetHostedPaymentPageRequest();
       $request->setMerchantAuthentication($ma);

       $request->setRefId($invoice);//refId is the invioce

       $request->setTransactionRequest($an_obj);
       $stary = $this->get_form_options();
       if(count($stary) > 0)
       {
           foreach($stary as $skey => $sval)
           {
               if($this->DEBUG)
               {
                   $this->logEvent("INFO: SKEY[".$skey."]");
               }
               $request->addToHostedPaymentSettings($sval);
           }
       }
       //-----------------------------------------------------------
       //EXECUTE REQUEST
       //-----------------------------------------------------------
       $controller = new AnetController\GetHostedPaymentPageController($request);
       if($this->mode == '1' or $this->mode == '4')
       {
           $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEn
vironment::SANDBOX);
       }
       elseif($this->mode == '3')
       {
           $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEn
vironment::PRODUCTION);

}
       else
       {
           $this->logEvent("ERROR: UNKNOWN MODE[".$this->mode."] ***** SPECIFIED *****");
           return;
       }
       //-----------------------------------------------------------
       //SET RESPONSE
       //-----------------------------------------------------------
       if (($response != null) && ($response->getMessages()->getResultCode() == "Ok"))
       {
           $this->token = $response->getToken();
           if($this->DEBUG){$this->logEvent("INFO: TOKEN RECEIVED[".$this->token."]");}
           $message = $response->getMessages()->getMessage();
           foreach($message as $mkey => $mval)
           {
               $this->logEvent("INFO: ".$message[$mkey]->getCode().
               " ".$message[$mkey]->getText());
           }
       }
       else
       {
           $this->logEvent("ERROR: Failed to get hosted payment page token");
           $error_message = $response->getMessages()->getMessage();
           $this->logEvent("ERROR: ".$error_message[0]->getCode()." ".$error_message[0]->getTe
xt());
       }
       return($response);

 

Member
Posts: 8
Registered: ‎03-11-2019

Re: TOKEN RECEIVED NEXT STEPS ?

HERE IS THE PAGE I GET BACK FROM AUTHORIZE.NET

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"> <head id="Head1"><title> Secure Information </title> <script type="text/javascript"> var g_token = "IE..TOKEN-HERE"; var g_merchantData = {"totalAmount":"62.5","currencySymbol":"$"}; var g_pageOptions = {"hostedPaymentButtonOptions":{"text":"Submit Payment"},"hostedPaymentStyleOptions":{"bgColor":"red"},"hostedPaymentOrderOptions":{"show":true,"merchantName":"Texas Girls Coaches Assoc."},"hostedPaymentReturnOptions":{"url":"http://tgca_dev.jdoherty.net/php/sadispatch.php?event=renew_ccpost; var g_paymentProfiles = null; var g_maxPaymentProfiles = false; var g_errorPanelMessage = "There was a technical issue processing your request."; var g_siteKey = "6Lc8tgYAAAAAAFfalsuPuIZ6bv_2dGT_Y9ZxURiK"; </script> <script type="text/javascript"> var g_EcheckEnabled = true; var g_CreditEnabled = true; </script> <base href="./Scripts/v1/"> </head> <body> <div class="PageOuter" id="divPageOuter"> <div id="divPopupScreen" class="PopupScreen" style="display:none;"></div> <div class="Page" id="divPage"> <div class="PageMain container" id="divPageMain container"> <app-accept-payment></app-accept-payment> <link href="styles.bundle.css" rel="stylesheet"/> <script type="text/javascript" src="inline.bundle.js"></script> <script type="text/javascript" src="polyfills.bundle.js"></script> <script type="text/javascript" src="scripts.bundle.js"></script> <script type="text/javascript" src="main.bundle.js"></script> </div> <div class="PageMainAfter"></div> </div> </div> </body> </html>
Highlighted
Trusted Contributor
Posts: 408
Registered: ‎11-05-2018

Re: TOKEN RECEIVED NEXT STEPS ?

Ok I see. It looked like php but not the typical style that I see it written in. I’ve heard that coldfusion is similar to php and I’ve seen smarty code that is a slightly modified version of php. Had I saw the rest of your code it would have made more sense.

I am thinking your error is due to not having an item id. If you print out the value for the item Id you are passing in your function, does it come up empty or null?