This function's called when a user completes the payment wizard in DineroMail, then it assumes the payment has been completed and informs this. However, completing the wizard in DineroMail may or may not mean the payment has been completed; some payment methods (Rapipago, Pagofacil, etc) need to be completed "offline". DineroMail marks these payments as pending, and this is what should be informed in these cases.
To fix it:
function uc_dineromail_success($cart_id = 0) {
$order->billing_street1 = $_POST['street_address'];
$order->billing_street2 = $_POST['street_address2'];
$order->city = $_POST['city'];
$order->billing_postal_code = $_POST['zip'];
$order->billing_phone = $_POST['phone'];
$zone_id = db_result(db_query("SELECT zone_id FROM {uc_zones} WHERE zone_code LIKE '%s'", $_POST['state']));
if (!empty($zone_id)) {
$order->billing_zone = $zone_id;
}
$country_id = db_result(db_query("SELECT country_id FROM {uc_countries} WHERE country_name LIKE '%s'", $_POST['country']));
if (!empty($zone_id)) {
$order->billing_country = $country_id;
}
if (strtolower($_POST['email']) !== strtolower($order->primary_email)) {
uc_order_comment_save($order->order_id, 0, t('Customer used a different e-mail address during payment: !email', array('!email' => check_plain($_POST['email']))), 'admin');
}
// Empty that cart...
uc_cart_empty($cart_id);
// Save changes to order without it's completion (it will be on finalization step)
uc_order_save($order);
$url = 'cart/dineromail/finalize/'. $order->order_id;
// Javascript redirect on the finalization page.
$output = '<script type="text/javascript">window.location = "'. url($url, array('absolute' => TRUE)) .'";</script>';
// Text link for users without Javascript enabled.
$output .= l(t('Click to complete checkout.'), $url, array('absolute' => TRUE));
print $output;
// exit();
}
function uc_dineromail_finalize() {
$order = uc_order_load(arg(3));
// Add a comment to let sales team know this came in through the site.
uc_order_comment_save($order->order_id, 0, t('Order created through website.'), 'admin');
$output = uc_cart_complete_sale($order, variable_get('uc_new_customer_login', FALSE));
$page = variable_get('uc_cart_checkout_complete_page', '');
if (!empty($page)) {
drupal_goto($page);
}
return $output;
}
to
function uc_dineromail_success($order_id = 0) {
$order = uc_order_load($order_id);
// If the order ID specified in the return URL is not the same as the one in
// the user's session, we need to assume this is either a spoof or that the
// user tried to adjust the order on this side while at PayPal. If it was a
// legitimate checkout, the IPN will still come in from PayPal so the order
// gets processed correctly. We'll leave an ambiguous message just in case.
if (intval($_SESSION['cart_order']) != $order->order_id) {
drupal_set_message(t('Thank you for your order! We will be notified by DineroMail that we have received your payment.'));
drupal_goto('cart');
}
// Ensure the payment method is DieroMail.
if ($order->payment_method != 'dineromail') {
drupal_goto('cart');
}
// This lets us know it's a legitimate access of the complete page.
$_SESSION['do_complete'] = TRUE;
drupal_goto('cart/checkout/complete');
}
Comments
Comment #1
anibalbenedetto commentedThe order should be completed using IPN.
The uc_dineromail_finalize() function is neither necessary nor safe.
Comment #2
alfonso100 commentedhi chirola83,
DineroMail doen't send IPN to ubercart once the payment is finished?
I am not receiving any notifications, all dinero mail payments remain as "in checkout"
Comment #3
didecus commentedHi chirola83 and alfonso100, i replace the function, but not receive any notification on my system, the payment remain in checkout... Any solution about it, thanks.
Comment #4
mpv commentedThis has been fixed in the 6.x-2.x branch. 6.x-1.x is no longer supported. The module now supports IPN notifications, orders are only completed when a notification for a successful payment arrives. See the project page for instructions on how to set up IPN notifications.