在我的测试中,我收到错误:
Failure/Error: stripeToken: stripe_helper.generate_card_token,
Stripe::InvalidRequestError:
Received unknown parameter: fingerprint
这是我的代码:
let(:stripe_helper) { StripeMock.create_test_helper }
let(:payment_params) do
{ .., stripeToken: stripe_helper.generate_card_token }
end
我做错了什么?
答案 0 :(得分:1)
您可以尝试以这种方式进行模拟。要生成_card_token,您必须提供参数。
let(:stripe_helper) { StripeMock.create_test_helper }
let(:payment_params) do
StripeMock.generate_card_token(last4: "2244", exp_month: 33, exp_year: 2255)
end
describe 'Token Creation' do
it "generates and reads a card token for create charge" do
charge = Stripe::Charge.create(amount: 500, currency: 'usd', source: payment_params)
card = charge.source
expect(card.last4).to eq("2244")
expect(card.exp_month).to eq(33)
expect(card.exp_year).to eq(2255)
end
end