わかりました、SelfStarter を使用しています。FlexPay アカウントをすべてセットアップしました。SelfStarter が機能させるために必要な情報、secret_key、access_key を入力します。
FlexPay を使用したことはありません。
現在、(バッカーとして) テストを行ったところ、注文してチェックアウトでき、支払いが承認されたことを示すメールが届きました。しかし、お金は手を変えません。
さらに調査したところ、収集したトークンに基づいて AmazonFlexPay.Pay を使用してアカウントに請求する必要があることがわかりました。それはクールですが、このコードを実際にどのように実装するかについては、コードの残りの部分との関係など、多くの情報を見つけることができません。これは、私が見つけることができるほとんどの情報です。
AmazonFlexPay.pay('12.99', 'USD', 'STOKEN', 'myrequest3292')
これは、SelfStarter のコントローラーのコードです。
class PreorderController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => :ipn
def index
end
def checkout
end
def prefill
@user = User.find_or_create_by_email!(params[:email])
if Settings.use_payment_options
payment_option_id = params['payment_option']
raise Exception.new("No payment option was selected") if payment_option_id.nil?
payment_option = PaymentOption.find(payment_option_id)
price = payment_option.amount
else
price = Settings.price
end
@order = Order.prefill!(:name => Settings.product_name, :price => price, :user_id => @user.id, :payment_option => payment_option)
# This is where all the magic happens. We create a multi-use token with Amazon, letting us charge the user's Amazon account
# Then, if they confirm the payment, Amazon POSTs us their shipping details and phone number
# From there, we save it, and voila, we got ourselves a preorder!
port = Rails.env.production? ? "" : ":3000"
callback_url = "#{request.scheme}://#{request.host}#{port}/preorder/postfill"
redirect_to AmazonFlexPay.multi_use_pipeline(@order.uuid, callback_url,
:transaction_amount => price,
:global_amount_limit => price + Settings.charge_limit,
:collect_shipping_address => "True",
:payment_reason => Settings.payment_description)
end
def postfill
unless params[:callerReference].blank?
@order = Order.postfill!(params)
end
# "A" means the user cancelled the preorder before clicking "Confirm" on Amazon Payments.
if params['status'] != 'A' && @order.present?
redirect_to :action => :share, :uuid => @order.uuid
else
redirect_to root_url
end
end
def share
@order = Order.find_by_uuid(params[:uuid])
end
def ipn
end
end
また、ルビーはこれまで手つかずのままなので、他に必要なものはすべてhttps://github.com/lockitron/selfstarterにあります。
パッケージから出る準備ができているように見えたので、SelfStarter が主張されました。そうではないようですので、助けていただければ幸いです。たぶん簡単なステップか何かを見落としているような気がします。