【问题标题】:Active Merchant Integrations (off site payments) [closed]活跃的商家整合(场外支付)[关闭]
【发布时间】:2011-12-10 23:27:53
【问题描述】:

我最初的问题(如下)可能太具体了,所以我要问一些更笼统的问题!

谁能指出有关使用活跃商家Integrations支持offsite payment gateway的教程、示例或文档的方向?

Active Merchant 的 rdoc 列出了以下所有支持的异地支付网关,但我没有找到任何关于如何使用 ActiveMerchant::Billing::Integrations 的教程或示例

  • 2 结帐
  • Banca Sella GestPay
  • Chronopay
  • 直接电子银行
  • DirecPay
  • HiTRUST
  • Moneybookers
  • Nochex
  • PayPal 网站支付标准
  • SagePay 表格
  • 验证者
  • WorldPay

尽管peepcoderails casts 尽可能好,但它们只考虑网关,而不考虑集成。

非常感谢!

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

  1. Active Merchant 是否支持 WorldPay 商业网关(托管支付页面)?我认为确实如此,从the rdoc 来看
  2. 我必须向 ActiveMerchant::Billing::Integrations::WorldPay.new 提供哪些参数?

谢谢

【问题讨论】:

  • 你解决了吗?我也无法切换:(
  • 不。仍然没有找到任何东西。
  • 由于您使用的是异地支付,您能否通过将POST 发送到worldpay URL 来简化流程?类似于 Paypal 按钮 API。
  • @daemonsy - 即不使用 ActiveMerchant?!
  • 实际上我正在尝试为我自己的项目进行 wp 集成。但我们正在尝试使用网关模式(即现场)。你在做什么产品?我会跑题一点,试着写一些代码。

标签: ruby-on-rails integration activemerchant worldpay


【解决方案1】:

我制作了一个简单的应用程序来演示 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

这将创建一个简单的button,将您的订单传送到 World Pay,客户将在其中输入信用卡详细信息并完成购买。我已将上述代码嵌入到订单控制器的show 页面中。例如,&lt;input type="hidden" name="amount" value="&lt;%=@order.amount"%&gt;&gt;。所以您可以在提交订单后点击buy this。有很多方法可以在 World Pay 中获得POST

之后,World Pay 会显示一个购物者响应页面,向您发送payment response 等。对于工作的付款响应,您可以将付款响应callback 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

因此,Notification 对象将读取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

【讨论】:

  • 谢谢。我期待在不久的将来尝试这个!
  • 没问题 =)。我喜欢 World Pay,但叹了口气,我希望他们能稍微改进一下他们托管的页面。
  • 谢谢.. 很酷的答案,我会尝试将其适应另一个支付处理器
猜你喜欢
  • 2014-06-27
  • 2016-07-31
  • 2011-11-09
  • 2011-03-17
  • 2011-06-20
  • 2017-01-07
  • 2012-09-23
  • 2012-02-19
  • 2015-10-14
相关资源
最近更新 更多