Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7730603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:15:59+00:00 2026-06-01T06:15:59+00:00

I have the following code in my simple ubercart payment gateway module to redirect

  • 0

I have the following code in my simple ubercart payment gateway module to redirect it to my merchant payment form after checkout:

  $data = array(
  'merchantId' => "1",  
  'amount' => $total,
  'orderRef' => $order->order_id,
  'currCode' => 608,
  'successUrl' => 'http://mydomain.com/cart/checkout/complete',
  'failUrl' => 'http://mydomain.com/Fail.html',
  'cancelUrl' => 'http://mydomain.com/Cancel.html',
  'payType' => 'N',
  'lang' => 'E',
  'pdesc' => t('You have !num_of_products products in your cart', array('!num_of_products' => count($order->products))),
);

$form['#action'] = 'https://test.mymerchantgateway.com/payment/pay.jsp';

In the code above I can initiate payment successfully. The problem is on how to return to my site and mark the order as complete. After some research, I added “http://mydomain.com/cart/checkout/complete” as the return url to my site but it’s not working.

Any know what is the correct return url in order to mark the ubercart order after checkout as complete?

I am using drupal 6.0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:16:00+00:00Added an answer on June 1, 2026 at 6:16 am

    If this is your custom payment module, you have to create your own redirect url
    (you can create one for all cases [success, error, cancel] and redirect upon status message returned):

    1.Specify a menu callback and a function to catch the POST variables returned by your payment gateway

    e.g for module name: uc_mypayment

    /**
     * Implementation of hook_menu().
     */
    function uc_mypayment_menu() {
      $items['cart/mypayment/complete'] = array(
        'title' => 'Order complete',
        'page callback' => 'uc_mypayment_complete',
        'access callback' => 'uc_mypayment_completion_access',
        'type' => MENU_CALLBACK,
        'file' => 'uc_mypayment.pages.inc',
      );
    }
    

    2.Then you have to implement the callback function which is the one that handles the returned variables:

    function uc_mypayment_complete($cart_id = 0) {
      $order_id = check_plain($_POST['Param1']);
      $payment_status = check_plain($_POST['Result']);
      $payment_amount = check_plain($_POST['Charge']);
      $payment_currency = check_plain($_POST['Currency']);
      $ErrorMessage = check_plain($_POST['ErrorMessage']);
      ...
    }
    

    tweak it according to your gateway protocol.

    3.Depending on the status and message you get back, you may redirect to the corresponding status page (i.e success, error, cancel) e.g

    //assuming you have saved your success, error and cancel Urls into the variables: uc_mypayment_success_return_url, uc_mypayment_error_return_url, uc_mypayment_cancel_return_url
    
    switch ($payment_status) {
        case 1: // successful transaction
            $comment = t('MyPaymentGateway transaction ID: @PayId', array('@PayId' => $PayId));
            uc_payment_enter($order->order_id, 'myPaymentGateway', $payment_amount, $order->uid, NULL, $comment);
            uc_cart_complete_sale($order);
            uc_order_comment_save($order->order_id, 0, t('Payment of @amount @currency submitted through myPaymentGateway.', array('@amount' =>   $price , '@currency' => $payment_currency)), 'order', 'payment_received');
            uc_order_comment_save($order->order_id, 0, t('MyPaymentGateway reported a payment of @amount @currency', array('@amount' =>   $payment_amount , '@currency' => $payment_currency)));
            drupal_set_message($debugmessage . t('Your payment was completed.'));
            drupal_goto(variable_get('uc_mypayment_success_return_url', 'cart'));
            break;  
        case 2: //error
            $message = $debugmessage . t("Your payment failed with following error message: @Error", array('@Error' => $ErrorMessage));
            uc_order_comment_save($order->order_id, 0, $message, 'admin');
            drupal_set_message($message . t(' Please try again in a few moments.'));
            drupal_goto(variable_get('uc_mypayment_error_return_url', 'cart'));
        break;
        case 3: //user cancelled
            uc_order_comment_save($order->order_id, 0, t("The customer cancelled payment."), 'order', 'canceled' );
            drupal_set_message($debugmessage .t('Your payment was cancelled. Please feel free to continue shopping or contact us for assistance.'));
            unset($_SESSION['cart_order']);
            drupal_goto(variable_get('uc_mypayment_cancel_return_url', 'cart'));
        break;
    }
    

    Now you can just supply one url for all cases, in this example: cart/mypayment/complete

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following very simple code: html <a data-bind=enable: selected() href=http://www.google.com>Click Me</a> javascript
I have the following simple code: var tabs = null; function addTab(id, title, data)
i have the following simple code, but it doesn,t work <ul> <li id=one onmouseover=this.style.background-color='white';>
I have the following simple code abstract class A { public abstract void Test(Int32
I have the simple following code, which is working in a ruby (not rails)
I have the following code (correct for my simple tests) for a linked list
I have used following code to create a simple PDF file. It executes fine
I have the following code that fills dataTable1 and dataTable2 with two simple SQL
I have the following simple Java code: package testj; import java.util.*; public class Query<T>
I have the following PHP code doing a very simple select into a table.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.