Jump to content
  • 0

After payment callback does not return to invoice automatically


Shaz3e

Question

Hello,

I am developing a third party payment gateway where customer can pay through Mobile Account/Shop/CreditCard I am good till I submit the payment but when it returns to success/failure payment the callback shows blank page if I use 'header("Location: http://test.com/whmcs/viewinvoice.php?id=123");' the invoice gets updates but does not show information message i.e. Thank you! Up on successfull transaction and error message when the transaction is failed. What is a good practice to redirect from callback.php to invoice page without using an extra function? For reference integration guide and payment gateway is attached to this post.

Any help would be appreciated.

Merchant Integration Guide.pdf

gateways.zip

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

I understand that you need to display a success/failure message of payment when redirecting to view invoice page, correct me if I'm wrong.

you could use one of these URLs when redirecting your client to view invoice page:

http://test.com/whmcs/viewinvoice.php?id=123&paymentsuccess=true

http://test.com/whmcs/viewinvoice.php?id=123&paymentfailed=true

Link to comment
Share on other sites

  • 0

You are absolutely right, Thank you for your time for understanding my problem. What I want to know to redirect to the invoice page with prebuilt WHMCS function or should I use header() function for this purpose.

Now I want to know if there is any pre-built function in WHMCS so the user will be redirected to the invoice page and then shows a message.

Link to comment
Share on other sites

  • 0

Thank you for your time answering my question. but I can see the code under viewinvoice.tpl how can I use default code instead of my own custom code.

{php}

            {if $paymentSuccessAwaitingNotification}
                {include file="$template/includes/panel.tpl" type="success" headerTitle=$LANG.success bodyContent=$LANG.invoicePaymentSuccessAwaitingNotify bodyTextCenter=true}
            {elseif $paymentSuccess}
                {include file="$template/includes/panel.tpl" type="success" headerTitle=$LANG.success bodyContent=$LANG.invoicepaymentsuccessconfirmation bodyTextCenter=true}
            {elseif $pendingReview}
                {include file="$template/includes/panel.tpl" type="info" headerTitle=$LANG.success bodyContent=$LANG.invoicepaymentpendingreview bodyTextCenter=true}
            {elseif $paymentFailed}
                {include file="$template/includes/panel.tpl" type="danger" headerTitle=$LANG.error bodyContent=$LANG.invoicepaymentfailedconfirmation bodyTextCenter=true}
            {elseif $offlineReview}
                {include file="$template/includes/panel.tpl" type="info" headerTitle=$LANG.success bodyContent=$LANG.invoiceofflinepaid bodyTextCenter=true}
            {/if}

{/php}

 

Edited by WHMCS ChrisD
Added code to PHP Code Box
Link to comment
Share on other sites

  • 0

Thank you for your time answering my question. but I can see the code under viewinvoice.tpl how can I use default code instead of my own custom code.

{if $paymentSuccessAwaitingNotification}
    {include file="$template/includes/panel.tpl" type="success" headerTitle=$LANG.success bodyContent=$LANG.invoicePaymentSuccessAwaitingNotify bodyTextCenter=true}
{elseif $paymentSuccess}
    {include file="$template/includes/panel.tpl" type="success" headerTitle=$LANG.success bodyContent=$LANG.invoicepaymentsuccessconfirmation bodyTextCenter=true}
{elseif $pendingReview}
    {include file="$template/includes/panel.tpl" type="info" headerTitle=$LANG.success bodyContent=$LANG.invoicepaymentpendingreview bodyTextCenter=true}
{elseif $paymentFailed}
    {include file="$template/includes/panel.tpl" type="danger" headerTitle=$LANG.error bodyContent=$LANG.invoicepaymentfailedconfirmation bodyTextCenter=true}
{elseif $offlineReview}
    {include file="$template/includes/panel.tpl" type="info" headerTitle=$LANG.success bodyContent=$LANG.invoiceofflinepaid bodyTextCenter=true}
{/if}

 

Link to comment
Share on other sites

  • 0

the following URLs will redirect you to view invoice and display the built-in message of success/failure payment:

On 2/2/2018 at 1:26 AM, sentq said:

other options you see in tpl file doesn't work in the same way, but maybe you can try activating them using ActionHook:ClientAreaPageViewInvoice

<?php

add_hook('ClientAreaPageViewInvoice', 1, function($vars) {
    // Display Payment Pending Message if the "pendingreview" specified in the view invoice URL
	if (isset($_GET['pendingreview'])){
    	return array("pendingReview" => true);
    }
});

 

Link to comment
Share on other sites

  • 0

Thank you for helping me in this way.

Now I am getting success/failure message according to the parameters in the URL now I want to know I am using the following code to return on the invoice page I hope I am following the right direction.

<?php
if ( $success ) {
    addInvoicePayment(
        $invoiceId,
        $transactionId,
        $paymentAmount,
        $paymentFee,
        $gatewayModuleName
    );
?>
    <form method="GET" action="<?php echo $gatewayParams['systemurl'] . 'viewinvoice.php';?>" id="PaymentSuccessFul">
        <input type="hidden" name="id" value="<?php echo $invoiceId;?>">
        <input type="hidden" name="paymentsuccess" value="true">
    </form>
    <script>
        (function(){
            document.getElementById("PaymentSuccessFul").submit();
        })();
    </script>
<?php }else{ ?>
    <form method="GET" action="<?php echo $gatewayParams['systemurl'] . 'viewinvoice.php';?>" id="PaymentFailed">
        <input type="hidden" name="id" value="<?php echo $invoiceId;?>">
        <input type="hidden" name="paymentfailed" value="true">
    </form>
    <script>
        (function(){
            document.getElementById("PaymentFailed").submit();
        })();
    </script>
<?php } ?>
?>

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated