单轨充电带轨道条​​纹

我试图弄清楚如何在表单输入字段中输入的一次充电中使用条带接受信用卡。

示例:user1登录并创建post,在字段中输入$ 20并单击提交。 post被创建,20美元从他的卡中扣款。 User2做同样的事情但是投入45美元并输入他的信用卡并提交表格。

我完成了以下工作; – 设计设置 – 角色 – 安装条纹gem和帐户设置

我还没有找到一个例子来解释条带的一次充电,一切都是基于订阅的。

我是新手,所以我试图模仿订阅示例,但没有成功。

以下是我使用Stripe和ActiveMerchant gem执行单次充电的方法。

transaction = ActiveMerchant::Billing::StripeGateway.new(:login => STRIPE_SECRET_KEY) paymentInfo = ActiveMerchant::Billing::CreditCard.new( :number => "4242424242424242", :month => "12", :year => "2020", :verification_value => "411") purchaseOptions = {:billing_address => { :name => "Customer Name", :address1 => "Customer Address Line 1", :city => "Customer City", :state => "Customer State", :zip => "Customer Zip Code" }} response = transaction.purchase((17.50 * 100).to_i, paymentInfo, purchaseOptions) if response.success? then logger.debug "charge successful" end