活跃商家集成(站外支付)

9

我的原始问题(如下)可能过于具体,因此我要问一些更普遍的问题!

有人可以指导我如何使用Active Merchant 集成来支持离线支付网关吗?

Active Merchant的rdoc将以下所有内容列为支持的离线支付网关,但我没有找到任何关于如何使用ActiveMerchant::Billing::Integrations的教程或示例

  • 2 Checkout
  • Banca Sella GestPay
  • Chronopay
  • Direct-eBanking
  • DirecPay
  • HiTRUST
  • Moneybookers
  • Nochex
  • PayPal Website Payments Standard
  • SagePay Form
  • Valitor
  • WorldPay

尽管它们可能很好,但peepcoderailscasts只考虑网关,而不是集成。

非常感谢!

我的公司正在从PayPal Express Checkout转移到WorldPay Business Gateway(托管付款页面)。我们使用Rails和Active Merchant。

  1. Active Merchant是否支持WorldPay Business Gateway(托管付款页面)?我认为它支持,根据rdoc
  2. 必须向ActiveMerchant :: Billing :: Integrations :: WorldPay.new提供哪些参数?

谢谢


你解决了吗?我也在切换方面遇到了麻烦 :( - Chris Edwards
没有。还是没有找到任何东西。 - Mike
由于您正在使用离线支付,您是否可以通过将POST请求发送到Worldpay的URL来简化流程?就像Paypal按钮API一样。 - Damon Aw
@daemonsy - 也就是说不用ActiveMerchant吗? - Mike
实际上我正在尝试为自己的项目进行wp集成。但我们正试图使用网关模式(即在站点上)。你在做哪个产品?我会稍微离题一下,然后尝试写出一些代码。 - Damon Aw
我们想要进行离线操作。我希望通过ActiveMerchant集成来实现,这样以后更换供应商就会更容易,而不是硬编码到WorldPay上。也许我对这个主题的文档理解有误,但是在ActiveMerchant的rdoc中,WorldPay被列为支持的离线网关。 - Mike
1个回答

11

我制作了一个简单的应用程序,以演示如何将Worldpay和Rails/Activemerchant的离站支付功能结合使用。

演示Rails应用程序- https://github.com/daemonsy/Worldpay-Rails--Off-Site--Integration-Example

对于World Pay托管付款,基本上需要向其付款URL进行post。将test-添加到secure.worldpay.com以测试模式。WP要求金额、货币、安装ID和cartId以向客户呈现页面。

<form action="https://test-secure.worldpay.com/wcc/purchase" method=POST>

<!-- This next line contains the testMode parameter - it specifies that the submission is a test submission -->
<input type="hidden" name="testMode" value="100">

<!-- This next line contains a mandatory parameter. Put your Installation ID inside the quotes after value= -->
<input type="hidden" name="instId" value="Your installation ID ">

<!-- Another mandatory parameter. Put your own reference identifier for the item purchased inside the quotes after value= -->
<input type="hidden" name="cartId" value="Your ID for the product ">

<!-- Another mandatory parameter. Put the total cost of the item inside the quotes after value= -->
<input type="hidden" name="amount" value="The cost of the product ">

<!-- Another mandatory parameter. Put the code for the purchase currency inside the quotes after value= -->
<input type="hidden" name="currency" value="currency code e.g. GBP, USD ">

<!-- This creates the button. When it is selected in the browser, the form submits the purchase details to us. -->
<input type=submit value=" Buy This ">

源代码: http://www.worldpay.com/support/kb/bg/htmlredirect/rhtml.html

这将创建一个简单的按钮,将您的订单传递到World Pay,在那里客户将输入信用卡详细信息并完成购买。我已经将上述代码嵌入到订单控制器的show页面中。例如:<input type="hidden" name="amount" value="<%=@order.amount"%>>。因此,在提交订单后,您可以单击buy this。有许多方法可以实现向World Pay的POST

之后,World Pay可以显示购物者响应页面,发送付款响应等。为了使付款响应起作用,您可以将付款响应回调URL设置为您的控制器之一。例如:=>http://mysite.com/payment-backend

这将是一个POST请求,因此您需要设置控制器来处理它。这就是Activemerchant发挥作用的地方。例如,

class BackendsController < ApplicationController
  include ActiveMerchant::Billing::Integrations
  protect_from_forgery :except=>[:worldpay_return]

  #in routes => match '/payment-backend'=>'backends#worldpay_return'
  def worldpay_return
    notification = WorldPay::Notification.new(request.raw_post)  

    order = Order.find(notification.item_id)

    if notification.acknowledge
      begin
        if notification.complete?
          order.status = 'success'
        end
      rescue
        order.status = "failed"
        raise
      ensure
        order.save
      end
    end
  render :text =>"Order status for #{order.id} is #{order.status}" 

  end

end

因此,通知对象将读取request.raw_post中的参数,并将它们设置为一个对象,您可以查询。我发现活动商家文档对于告知哪些返回参数是由其映射的很有用。
请注意,此控制器是一个非常简单的示例。World Pay为您提供了一些方法来验证响应,这得到了Active Merchant的支持。 WorldPay :: Notifications的ActiveMerchant文档 http://rdoc.info/github/Shopify/active_merchant/master/ActiveMerchant/Billing/Integrations/WorldPay World Pay付款响应文档 http://www.worldpay.com/support/kb/bg/paymentresponse/payment_response.html

谢谢。我期待着在不久的将来尝试这个! - Mike
没问题 =)。我喜欢World Pay,但是唉,我希望他们能稍微改进一下他们那丑陋的托管页面。 - Damon Aw
谢谢,很棒的答案,我会尝试将其适应其他支付处理器。 - Orlando

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接