0

I am developing a custom payment gateway module for ubercart, I am able to complete an order on the third party payment system using their api and its working fine, the problem I am facing is how to save that completed order in the database. If we will see in paypal payment gateway for ubercart when we complete an order, Under store option we have an option to view the orders and there status (please check screenshot below), this is the same thing I want to achieve, in-short how can I keep track of orders processed through a custom payment gateway.

Same thing I want to achieve

I know there is a hook uc_order_save($order) in ubercart, but I am confused how to implement it, so that it can interact with the internal values of ubercart orders. I am sure there will be a way in ubercart to achieve it.

0

You do not need to implement that hook.

First you need to be sure whether the payment service method is gateway or redirect. Depending on this, the payment complete function is different.

Within that function, regardless how it is implemented, here is a list of functions that are helpful.

This function is utilized by the default checkout system and can be used by third party checkout integration modules to complete a sale.

to leave comments in the order regarding the payment outcome, as well as watchdog()

This function logs a payment for an order in the payment receipts table.

0

Hi I added the below code but still the order is not recorded

function my_pay_gateway_menu() { $items['paymentcomplete'] = array( 'title' => 'Payment Complete', 'page callback' => 'my_pay_gateway_complete', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); return $items; }

function my_pay_gateway_complete() {

if (empty($_POST)) { watchdog('My Payment Gateway', 'Received an empty or incomplete response. Response details: @request_details', array('@request_details' => print_r($_POST,true)), WATCHDOG_ERROR);

return 'There was a problem with your payment';

}

if ($_POST['status'] == 'SUCCESS') {

// Assuming all tests passed and payment was successful // Complete the order uc_payment_enter($order_id, 'my_pay_gateway', $amount, $order->uid, NULL, $orderId);

uc_cart_complete($order, variable_get('uc_new_customer_login', FALSE));

uc_order_comment_save($order_id, $uid, $message, $type = 'admin', $status = 1, $notify = FALSE);

uc_cart_empty(uc_cart_get_id()); 


return 'Thank you for your purchase';

} }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.