function test_gateway_charge in Ubercart 5
Same name and namespace in other branches
- 6.2 payment/uc_credit/test_gateway.module \test_gateway_charge()
- 7.3 payment/uc_credit/tests/test_gateway.module \test_gateway_charge()
2 string references to 'test_gateway_charge'
- hook_payment_gateway in docs/
hooks.php - Register payment gateway callbacks.
- test_gateway_payment_gateway in payment/
uc_payment/ test_gateway.module
File
- payment/
uc_payment/ test_gateway.module, line 30 - A test module used as an example for a payment gateway.
Code
function test_gateway_charge($order_id, $amount, $data) {
global $user;
$order = uc_order_load($order_id);
// Use 0000000000000000 to test a failed payment, anything else for a good one.
if ($order->payment_details['cc_number'] == '0000000000000000') {
$success = FALSE;
}
else {
$success = TRUE;
}
// Uncomment this lines to see the order object. The information for the
// payment is in the $order->payment_details array.
// drupal_set_message('<pre>'. print_r($order->payment_details, true) .'</pre>');
if ($success) {
$message = t('Credit card charged: !amount', array(
'!amount' => uc_currency_format($amount),
));
uc_order_comment_save($order_id, $user->uid, $message, 'admin');
}
else {
$message = t('Credit card charge failed.');
uc_order_comment_save($order_id, $user->uid, $message, 'admin');
}
$result = array(
'success' => $success,
'comment' => t('Card charged, resolution code: 0022548315'),
'message' => $success ? t('Credit card payment processed successfully.') : t('Credit card charge failed.'),
'uid' => $user->uid,
);
return $result;
}