Tag: 条纹支付

如何在Rails上编写Stripe checkout的集成测试?

我试图为我的Rails 3.2应用程序为Stripe的checkout.js [ https://checkout.stripe.com/checkout.js ]编写集成测试。 在手动测试时(使用Stripe的测试键)条纹检查对我来说正常工作,但我无法让fill_in检测并fill_in条带结帐iframe模式中的电子邮件字段。 我正在使用无端 javascript的poltergeist ,虽然也用capybara-webkit和甚至selenium测试了同样的问题。 我要测试的是完整的订阅注册流程,以显示新用户在Stripe中输入付款详细信息后可以创建订阅者帐户 – 但我无法通过Stripe结帐弹出窗口。 这是我before .. do : describe “show Stripe checkout”, :js => true do before do visit pricing_path click_button ‘plan-illuminated’ stripe_iframe = all(‘iframe[name=stripe_checkout_app]’).last Capybara.within_frame stripe_iframe do fill_in “email”, :with => “test-user@example.com” fill_in “billing-name”, :with => “Mr Name” fill_in “billing-street”, :with => “test Street” fill_in “billing-zip”, […]

条带标记未附加到Rails App的请求主体

我正在制作一个Rails应用程序,允许用户以$ X / yr成为订阅用户,我被困在订阅页面上,无论我做什么,stripeToken都没有附加到请求和CreateSubscription.rb说“这个客户没有附加付款来源“。 我的turbolinks被禁用了。 我的条带日志说它收到POST主体的请求:电子邮件:“raf6000@gmail.com”计划:“praducks-annual”但错误被抛出如下 – 因为没有源对象附加到请求 – 错误:键入:“invalid_request_error”消息:“此客户没有附加的付款来源” CreateSubscription.rb class CreateSubscription def self.call(plan, email_address, token) user, raw_token = CreateUser.call(email_address) subscription = Subscription.new( plan: plan, user: user ) begin stripe_sub = nil if user.stripe_customer_id.blank? puts “Customer is new” puts token.nil? customer = Stripe::Customer.create( source: token, email: user.email, plan: plan.stripe_id, ) user.stripe_customer_id = customer.id user.save! […]

在创建新卡之前,我是否可以检查卡片是否已经存在?

因为我已经在我的数据库中保存了条带客户ID以便以后付款。 在这里,客户将拥有多张卡片,我希望使用该特定客户的现有卡片检查/validation客户卡。 假设相同的卡详细信息存储多次作为多张卡。 在这个过程中,我想用令牌检查这张卡是否已经存在。 将使用它如果已经存在,如果没有将创建新卡。

我应该每个月使用什么作为计算用户消耗的资源量的起点?

比方说,我为我的用户使用条带订阅,其中一个计划是100个API请求每月10美元,这是标准价格。 但是,如果用户使用了150个API请求,我会在10美元的最高价格上再收取3美元。 对于200多个请求,总共17美元。 说,我已于10月9日订阅了用户。 11月9日,Stripe将再次收取费用。 我应该何时“冻结”用户在本月使用的API数量来计算总体价格,并从11月9日到12月9日的新时期再次从零开始计算? 就我而言,它位于我的条带Web钩子控制器中的payment.success或invoice.success事件上。 但是,我认为这不可靠,因为: 它究竟是哪一个 – payment.success或invoice.success – 我需要的那个? 它们同时发生,据我所知有时payment.success 首先发生,有时 – invoice.success并且不知道哪一个在每个特定情况下首先出现。 Theres是这两个事件之间的时间段,我不知道到底有多长,可能是几分钟。 但在这几分钟内,用户可能会消耗至少一个发票 我不确定是否保证每个用户的事件payment.success和invoice.success每月只发生一次 。 他们真的吗? 如果不是,使用它们实现我的目标就更不可靠了。 invoice.created事件发生在发票关闭前1小时。

条带连接:针对“已连接”(独立)帐户为现有客户收费

如果试图通过 连接帐户向客户记录(具有相关信用卡)收费,我收到错误声称“没有这样的客户:cus_xxxx” – 即使向同一个客户收取费用也能正常工作不使用“已连接”帐户时(通过平台帐户充值时)。 例如,假设我们有一个ID为acct_ABC123的“已连接”(独立)帐户,请考虑以下Ruby代码: # Use the (secret) API key for the “platform” or base account. Stripe.api_key = ‘sk_[…]’ customer = Stripe::Customer.create(email: ‘customer@example.com’) # Associate a credit-card with the customer. token = # Generate a token (eg, using Stripe Checkout). customer.sources.create(source: token) # Attempt to charge the card via the connected account… Stripe::Charge.create({ amount: […]

Capybara在JS模式中填补麻烦

让我首先确认这不是重复(因为那里发布的答案没有解决我的问题)。 这篇文章基本上是我的确切问题:Capybara无法找到Stripe模式中的表单字段来填充它们。 这是我的水豚规格: describe ‘checkout’, type: :feature, js: true do it ‘checks out correctly’ do visit ‘/’ page.should have_content ‘Amount: $20.00’ page.find(‘#button-two’).click_button ‘Pay with Card’ Capybara.within_frame ‘stripe_checkout_app’ do fill_in ‘Email’, with: ‘example@example.com’ fill_in ‘Name’, with: ‘Nick Cox’ fill_in ‘Street’, with: ‘123 Anywhere St.’ fill_in ‘ZIP’, with: ‘98117’ fill_in ‘City’, with: ‘Seattle’ click_button ‘Payment Info’ fill_in […]