9

私の元の質問 (下記) はおそらく具体的すぎたので、もっと一般的な質問をします!

Active Merchant Integrationsを使用してオフサイトの支払いゲートウェイをサポートするためのチュートリアル、例、またはドキュメントの方向性を誰か教えてもらえますか?

Active Merchant の rdoc には、サポートされているオフサイト支払いゲートウェイとして次のすべてがリストされていますが、 ActiveMerchant::Billing::Integrationsの使用方法に関するチュートリアルや例は見つかりませんでした。

  • 2 チェックアウト
  • Banca Sella GestPay
  • クロノペイ
  • ダイレクトeバンキング
  • ディレクペイ
  • ハイトラスト
  • マネーブッカーズ
  • ノシェックス
  • PayPal ウェブ ペイメント スタンダード
  • SagePay フォーム
  • バリトール
  • ワールドペイ

良いかもしれませんが、peepcoderails のキャストはゲートウェイのみを考慮し、統合は考慮しません。

どうもありがとう!

私の会社は、PayPal Express Checkout から WorldPay Business Gateway (ホストされた支払いページ) に移行しています。Rails と Active Merchant を使用しています。

  1. Active Merchant は WorldPay Business Gateway (Hosted Payment Page) をサポートしていますか? rdocから判断すると、そうだと思います
  2. ActiveMerchant::Billing::Integrations::WorldPay.new にどの引数を指定する必要がありますか?

ありがとう

4

1 に答える 1

11

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

ソース: http://www.worldpay.com/support/kb/bg/htmlredirect/rhtml.html

buttonこれにより、顧客がクレジット カードの詳細を入力して購入を完了する World Pay に注文を運ぶシンプルなフォームが作成されます。show上記のコードを注文コントローラーのページに埋め込みました。例えば、<input type="hidden" name="amount" value="<%=@order.amount"%>>buy thisそのため、注文を送信した後にクリックできます。POSTto World Payを達成するには多くの方法があります。

その後、World Pay は買い物客の応答ページを表示したり、送信したりできますpayment response。支払い応答が機能するようにするには、コントローラの 1 つに支払い応答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

したがって、通知オブジェクトはパラメーターを読み取り、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

于 2012-02-21T14:11:33.013 に答える