cancel
Showing results for 
Search instead for 
Did you mean: 

Return Order->InvoiceNum (or refTransID) w/ Accept Hosted Payment form

Problem:  Need guidance on returning the Order->InvoiceNum (or refTransID) while using Accept Hosted Payment form.  My attempt (see code below) is not working.  Not sure if I'm setting it incorrectly or returning it incorrectly.  If there's a way to do this with refTransId, that would be even better.

 

Background:

-I can successfully complete authcapture transactions using the Accept Hosted payment form.  I can also call the TransactionDetail and get a json payload. 

 

I'm sending my custom 'order id' (Session #) in the Order->Invoice number field when I do the authCapture transaction .  I tried to put it in both the reference ID field and the refTransID field with no luck.  Then I stumbled across a forum post (see below) where the admin says there's a known bug with the Accept Hosted Payment form where the refTransID is not currently working.   

 

This says to use transRefID:

https://community.developer.authorize.net/t5/Integration-and-Testing/quot-Webhook-quot-VS-quot-Silen...

 

This says transRefid has known bug.  Use Order->Invoice Number instead

https://community.developer.authorize.net/t5/Integration-and-Testing/RefID-not-being-returned-in-get...

 

Thanks

JJ

 

CODE TO SET THE ORDER

	$refId =  $_SESSION["SessionNumber"];  //Always unique - returned with the web hook
  //$refId =12345;
 $input_xml = '<getHostedPaymentPageRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
 <merchantAuthentication>
 <name>MyLogin</name>
 <transactionKey>MyTransKey</transactionKey>
 </merchantAuthentication>


 <transactionRequest>
 <transactionType>authCaptureTransaction</transactionType>
 <amount>';

// $input_xml .=3.50  .'</amount>

 $input_xml .= $_SESSION["ReceiptTotal"]  .'</amount>
 <order><invoiceNumber>';


 $input_xml .=  $refId  .'</invoiceNumber></order>

 </transactionRequest>
 
 <hostedPaymentSettings>
 
 <setting>
 <settingName>hostedPaymentBillingAddressOptions</settingName>
 <settingValue>{"show": false, "required":false}</settingValue>
 </setting>
 
 <setting>
 <settingName>hostedPaymentButtonOptions</settingName>
 <settingValue>{"text": "Pay"}</settingValue>
 </setting>
 
 <setting>
 <settingName>hostedPaymentReturnOptions</settingName>
 <settingValue>{ "showReceipt":true, "url":"https://xxxxx.org/IntCampReceiptSuccess.html","urlText":"Continue","cancelUrl":"https://xxxx.org/IntCampReceiptCancel.html","cancelUrlText":"Cancel"}</settingValue>
 </setting>
 
 <setting>
 <settingName>hostedPaymentPaymentOptions</settingName>
 <settingValue>{"cardCodeRequired": true, "showCreditCard": true, "showBankAccount": false}</settingValue>
 </setting>
 
 <setting>
 <settingName>hostedPaymentOrderOptions</settingName>	
 <settingValue>{"show": true, "merchantName": "xxxxx"}</settingValue>
 </setting>
 
 </hostedPaymentSettings>
 </getHostedPaymentPageRequest>';
 

 

CODE TO RETRIEVE THE ORDER

 

<?php
  require 'vendor/autoload.php';
  use net\authorize\api\contract\v1 as AnetAPI;
  use net\authorize\api\controller as AnetController;
  
  define("AUTHORIZENET_LOG_FILE", "phplog");

function getTransactionDetails($transactionId)
{
    /* Create a merchantAuthenticationType object with authentication details
       retrieved from the constants file */
    $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
 //   $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
 //   $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);

    $merchantAuthentication->setName('Mylogin');
   $merchantAuthentication->setTransactionKey('MyTranskey');	
	
    
    // Set the transaction's refId
    $refId = 'ref' . time();

    $request = new AnetAPI\GetTransactionDetailsRequest();
    $request->setMerchantAuthentication($merchantAuthentication);
    $request->setTransId($transactionId);
	$request->setrefId($refId);
  
    $controller = new AnetController\GetTransactionDetailsController($request);

    $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);

    if (($response != null) && ($response->getMessages()->getResultCode() == "Ok"))
    {
        echo "SUCCESS: Transaction Status:" . $response->getTransaction()->getTransactionStatus() . "\n";
        echo "                Auth Amount:" . $response->getTransaction()->getAuthAmount() . "\n";
        echo "                   Trans ID:" . $response->getTransaction()->getTransId() . "\n";

NEXT LINE DOES NOT WORK
        echo "   Reference ID/Session Num:" . $response->getTransaction()->getOrder() . "\n";		
     }
    else
    {
        echo "ERROR :  Invalid response\n";
        $errorMessages = $response->getMessages()->getMessage();
        echo "Response : " . $errorMessages[0]->getCode() . "  " .$errorMessages[0]->getText() . "\n";
    }

    return $response;
  }

  if(!defined('DONT_RUN_SAMPLES'))
  
    getTransactionDetails("123456...");
?>
jjauthnet
Member
0 REPLIES 0