cancel
Showing results for 
Search instead for 
Did you mean: 

TOKEN RECEIVED NEXT STEPS ?

I receive my token just fine, what are the next steps to set up the form fields for the post to

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

 

Do I call certain API's, a little confused by the docs on this REST interface?  

 

When I call :

$lineItem1 = new AnetAPI\LineItemType();

$lineItem1->setItemId($item_id);

...

$an_tranobj->addToLineItems($lineItem1);

Is this really generating the XML to be sent.

 

Do I need to use the API to correctly generate the XML for AN to accept it?

 

I have had a working version som SIM for over 8 years and the conversion is causing lots of problems, I use REST interfaces on other interfaces and they usually create a code example of a start to finish, I have looked at the ones on GitHub, but they all seem to assume facts not in evidence!

 

I am hoping one of you experts can lend me a hand on this.

 

Jim

 

 

 

jmd804500
Contributor
12 REPLIES 12

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);

 

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>
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?