1
Braintree Paypal SDKは、ホストされたフィールドのあるフォームでpaypalボタンをレンダリングします。しかし、ノンスをサーバーに提出する方法を理解することはできません。このセクションで私はどのようにしますか?ペイロードノンスをサーバに提出するBraintree SDK Paypalルビーレール
onAuthorize: function (data, actions) {
return paypalCheckoutInstance.tokenizePayment(data)
.then(function (payload) {
// Submit `payload.nonce` to your server
//console.log (payload.nonce)
});
},
私のコントローラのアクションは、あなたがあなたのサーバーに支払いナンスを渡すためにJavaScriptでの要求を生成する必要があります
def payment
Cart.find(session[:cart_id])
result = Braintree::Transaction.sale(
amount: current_order.subtotal,
payment_method_nonce: params[:payment_method_nonce],
:options => {
:submit_for_settlement => true},
)
response = {:success => result.success?}
if result.success?
response[:transaction_id] = result.transaction.id
current_order.update(status: "purchased")
ReceiptMailer.purchase_order(current_passenger,
current_order).deliver_now
redirect_to root_path,
notice: "Thank you for booking, Please check your email for invoice"
session.delete(:cart_id)
elsif result.transaction
redirect_to cart_path, alert: "something went wrong, your transactions was not successful!"
end
end
ありがとうございます。それは正常に働いた。 – Sebala