Mik*_*ike 9 integration ruby-on-rails activemerchant worldpay
我原来的问题(下面)可能太具体了,所以我会问一些更普遍的问题!
有人能指出我使用Active Merchant Integrations支持异地支付网关的教程,示例或文档的方向吗?
Active Merchant的rdoc列出了以下所有支持的非现场支付网关,但我没有找到有关如何使用ActiveMerchant :: Billing :: Integrations的任何教程或示例
虽然它们可能是好的,但是peepcode和rails casts只考虑网关,而不是集成.
非常感谢!
我的公司正在从PayPal Express Checkout转移到WorldPay Business Gateway(托管付款页面).我们正在使用Rails和Active Merchant.
- Active Merchant是否支持WorldPay Business Gateway(托管付款页面)?我认为确实如此,从rdoc来看
- 我必须向ActiveMerchant提供什么参数:: Billing :: Integrations :: WorldPay.new?
谢谢
Dam*_* Aw 10
我制作了一个简单的应用程序来演示Worldpay和Rails/Activemerchant的异地付款如何协同工作.
演示Rails应用程序 - https://github.com/daemonsy/Worldpay-Rails--Off-Site--Integration-Example
对于World Pay托管付款,基本上post需要支付其付款URL.添加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 ">
Run Code Online (Sandbox Code Playgroud)
资料来源:http://www.worldpay.com/support/kb/bg/htmlredirect/rhtml.html
这创建了一个简单button的订单到World Pay,客户将输入信用卡详细信息并完成购买.我已将上述代码嵌入到show订单控制器的页面中.e,g , <input type="hidden" name="amount" value="<%=@order.amount"%>>. 所以您可以buy this在提交订单后点击.实现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
Run Code Online (Sandbox Code Playgroud)
因此,Notification对象将读取params request.raw_post并将它们设置为您可以查询的对象.我发现活跃的商家文档对于告诉它所映射的返回参数是有用的.
请注意,此控制器是一个非常粗略的例子.World Pay提供了一些验证响应的方法,Active Merchant支持这种方法.
WorldPay上的ActiveMerchant文档::通知 http://rdoc.info/github/Shopify/active_merchant/master/ActiveMerchant/Billing/Integrations/WorldPay World Pay Payment Response文档 http://www.worldpay.com/support/kb/bg /paymentresponse/payment_response.html