Reputation: 1567
I've been looking for 2 days on how to integrate my merchant payment gateway into ubercart with no lack. So I decided to ask it here.
I have the following code as an example from my merchant:
<form name="payFormCcard" method="post" action=" https://test.MyMerchantGateway.com/ECN/eng/payment/payForm.jsp">
<input type="hidden" name="merchantId" value="1">
<input type="hidden" name="amount" value="3000.0" >
<input type="hidden" name="orderRef" value="000000000014">
<input type="hidden" name="currCode" value="608" >
<input type="hidden" name="successUrl" value="http://www.yourdomain.com/Success.html">
<input type="hidden" name="failUrl" value="http://www.yourdomain.com/Fail.html">
<input type="hidden" name="cancelUrl" value="http://www.yourdomain.com/Cancel.html">
<input type="hidden" name="payType" value="N">
<input type="hidden" name="lang" value="E">
<input type="submit" name="submit">
</form>
Please note that I change the actual domain above for security reason.
What I want after checkout is redirect it to https://test.MyMerchantGateway.com/ECN/eng/payment/payForm.jsp
Upvotes: 0
Views: 2437
Reputation: 8686
Looks like you want to do an off-site payment (external to your Drupal site), so in your payment module, you will need to write a payment method that redirects like so:
function my_pay_gateway_uc_payment_method() {
$methods[] = array(
'id' => 'my_pay_credit',
'name' => t('My Payment Gateway'),
'title' => t('My Payment Gateway'),
'desc' => t('Pay through my payment gateway'),
'callback' => 'my_payment_method',
'redirect' => 'my_payment_form', // <-- Note the redirect callback provided
'weight' => 1,
'checkout' => TRUE,
);
return $methods;
}
Then you should add code to the redirect callback to build a form that sits behind the Submit Order button to redirect to your payment gateway while including all the information you need like:
function my_payment_form($form, &$form_state, $order) {
// Build the data to send to my payment gateway
$data = array(
'merchantId' => '1',
'amount' => '3000.0',
'orderRef' => '000000000014',
'currCode' => '608',
// You can fill in the rest...
);
// This code goes behind the final checkout button of the checkout pane
foreach ($data as $name => $value) {
if (!empty($value)) {
$form[$name] = array('#type' => 'hidden', '#value' => $value);
}
}
$form['#action'] = 'https://test.MyMerchantGateway.com/ECN/eng/payment/payForm.jsp';
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit Orders'),
);
return $form;
}
For more details, see my blog post at http://nmc-codes.blogspot.ca/2012/07/how-to-create-custom-ubercart-payment.html
Upvotes: 1