【问题标题】:How to integrate 3rd party merchant payment gateway in ubercart如何在 ubercart 中集成第三方商家支付网关
【发布时间】:2012-04-06 17:10:20
【问题描述】:

我一直在寻找如何将我的商家支付网关集成到 ubercart 中的 2 天。所以我决定在这里问。

我的商家提供以下代码作为示例:

<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>

请注意,出于安全原因,我更改了上面的实际域。

结帐后我想要的是将其重定向到https://test.MyMerchantGateway.com/ECN/eng/payment/payForm.jsp

【问题讨论】:

    标签: drupal ubercart


    【解决方案1】:

    看起来您想要进行场外付款(在您的 Drupal 站点外部),因此在您的付款模块中,您需要编写一个像这样重定向的付款方式:

    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;
    }
    

    然后您应该向重定向回调添加代码,以构建一个位于 提交订单 按钮后面的表单,以重定向到您的支付网关,同时包含您需要的所有信息,例如:

    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;
    }
    

    更多详情请看我http://nmc-codes.blogspot.ca/2012/07/how-to-create-custom-ubercart-payment.html的博文

    【讨论】:

    猜你喜欢
    • 2015-11-10
    • 2019-02-21
    • 2017-05-04
    • 1970-01-01
    • 2019-10-16
    • 2019-05-30
    • 2015-10-14
    • 2021-07-30
    • 2017-01-01
    相关资源
    最近更新 更多