cancel
Showing results for 
Search instead for 
Did you mean: 

Accept Hosted Redirect Method Not get Transaction details on success page

Hi,

   

   I have configured Authorize.net API using Accepted Hosted payment method using Redirect method for a secure checkout . To impletent Accepted Hosted Payment we follow these steps :

- As per the api and documentation for the first step, we formed the refId,price,url,cancel url details and got the token.
- The along with the token we posted the form to authorize.net server. There once we entered the card details and other things, after receipt page we come back to our success url.
- At the time when we navigate to our server (on success page) we cant get any transaction details like transId etc.
- As per the api references, to get any transaction details we need transId to get the details.

 

I have used Redirect Method , not IFrameCommunicator. So please provide me solution using redirect method. Please check my code and tell me what parameter are missed from my side?

 

<?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 getAnAcceptPaymentPage()
{
  
    // Common setup for API credentials 
  $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();  
  $merchantAuthentication->setName(MERCHANT_LOGIN_ID);  
  $merchantAuthentication->setTransactionKey(MERCHANT_TRANSACTION_KEY);  
   
    // Set the transaction's refId
    $refId = 'ref' . time();
   
    // Set the customer's Bill To address
    $customerAddress = new AnetAPI\CustomerAddressType();
    $customerAddress->setFirstName("Ellen");
    $customerAddress->setLastName("Johnson");
    $customerAddress->setCompany("Souveniropolis");
    $customerAddress->setAddress("14 Main Street");
    $customerAddress->setCity("Pecan Springs");
    $customerAddress->setState("TX");
    $customerAddress->setZip("44628");
    $customerAddress->setCountry("USA");

    // Set the customer's identifying information
    $customerData = new AnetAPI\CustomerDataType();
    $customerData->setType("individual");
    $customerData->setId("99999456654");
    $customerData->setEmail("EllenJohnson@example.com");
       
    //create a transaction
    $transactionRequestType = new AnetAPI\TransactionRequestType();
    $transactionRequestType->setTransactionType("authCaptureTransaction");
    $transactionRequestType->setAmount("12.00");
    $transactionRequestType->setBillTo($customerAddress);
    $transactionRequestType->setCustomer($customerData);
       
    // Set Hosted Form options
    $setting1 = new AnetAPI\SettingType();
    $setting1->setSettingName("hostedPaymentButtonOptions");
    $setting1->setSettingValue("{\"text\": \"Pay\"}");
    $setting2 = new AnetAPI\SettingType();
    $setting2->setSettingName("hostedPaymentOrderOptions");
    $setting2->setSettingValue("{\"show\": true}");
    $setting3 = new AnetAPI\SettingType();
    $setting3->setSettingName("hostedPaymentReturnOptions");
    $setting3->setSettingValue("{\"url\": \"http://localhost/soap_api/Payment_Gateway_API/receipt.php\", \"cancelUrl\": \"http://localhost/soap_api/Payment_Gateway_API/cancel.php\", \"showReceipt\": true}");
    // Build transaction request
    $request = new AnetAPI\GetHostedPaymentPageRequest();
    $request->setMerchantAuthentication($merchantAuthentication);
    $request->setRefId($refId);
    $request->setTransactionRequest($transactionRequestType);
    $request->addToHostedPaymentSettings($setting1);
    $request->addToHostedPaymentSettings($setting2);
    $request->addToHostedPaymentSettings($setting3);
   
    //execute request
    $controller = new AnetController\GetHostedPaymentPageController($request);
    $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
   
    if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) {
    
        return $response->getToken();
    } else {
        echo "ERROR :  Failed to get hosted payment page token\n";
        $errorMessages = $response->getMessages()->getMessage();
        echo "RESPONSE : " . $errorMessages[0]->getCode() . "  " .$errorMessages[0]->getText() . "\n";
    }
    return $response;
}

 

if (!defined('DONT_RUN_SAMPLES')) {
 $val=getAnAcceptPaymentPage();

}

?>

<div id="iframe_holder" class="center-block" style="width:90%;max-width: 1000px" data-mediator="payment-form-loader">   
    <form id="send_hptoken" name="authForm" action="https://test.authorize.net/payment/payment" method="post" target="load_payment">
        <input type="hidden" name="token" value="<?php echo $val; ?>" />      
    </form>
    <script>
document.authForm.submit();
</script>

 

Thank You!

gitamaurya
Member
4 REPLIES 4

Hi,

  

     Payment done successfully, i also received merchant's email receipt of payment but i don't receive any response data of payment transaction on receipt page. Please tell me how to get transaction detail like transaction ID etc on success page?

 

Thank You!

gitamaurya
Member

For the Accept Hosted method, in order to get transaction information, like transId, you need to use an iframe or lightbox with a hostedPaymentIFrameCommunicatorUrl specified, as that is where the details get passed through.

 

Alternatively, you can register for Webhooks to receive real-time notifications when transactions are either declined or approved.

Powered by NexWebSites.com -
Certified Authorize.net developers

Hi,

 

    I have successfully implemented Hosted Payment Gateway in our panel. So Now we want to add Automated Recurring Billing in our panel . Can you tell me it is possible to add Hosted Automated Recurring Billing instead of API at our panel.

 

Thank You!

gitamaurya
Member

hi,

 

   i want to create secure Automated Recurring Billing subscription using Authorize.net API from our panel. Please give suggestions regarding to implement secure Automated Recurring Billing subscription in our solutions.

 

Thank You!