mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-01 12:24:28 +01:00
Merge branch 'product-store' into product-store_dev
This commit is contained in:
commit
ef6bc6c046
@ -18,16 +18,14 @@ class Checkout::PaymentService
|
||||
CouponService.new.validate(coupon_code, order.statistic_profile.user.id)
|
||||
|
||||
amount = debit_amount(order)
|
||||
if operator.privileged? || amount.zero?
|
||||
if (operator.privileged? && operator != order.statistic_profile.user) || amount.zero?
|
||||
Payments::LocalService.new.payment(order, coupon_code)
|
||||
elsif operator.member?
|
||||
if Stripe::Helper.enabled?
|
||||
Payments::StripeService.new.payment(order, coupon_code, payment_id)
|
||||
elsif PayZen::Helper.enabled?
|
||||
Payments::PayzenService.new.payment(order, coupon_code)
|
||||
else
|
||||
raise Error('Bad gateway or online payment is disabled')
|
||||
end
|
||||
elsif Stripe::Helper.enabled? && payment_id.present?
|
||||
Payments::StripeService.new.payment(order, coupon_code, payment_id)
|
||||
elsif PayZen::Helper.enabled?
|
||||
Payments::PayzenService.new.payment(order, coupon_code)
|
||||
else
|
||||
raise Error('Bad gateway or online payment is disabled')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -73,7 +73,7 @@ class InvoicesService
|
||||
method = if payment_method
|
||||
payment_method
|
||||
else
|
||||
operator&.admin? || (operator&.manager? && operator != user) ? nil : 'card'
|
||||
(operator&.admin? || operator&.manager?) && operator != user ? nil : 'card'
|
||||
end
|
||||
|
||||
invoice = Invoice.new(
|
||||
|
10
test/fixtures/order_items.yml
vendored
10
test/fixtures/order_items.yml
vendored
@ -158,3 +158,13 @@ order_item_27:
|
||||
is_offered:
|
||||
created_at: <%= DateTime.current.utc.change({:hour => 10}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
updated_at: <%= DateTime.current.utc.change({:hour => 15}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
order_item_28:
|
||||
id: 28
|
||||
order_id: 20
|
||||
orderable_type: Product
|
||||
orderable_id: 13
|
||||
amount: 500
|
||||
quantity: 2
|
||||
is_offered:
|
||||
created_at: <%= DateTime.current.utc.change({:hour => 10}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
updated_at: <%= DateTime.current.utc.change({:hour => 15}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
|
2
test/fixtures/orders.yml
vendored
2
test/fixtures/orders.yml
vendored
@ -239,7 +239,7 @@ order_20:
|
||||
token: 0DKxbAOzSXRx-amXyhmDdg1666691976019
|
||||
reference: '005904-<%= DateTime.current.utc.strftime('%m') %>-<%= DateTime.current.utc.strftime('%d') %>'
|
||||
state: cart
|
||||
total: 261500
|
||||
total: 262500
|
||||
created_at: <%= DateTime.current.utc.change({:hour => 10}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
updated_at: <%= DateTime.current.utc.change({:hour => 15}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
wallet_amount:
|
||||
|
@ -35,7 +35,7 @@ module InvoiceHelper
|
||||
# Line of text should be of form 'Label $10.00'
|
||||
# @returns {float}
|
||||
def parse_amount_from_invoice_line(line)
|
||||
line[line.rindex(' ') + 1..].tr(I18n.t('number.currency.format.unit'), '').to_f
|
||||
line[line.rindex(' ') + 1..].tr(I18n.t('number.currency.format.unit'), '').gsub(/[$,]/, '').to_f
|
||||
end
|
||||
|
||||
# check VAT and total excluding taxes
|
||||
|
426
test/integration/store/admin_pay_order_test.rb
Normal file
426
test/integration/store/admin_pay_order_test.rb
Normal file
@ -0,0 +1,426 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
module Store; end
|
||||
|
||||
class Store::AdminPayOrderTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@admin = User.find_by(username: 'admin')
|
||||
@pjproudhon = User.find_by(username: 'pjproudhon')
|
||||
@caisse_en_bois = Product.find_by(slug: 'caisse-en-bois')
|
||||
@panneaux = Product.find_by(slug: 'panneaux-de-mdf')
|
||||
@cart1 = Order.find_by(token: '0DKxbAOzSXRx-amXyhmDdg1666691976019')
|
||||
end
|
||||
|
||||
test 'admin pay himself order by cart with success' do
|
||||
login_as(@admin, scope: :user)
|
||||
|
||||
invoice_count = Invoice.count
|
||||
invoice_items_count = InvoiceItem.count
|
||||
|
||||
VCR.use_cassette('store_order_admin_pay_by_cart_success') do
|
||||
post '/api/checkout/payment',
|
||||
params: {
|
||||
payment_id: stripe_payment_method,
|
||||
order_token: @cart1.token,
|
||||
customer_id: @admin.id
|
||||
}.to_json, headers: default_headers
|
||||
end
|
||||
|
||||
@cart1.reload
|
||||
|
||||
# general assertions
|
||||
assert_equal 200, response.status
|
||||
assert_equal invoice_count + 1, Invoice.count
|
||||
assert_equal invoice_items_count + 2, InvoiceItem.count
|
||||
|
||||
# invoice_items assertions
|
||||
invoice_item = InvoiceItem.last
|
||||
|
||||
assert invoice_item.check_footprint
|
||||
|
||||
# invoice assertions
|
||||
invoice = Invoice.last
|
||||
assert_invoice_pdf invoice
|
||||
assert_not_nil invoice.debug_footprint
|
||||
|
||||
assert_not @cart1.payment_gateway_object.blank?
|
||||
assert_not invoice.payment_gateway_object.blank?
|
||||
assert_not invoice.total.blank?
|
||||
assert invoice.check_footprint
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: invoice)
|
||||
|
||||
assert_equal @cart1.state, 'paid'
|
||||
assert_equal @cart1.payment_method, 'card'
|
||||
assert_equal @cart1.paid_total, 262_500
|
||||
|
||||
stock_movement = @caisse_en_bois.product_stock_movements.last
|
||||
assert_equal stock_movement.stock_type, 'external'
|
||||
assert_equal stock_movement.reason, 'sold'
|
||||
assert_equal stock_movement.quantity, -5
|
||||
assert_equal stock_movement.order_item_id, @cart1.order_items.first.id
|
||||
|
||||
stock_movement = @panneaux.product_stock_movements.last
|
||||
assert_equal stock_movement.stock_type, 'external'
|
||||
assert_equal stock_movement.reason, 'sold'
|
||||
assert_equal stock_movement.quantity, -2
|
||||
assert_equal stock_movement.order_item_id, @cart1.order_items.last.id
|
||||
|
||||
activity = @cart1.order_activities.last
|
||||
assert_equal activity.activity_type, 'paid'
|
||||
assert_equal activity.operator_profile_id, @admin.invoicing_profile.id
|
||||
end
|
||||
|
||||
test 'admin pay himself order by cart and wallet with success' do
|
||||
login_as(@admin, scope: :user)
|
||||
|
||||
service = WalletService.new(user: @admin, wallet: @admin.wallet)
|
||||
service.credit(1000)
|
||||
|
||||
invoice_count = Invoice.count
|
||||
invoice_items_count = InvoiceItem.count
|
||||
users_credit_count = UsersCredit.count
|
||||
wallet_transactions_count = WalletTransaction.count
|
||||
|
||||
VCR.use_cassette('store_order_admin_pay_by_cart_and_wallet_success') do
|
||||
post '/api/checkout/payment',
|
||||
params: {
|
||||
payment_id: stripe_payment_method,
|
||||
order_token: @cart1.token,
|
||||
customer_id: @admin.id
|
||||
}.to_json, headers: default_headers
|
||||
end
|
||||
|
||||
@admin.wallet.reload
|
||||
@cart1.reload
|
||||
|
||||
# general assertions
|
||||
assert_equal 200, response.status
|
||||
assert_equal invoice_count + 1, Invoice.count
|
||||
assert_equal invoice_items_count + 2, InvoiceItem.count
|
||||
|
||||
# invoice_items assertions
|
||||
invoice_item = InvoiceItem.last
|
||||
|
||||
assert invoice_item.check_footprint
|
||||
|
||||
# invoice assertions
|
||||
invoice = Invoice.last
|
||||
assert_invoice_pdf invoice
|
||||
assert_not_nil invoice.debug_footprint
|
||||
|
||||
assert_not @cart1.payment_gateway_object.blank?
|
||||
assert_not invoice.payment_gateway_object.blank?
|
||||
assert_not invoice.total.blank?
|
||||
assert invoice.check_footprint
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: invoice)
|
||||
|
||||
assert_equal @cart1.state, 'paid'
|
||||
assert_equal @cart1.payment_method, 'card'
|
||||
assert_equal @cart1.paid_total, 162_500
|
||||
assert_equal users_credit_count, UsersCredit.count
|
||||
assert_equal wallet_transactions_count + 1, WalletTransaction.count
|
||||
|
||||
# wallet
|
||||
assert_equal 0, @admin.wallet.amount
|
||||
assert_equal 2, @admin.wallet.wallet_transactions.count
|
||||
transaction = @admin.wallet.wallet_transactions.last
|
||||
assert_equal 'debit', transaction.transaction_type
|
||||
assert_equal @cart1.wallet_amount / 100.0, transaction.amount
|
||||
assert_equal @cart1.wallet_transaction_id, transaction.id
|
||||
assert_equal invoice.wallet_amount / 100.0, transaction.amount
|
||||
end
|
||||
|
||||
test 'admin pay user order by local with success' do
|
||||
login_as(@admin, scope: :user)
|
||||
|
||||
invoice_count = Invoice.count
|
||||
invoice_items_count = InvoiceItem.count
|
||||
|
||||
post '/api/checkout/payment',
|
||||
params: {
|
||||
order_token: @cart1.token,
|
||||
customer_id: @pjproudhon.id
|
||||
}.to_json, headers: default_headers
|
||||
|
||||
@cart1.reload
|
||||
|
||||
# general assertions
|
||||
assert_equal 200, response.status
|
||||
assert_equal invoice_count + 1, Invoice.count
|
||||
assert_equal invoice_items_count + 2, InvoiceItem.count
|
||||
|
||||
# invoice_items assertions
|
||||
invoice_item = InvoiceItem.last
|
||||
|
||||
assert invoice_item.check_footprint
|
||||
|
||||
# invoice assertions
|
||||
invoice = Invoice.last
|
||||
assert_invoice_pdf invoice
|
||||
assert_not_nil invoice.debug_footprint
|
||||
|
||||
assert @cart1.payment_gateway_object.blank?
|
||||
assert invoice.payment_gateway_object.blank?
|
||||
assert_not invoice.total.blank?
|
||||
assert invoice.check_footprint
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: invoice)
|
||||
|
||||
assert_equal @cart1.state, 'paid'
|
||||
assert_equal @cart1.payment_method, 'local'
|
||||
assert_equal @cart1.paid_total, 262_500
|
||||
|
||||
stock_movement = @caisse_en_bois.product_stock_movements.last
|
||||
assert_equal stock_movement.stock_type, 'external'
|
||||
assert_equal stock_movement.reason, 'sold'
|
||||
assert_equal stock_movement.quantity, -5
|
||||
assert_equal stock_movement.order_item_id, @cart1.order_items.first.id
|
||||
|
||||
stock_movement = @panneaux.product_stock_movements.last
|
||||
assert_equal stock_movement.stock_type, 'external'
|
||||
assert_equal stock_movement.reason, 'sold'
|
||||
assert_equal stock_movement.quantity, -2
|
||||
assert_equal stock_movement.order_item_id, @cart1.order_items.last.id
|
||||
|
||||
activity = @cart1.order_activities.last
|
||||
assert_equal activity.activity_type, 'paid'
|
||||
assert_equal activity.operator_profile_id, @admin.invoicing_profile.id
|
||||
end
|
||||
|
||||
test 'admin pay user offered order by local with success' do
|
||||
login_as(@admin, scope: :user)
|
||||
|
||||
invoice_count = Invoice.count
|
||||
invoice_items_count = InvoiceItem.count
|
||||
|
||||
@cart1 = Cart::SetOfferService.new.call(@cart1, @caisse_en_bois, true)
|
||||
|
||||
post '/api/checkout/payment',
|
||||
params: {
|
||||
order_token: @cart1.token,
|
||||
customer_id: @pjproudhon.id
|
||||
}.to_json, headers: default_headers
|
||||
|
||||
@cart1.reload
|
||||
|
||||
# general assertions
|
||||
assert_equal 200, response.status
|
||||
assert_equal invoice_count + 1, Invoice.count
|
||||
assert_equal invoice_items_count + 2, InvoiceItem.count
|
||||
|
||||
# invoice_items assertions
|
||||
invoice_item = InvoiceItem.last
|
||||
|
||||
assert invoice_item.check_footprint
|
||||
|
||||
# invoice assertions
|
||||
invoice = Invoice.last
|
||||
assert_invoice_pdf invoice
|
||||
assert_not_nil invoice.debug_footprint
|
||||
|
||||
assert @cart1.payment_gateway_object.blank?
|
||||
assert invoice.payment_gateway_object.blank?
|
||||
assert_not invoice.total.blank?
|
||||
assert invoice.check_footprint
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: invoice)
|
||||
|
||||
assert_equal @cart1.state, 'paid'
|
||||
assert_equal @cart1.payment_method, 'local'
|
||||
assert_equal @cart1.paid_total, 1_000
|
||||
|
||||
stock_movement = @caisse_en_bois.product_stock_movements.last
|
||||
assert_equal stock_movement.stock_type, 'external'
|
||||
assert_equal stock_movement.reason, 'sold'
|
||||
assert_equal stock_movement.quantity, -5
|
||||
assert_equal stock_movement.order_item_id, @cart1.order_items.first.id
|
||||
|
||||
stock_movement = @panneaux.product_stock_movements.last
|
||||
assert_equal stock_movement.stock_type, 'external'
|
||||
assert_equal stock_movement.reason, 'sold'
|
||||
assert_equal stock_movement.quantity, -2
|
||||
assert_equal stock_movement.order_item_id, @cart1.order_items.last.id
|
||||
|
||||
activity = @cart1.order_activities.last
|
||||
assert_equal activity.activity_type, 'paid'
|
||||
assert_equal activity.operator_profile_id, @admin.invoicing_profile.id
|
||||
end
|
||||
|
||||
test 'admin pay himself order by wallet with success' do
|
||||
login_as(@admin, scope: :user)
|
||||
|
||||
service = WalletService.new(user: @admin, wallet: @admin.wallet)
|
||||
service.credit(@cart1.total / 100)
|
||||
|
||||
invoice_count = Invoice.count
|
||||
invoice_items_count = InvoiceItem.count
|
||||
users_credit_count = UsersCredit.count
|
||||
wallet_transactions_count = WalletTransaction.count
|
||||
|
||||
post '/api/checkout/payment',
|
||||
params: {
|
||||
order_token: @cart1.token,
|
||||
customer_id: @admin.id
|
||||
}.to_json, headers: default_headers
|
||||
|
||||
@admin.wallet.reload
|
||||
@cart1.reload
|
||||
|
||||
# general assertions
|
||||
assert_equal 200, response.status
|
||||
assert_equal @cart1.state, 'paid'
|
||||
assert_equal invoice_count + 1, Invoice.count
|
||||
assert_equal invoice_items_count + 2, InvoiceItem.count
|
||||
assert_equal users_credit_count, UsersCredit.count
|
||||
assert_equal wallet_transactions_count + 1, WalletTransaction.count
|
||||
|
||||
# invoice_items assertions
|
||||
invoice_item = InvoiceItem.last
|
||||
|
||||
assert invoice_item.check_footprint
|
||||
|
||||
# invoice assertions
|
||||
invoice = Invoice.last
|
||||
assert_invoice_pdf invoice
|
||||
assert_not_nil invoice.debug_footprint
|
||||
|
||||
assert invoice.payment_gateway_object.blank?
|
||||
assert_not invoice.total.blank?
|
||||
assert invoice.check_footprint
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: invoice)
|
||||
|
||||
# wallet
|
||||
assert_equal 0, @admin.wallet.amount
|
||||
assert_equal 2, @admin.wallet.wallet_transactions.count
|
||||
transaction = @admin.wallet.wallet_transactions.last
|
||||
assert_equal 'debit', transaction.transaction_type
|
||||
assert_equal @cart1.paid_total, 0
|
||||
assert_equal @cart1.wallet_amount / 100.0, transaction.amount
|
||||
assert_equal @cart1.payment_method, 'wallet'
|
||||
assert_equal @cart1.wallet_transaction_id, transaction.id
|
||||
assert_equal invoice.wallet_amount / 100.0, transaction.amount
|
||||
end
|
||||
|
||||
test 'admin pay user order by wallet with success' do
|
||||
login_as(@admin, scope: :user)
|
||||
|
||||
service = WalletService.new(user: @admin, wallet: @pjproudhon.wallet)
|
||||
service.credit(@cart1.total / 100)
|
||||
|
||||
invoice_count = Invoice.count
|
||||
invoice_items_count = InvoiceItem.count
|
||||
users_credit_count = UsersCredit.count
|
||||
wallet_transactions_count = WalletTransaction.count
|
||||
|
||||
post '/api/checkout/payment',
|
||||
params: {
|
||||
order_token: @cart1.token,
|
||||
customer_id: @pjproudhon.id
|
||||
}.to_json, headers: default_headers
|
||||
|
||||
@pjproudhon.wallet.reload
|
||||
@cart1.reload
|
||||
|
||||
# general assertions
|
||||
assert_equal 200, response.status
|
||||
assert_equal @cart1.state, 'paid'
|
||||
assert_equal invoice_count + 1, Invoice.count
|
||||
assert_equal invoice_items_count + 2, InvoiceItem.count
|
||||
assert_equal users_credit_count, UsersCredit.count
|
||||
assert_equal wallet_transactions_count + 1, WalletTransaction.count
|
||||
|
||||
# invoice_items assertions
|
||||
invoice_item = InvoiceItem.last
|
||||
|
||||
assert invoice_item.check_footprint
|
||||
|
||||
# invoice assertions
|
||||
invoice = Invoice.last
|
||||
assert_invoice_pdf invoice
|
||||
assert_not_nil invoice.debug_footprint
|
||||
|
||||
assert invoice.payment_gateway_object.blank?
|
||||
assert_not invoice.total.blank?
|
||||
assert invoice.check_footprint
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: invoice)
|
||||
|
||||
# wallet
|
||||
assert_equal 0, @pjproudhon.wallet.amount
|
||||
assert_equal 2, @pjproudhon.wallet.wallet_transactions.count
|
||||
transaction = @pjproudhon.wallet.wallet_transactions.last
|
||||
assert_equal 'debit', transaction.transaction_type
|
||||
assert_equal @cart1.paid_total, 0
|
||||
assert_equal @cart1.wallet_amount / 100.0, transaction.amount
|
||||
assert_equal @cart1.payment_method, 'wallet'
|
||||
assert_equal @cart1.wallet_transaction_id, transaction.id
|
||||
assert_equal invoice.wallet_amount / 100.0, transaction.amount
|
||||
end
|
||||
|
||||
test 'admin pay user order by wallet and coupon with success' do
|
||||
login_as(@admin, scope: :user)
|
||||
|
||||
service = WalletService.new(user: @admin, wallet: @pjproudhon.wallet)
|
||||
service.credit(@cart1.total / 100)
|
||||
|
||||
invoice_count = Invoice.count
|
||||
invoice_items_count = InvoiceItem.count
|
||||
users_credit_count = UsersCredit.count
|
||||
wallet_transactions_count = WalletTransaction.count
|
||||
|
||||
post '/api/checkout/payment',
|
||||
params: {
|
||||
order_token: @cart1.token,
|
||||
customer_id: @pjproudhon.id,
|
||||
coupon_code: 'GIME3EUR'
|
||||
}.to_json, headers: default_headers
|
||||
|
||||
@pjproudhon.wallet.reload
|
||||
@cart1.reload
|
||||
|
||||
# general assertions
|
||||
assert_equal 200, response.status
|
||||
assert_equal @cart1.state, 'paid'
|
||||
assert_equal invoice_count + 1, Invoice.count
|
||||
assert_equal invoice_items_count + 2, InvoiceItem.count
|
||||
assert_equal users_credit_count, UsersCredit.count
|
||||
assert_equal wallet_transactions_count + 1, WalletTransaction.count
|
||||
assert_equal Coupon.find_by(code: 'GIME3EUR').id, @cart1.coupon_id
|
||||
|
||||
# invoice_items assertions
|
||||
invoice_item = InvoiceItem.last
|
||||
assert invoice_item.check_footprint
|
||||
|
||||
# invoice assertions
|
||||
invoice = Invoice.last
|
||||
assert_invoice_pdf invoice
|
||||
assert_not_nil invoice.debug_footprint
|
||||
|
||||
assert invoice.payment_gateway_object.blank?
|
||||
assert_not invoice.total.blank?
|
||||
assert invoice.check_footprint
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: invoice)
|
||||
|
||||
# wallet
|
||||
assert_equal 3, @pjproudhon.wallet.amount
|
||||
assert_equal 2, @pjproudhon.wallet.wallet_transactions.count
|
||||
transaction = @pjproudhon.wallet.wallet_transactions.last
|
||||
assert_equal 'debit', transaction.transaction_type
|
||||
assert_equal @cart1.paid_total, 0
|
||||
assert_equal @cart1.wallet_amount, 262_200
|
||||
assert_equal 2622, transaction.amount
|
||||
end
|
||||
end
|
@ -63,6 +63,69 @@ class Store::UserPayOrderTest < ActionDispatch::IntegrationTest
|
||||
assert_equal activity.operator_profile_id, @pjproudhon.invoicing_profile.id
|
||||
end
|
||||
|
||||
test 'user pay order by cart and wallet with success' do
|
||||
login_as(@pjproudhon, scope: :user)
|
||||
|
||||
service = WalletService.new(user: @admin, wallet: @pjproudhon.wallet)
|
||||
service.credit(1)
|
||||
|
||||
invoice_count = Invoice.count
|
||||
invoice_items_count = InvoiceItem.count
|
||||
users_credit_count = UsersCredit.count
|
||||
wallet_transactions_count = WalletTransaction.count
|
||||
|
||||
VCR.use_cassette('store_order_pay_by_cart_and_wallet_success') do
|
||||
post '/api/checkout/payment',
|
||||
params: {
|
||||
payment_id: stripe_payment_method,
|
||||
order_token: @cart1.token
|
||||
}.to_json, headers: default_headers
|
||||
end
|
||||
|
||||
@pjproudhon.wallet.reload
|
||||
@cart1.reload
|
||||
|
||||
# general assertions
|
||||
assert_equal 200, response.status
|
||||
assert_equal invoice_count + 1, Invoice.count
|
||||
assert_equal invoice_items_count + 1, InvoiceItem.count
|
||||
|
||||
# invoice_items assertions
|
||||
invoice_item = InvoiceItem.last
|
||||
|
||||
assert invoice_item.check_footprint
|
||||
|
||||
# invoice assertions
|
||||
invoice = Invoice.last
|
||||
assert_invoice_pdf invoice
|
||||
assert_not_nil invoice.debug_footprint
|
||||
|
||||
assert_not @cart1.payment_gateway_object.blank?
|
||||
assert_not invoice.payment_gateway_object.blank?
|
||||
assert_not invoice.total.blank?
|
||||
assert invoice.check_footprint
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: invoice)
|
||||
|
||||
assert_equal @cart1.state, 'paid'
|
||||
assert_equal @cart1.payment_method, 'card'
|
||||
assert_equal @cart1.paid_total, 400
|
||||
assert_equal users_credit_count, UsersCredit.count
|
||||
assert_equal wallet_transactions_count + 1, WalletTransaction.count
|
||||
|
||||
# wallet
|
||||
assert_equal 0, @pjproudhon.wallet.amount
|
||||
assert_equal 2, @pjproudhon.wallet.wallet_transactions.count
|
||||
transaction = @pjproudhon.wallet.wallet_transactions.last
|
||||
assert_equal 'debit', transaction.transaction_type
|
||||
assert_equal @cart1.paid_total, 400
|
||||
assert_equal @cart1.wallet_amount / 100.0, transaction.amount
|
||||
assert_equal @cart1.payment_method, 'card'
|
||||
assert_equal @cart1.wallet_transaction_id, transaction.id
|
||||
assert_equal invoice.wallet_amount / 100.0, transaction.amount
|
||||
end
|
||||
|
||||
test 'user pay order by wallet with success' do
|
||||
login_as(@pjproudhon, scope: :user)
|
||||
|
||||
@ -76,7 +139,6 @@ class Store::UserPayOrderTest < ActionDispatch::IntegrationTest
|
||||
|
||||
post '/api/checkout/payment',
|
||||
params: {
|
||||
# payment_method_id: stripe_payment_method,
|
||||
order_token: @cart1.token
|
||||
}.to_json, headers: default_headers
|
||||
|
||||
@ -133,7 +195,6 @@ class Store::UserPayOrderTest < ActionDispatch::IntegrationTest
|
||||
|
||||
post '/api/checkout/payment',
|
||||
params: {
|
||||
# payment_method_id: stripe_payment_method,
|
||||
order_token: @cart1.token,
|
||||
coupon_code: 'GIME3EUR'
|
||||
}.to_json, headers: default_headers
|
||||
|
@ -70,7 +70,7 @@ class Cart::FindOrCreateServiceTest < ActiveSupport::TestCase
|
||||
test 'admin get a cart' do
|
||||
cart = Cart::FindOrCreateService.new(@admin).call(nil)
|
||||
assert_equal cart.state, 'cart'
|
||||
assert_equal cart.total, 261_500
|
||||
assert_equal cart.total, 262_500
|
||||
assert_equal cart.operator_profile_id, @admin.invoicing_profile.id
|
||||
assert_nil cart.statistic_profile_id
|
||||
assert_equal Order.where(operator_profile_id: @admin.invoicing_profile.id, state: 'cart').count, 1
|
||||
|
@ -5,20 +5,20 @@ require 'test_helper'
|
||||
class Cart::SetOfferServiceTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@caisse_en_bois = Product.find_by(slug: 'caisse-en-bois')
|
||||
@panneaux = Product.find_by(slug: 'panneaux-de-mdf')
|
||||
@filament = Product.find_by(slug: 'filament-pla-blanc')
|
||||
@cart = Order.find_by(token: '0DKxbAOzSXRx-amXyhmDdg1666691976019')
|
||||
end
|
||||
|
||||
test 'set offer product in cart' do
|
||||
cart = Cart::SetOfferService.new.call(@cart, @caisse_en_bois, true)
|
||||
assert_equal cart.total, 0
|
||||
assert_equal cart.total, 1000
|
||||
assert_equal cart.order_items.first.amount, @caisse_en_bois.amount
|
||||
assert_equal cart.order_items.first.is_offered, true
|
||||
end
|
||||
|
||||
test 'cannot set offer if product that isnt in cart' do
|
||||
assert_raise ActiveRecord::RecordNotFound do
|
||||
Cart::SetOfferService.new.call(@cart, @panneaux, true)
|
||||
Cart::SetOfferService.new.call(@cart, @filament, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,338 @@
|
||||
---
|
||||
http_interactions:
|
||||
- request:
|
||||
method: post
|
||||
uri: https://api.stripe.com/v1/payment_methods
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: type=card&card[number]=4242424242424242&card[exp_month]=4&card[exp_year]=2023&card[cvc]=314
|
||||
headers:
|
||||
User-Agent:
|
||||
- Stripe/v1 RubyBindings/5.29.0
|
||||
Authorization:
|
||||
- Bearer sk_test_testfaketestfaketestfake
|
||||
Content-Type:
|
||||
- application/x-www-form-urlencoded
|
||||
Stripe-Version:
|
||||
- '2019-08-14'
|
||||
X-Stripe-Client-User-Agent:
|
||||
- '{"bindings_version":"5.29.0","lang":"ruby","lang_version":"2.6.3 p62 (2019-04-16)","platform":"x86_64-darwin18","engine":"ruby","publisher":"stripe","uname":"Darwin
|
||||
MacBook-Pro-Sleede-Peng 20.6.0 Darwin Kernel Version 20.6.0: Thu Sep 29 20:15:11
|
||||
PDT 2022; root:xnu-7195.141.42~1/RELEASE_X86_64 x86_64","hostname":"MacBook-Pro-Sleede-Peng"}'
|
||||
Accept-Encoding:
|
||||
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
||||
Accept:
|
||||
- "*/*"
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
Server:
|
||||
- nginx
|
||||
Date:
|
||||
- Mon, 07 Nov 2022 17:22:23 GMT
|
||||
Content-Type:
|
||||
- application/json
|
||||
Content-Length:
|
||||
- '930'
|
||||
Connection:
|
||||
- keep-alive
|
||||
Access-Control-Allow-Credentials:
|
||||
- 'true'
|
||||
Access-Control-Allow-Methods:
|
||||
- GET, POST, HEAD, OPTIONS, DELETE
|
||||
Access-Control-Allow-Origin:
|
||||
- "*"
|
||||
Access-Control-Expose-Headers:
|
||||
- Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required
|
||||
Access-Control-Max-Age:
|
||||
- '300'
|
||||
Cache-Control:
|
||||
- no-cache, no-store
|
||||
Idempotency-Key:
|
||||
- 3d420ca2-b79a-451b-88bc-56efb989ae3e
|
||||
Original-Request:
|
||||
- req_7tnZKRYjblvjJF
|
||||
Request-Id:
|
||||
- req_7tnZKRYjblvjJF
|
||||
Stripe-Should-Retry:
|
||||
- 'false'
|
||||
Stripe-Version:
|
||||
- '2019-08-14'
|
||||
Strict-Transport-Security:
|
||||
- max-age=63072000; includeSubDomains; preload
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: |-
|
||||
{
|
||||
"id": "pm_1M1Z1f2sOmf47Nz9y4qaYQap",
|
||||
"object": "payment_method",
|
||||
"billing_details": {
|
||||
"address": {
|
||||
"city": null,
|
||||
"country": null,
|
||||
"line1": null,
|
||||
"line2": null,
|
||||
"postal_code": null,
|
||||
"state": null
|
||||
},
|
||||
"email": null,
|
||||
"name": null,
|
||||
"phone": null
|
||||
},
|
||||
"card": {
|
||||
"brand": "visa",
|
||||
"checks": {
|
||||
"address_line1_check": null,
|
||||
"address_postal_code_check": null,
|
||||
"cvc_check": "unchecked"
|
||||
},
|
||||
"country": "US",
|
||||
"exp_month": 4,
|
||||
"exp_year": 2023,
|
||||
"fingerprint": "o52jybR7bnmNn6AT",
|
||||
"funding": "credit",
|
||||
"generated_from": null,
|
||||
"last4": "4242",
|
||||
"networks": {
|
||||
"available": [
|
||||
"visa"
|
||||
],
|
||||
"preferred": null
|
||||
},
|
||||
"three_d_secure_usage": {
|
||||
"supported": true
|
||||
},
|
||||
"wallet": null
|
||||
},
|
||||
"created": 1667841743,
|
||||
"customer": null,
|
||||
"livemode": false,
|
||||
"metadata": {},
|
||||
"type": "card"
|
||||
}
|
||||
recorded_at: Mon, 07 Nov 2022 17:22:24 GMT
|
||||
- request:
|
||||
method: post
|
||||
uri: https://api.stripe.com/v1/payment_intents
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: payment_method=pm_1M1Z1f2sOmf47Nz9y4qaYQap&amount=162500¤cy=usd&confirmation_method=manual&confirm=true&customer=cus_8CyNk3UTi8lvCc
|
||||
headers:
|
||||
User-Agent:
|
||||
- Stripe/v1 RubyBindings/5.29.0
|
||||
Authorization:
|
||||
- Bearer sk_test_testfaketestfaketestfake
|
||||
Content-Type:
|
||||
- application/x-www-form-urlencoded
|
||||
X-Stripe-Client-Telemetry:
|
||||
- '{"last_request_metrics":{"request_id":"req_7tnZKRYjblvjJF","request_duration_ms":697}}'
|
||||
Stripe-Version:
|
||||
- '2019-08-14'
|
||||
X-Stripe-Client-User-Agent:
|
||||
- '{"bindings_version":"5.29.0","lang":"ruby","lang_version":"2.6.3 p62 (2019-04-16)","platform":"x86_64-darwin18","engine":"ruby","publisher":"stripe","uname":"Darwin
|
||||
MacBook-Pro-Sleede-Peng 20.6.0 Darwin Kernel Version 20.6.0: Thu Sep 29 20:15:11
|
||||
PDT 2022; root:xnu-7195.141.42~1/RELEASE_X86_64 x86_64","hostname":"MacBook-Pro-Sleede-Peng"}'
|
||||
Accept-Encoding:
|
||||
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
||||
Accept:
|
||||
- "*/*"
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
Server:
|
||||
- nginx
|
||||
Date:
|
||||
- Mon, 07 Nov 2022 17:22:25 GMT
|
||||
Content-Type:
|
||||
- application/json
|
||||
Content-Length:
|
||||
- '4476'
|
||||
Connection:
|
||||
- keep-alive
|
||||
Access-Control-Allow-Credentials:
|
||||
- 'true'
|
||||
Access-Control-Allow-Methods:
|
||||
- GET, POST, HEAD, OPTIONS, DELETE
|
||||
Access-Control-Allow-Origin:
|
||||
- "*"
|
||||
Access-Control-Expose-Headers:
|
||||
- Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required
|
||||
Access-Control-Max-Age:
|
||||
- '300'
|
||||
Cache-Control:
|
||||
- no-cache, no-store
|
||||
Idempotency-Key:
|
||||
- 5294d6d7-d766-4aa5-bac1-be52f491fa20
|
||||
Original-Request:
|
||||
- req_c0S6XFCR5hlcc9
|
||||
Request-Id:
|
||||
- req_c0S6XFCR5hlcc9
|
||||
Stripe-Should-Retry:
|
||||
- 'false'
|
||||
Stripe-Version:
|
||||
- '2019-08-14'
|
||||
Strict-Transport-Security:
|
||||
- max-age=63072000; includeSubDomains; preload
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: |-
|
||||
{
|
||||
"id": "pi_3M1Z1g2sOmf47Nz91KcAbrWR",
|
||||
"object": "payment_intent",
|
||||
"amount": 162500,
|
||||
"amount_capturable": 0,
|
||||
"amount_details": {
|
||||
"tip": {}
|
||||
},
|
||||
"amount_received": 162500,
|
||||
"application": null,
|
||||
"application_fee_amount": null,
|
||||
"automatic_payment_methods": null,
|
||||
"canceled_at": null,
|
||||
"cancellation_reason": null,
|
||||
"capture_method": "automatic",
|
||||
"charges": {
|
||||
"object": "list",
|
||||
"data": [
|
||||
{
|
||||
"id": "ch_3M1Z1g2sOmf47Nz91YJQvMPK",
|
||||
"object": "charge",
|
||||
"amount": 162500,
|
||||
"amount_captured": 162500,
|
||||
"amount_refunded": 0,
|
||||
"application": null,
|
||||
"application_fee": null,
|
||||
"application_fee_amount": null,
|
||||
"balance_transaction": "txn_3M1Z1g2sOmf47Nz913ZvXNvF",
|
||||
"billing_details": {
|
||||
"address": {
|
||||
"city": null,
|
||||
"country": null,
|
||||
"line1": null,
|
||||
"line2": null,
|
||||
"postal_code": null,
|
||||
"state": null
|
||||
},
|
||||
"email": null,
|
||||
"name": null,
|
||||
"phone": null
|
||||
},
|
||||
"calculated_statement_descriptor": "Stripe",
|
||||
"captured": true,
|
||||
"created": 1667841744,
|
||||
"currency": "usd",
|
||||
"customer": "cus_8CyNk3UTi8lvCc",
|
||||
"description": null,
|
||||
"destination": null,
|
||||
"dispute": null,
|
||||
"disputed": false,
|
||||
"failure_balance_transaction": null,
|
||||
"failure_code": null,
|
||||
"failure_message": null,
|
||||
"fraud_details": {},
|
||||
"invoice": null,
|
||||
"livemode": false,
|
||||
"metadata": {},
|
||||
"on_behalf_of": null,
|
||||
"order": null,
|
||||
"outcome": {
|
||||
"network_status": "approved_by_network",
|
||||
"reason": null,
|
||||
"risk_level": "normal",
|
||||
"risk_score": 45,
|
||||
"seller_message": "Payment complete.",
|
||||
"type": "authorized"
|
||||
},
|
||||
"paid": true,
|
||||
"payment_intent": "pi_3M1Z1g2sOmf47Nz91KcAbrWR",
|
||||
"payment_method": "pm_1M1Z1f2sOmf47Nz9y4qaYQap",
|
||||
"payment_method_details": {
|
||||
"card": {
|
||||
"brand": "visa",
|
||||
"checks": {
|
||||
"address_line1_check": null,
|
||||
"address_postal_code_check": null,
|
||||
"cvc_check": "pass"
|
||||
},
|
||||
"country": "US",
|
||||
"exp_month": 4,
|
||||
"exp_year": 2023,
|
||||
"fingerprint": "o52jybR7bnmNn6AT",
|
||||
"funding": "credit",
|
||||
"installments": null,
|
||||
"last4": "4242",
|
||||
"mandate": null,
|
||||
"network": "visa",
|
||||
"three_d_secure": null,
|
||||
"wallet": null
|
||||
},
|
||||
"type": "card"
|
||||
},
|
||||
"receipt_email": null,
|
||||
"receipt_number": null,
|
||||
"receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xMDNyRTYyc09tZjQ3Tno5KNH9pJsGMgbMAdBS9Kg6LBbMQFUWP1mmaiHjAUCgW-WYHRH5dwIHTlYhiTVjiSL5fqEMQr17GSJhWPA-",
|
||||
"refunded": false,
|
||||
"refunds": {
|
||||
"object": "list",
|
||||
"data": [],
|
||||
"has_more": false,
|
||||
"total_count": 0,
|
||||
"url": "/v1/charges/ch_3M1Z1g2sOmf47Nz91YJQvMPK/refunds"
|
||||
},
|
||||
"review": null,
|
||||
"shipping": null,
|
||||
"source": null,
|
||||
"source_transfer": null,
|
||||
"statement_descriptor": null,
|
||||
"statement_descriptor_suffix": null,
|
||||
"status": "succeeded",
|
||||
"transfer_data": null,
|
||||
"transfer_group": null
|
||||
}
|
||||
],
|
||||
"has_more": false,
|
||||
"total_count": 1,
|
||||
"url": "/v1/charges?payment_intent=pi_3M1Z1g2sOmf47Nz91KcAbrWR"
|
||||
},
|
||||
"client_secret": "pi_3M1Z1g2sOmf47Nz91KcAbrWR_secret_ocSaI8LfCIvNBzfXl5iwRB9kS",
|
||||
"confirmation_method": "manual",
|
||||
"created": 1667841744,
|
||||
"currency": "usd",
|
||||
"customer": "cus_8CyNk3UTi8lvCc",
|
||||
"description": null,
|
||||
"invoice": null,
|
||||
"last_payment_error": null,
|
||||
"livemode": false,
|
||||
"metadata": {},
|
||||
"next_action": null,
|
||||
"on_behalf_of": null,
|
||||
"payment_method": "pm_1M1Z1f2sOmf47Nz9y4qaYQap",
|
||||
"payment_method_options": {
|
||||
"card": {
|
||||
"installments": null,
|
||||
"mandate_options": null,
|
||||
"network": null,
|
||||
"request_three_d_secure": "automatic"
|
||||
}
|
||||
},
|
||||
"payment_method_types": [
|
||||
"card"
|
||||
],
|
||||
"processing": null,
|
||||
"receipt_email": null,
|
||||
"review": null,
|
||||
"setup_future_usage": null,
|
||||
"shipping": null,
|
||||
"source": null,
|
||||
"statement_descriptor": null,
|
||||
"statement_descriptor_suffix": null,
|
||||
"status": "succeeded",
|
||||
"transfer_data": null,
|
||||
"transfer_group": null
|
||||
}
|
||||
recorded_at: Mon, 07 Nov 2022 17:22:26 GMT
|
||||
recorded_with: VCR 6.0.0
|
340
test/vcr_cassettes/store_order_admin_pay_by_cart_success.yml
Normal file
340
test/vcr_cassettes/store_order_admin_pay_by_cart_success.yml
Normal file
@ -0,0 +1,340 @@
|
||||
---
|
||||
http_interactions:
|
||||
- request:
|
||||
method: post
|
||||
uri: https://api.stripe.com/v1/payment_methods
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: type=card&card[number]=4242424242424242&card[exp_month]=4&card[exp_year]=2023&card[cvc]=314
|
||||
headers:
|
||||
User-Agent:
|
||||
- Stripe/v1 RubyBindings/5.29.0
|
||||
Authorization:
|
||||
- Bearer sk_test_testfaketestfaketestfake
|
||||
Content-Type:
|
||||
- application/x-www-form-urlencoded
|
||||
X-Stripe-Client-Telemetry:
|
||||
- '{"last_request_metrics":{"request_id":"req_RmcFNPXaqrPUG5","request_duration_ms":2}}'
|
||||
Stripe-Version:
|
||||
- '2019-08-14'
|
||||
X-Stripe-Client-User-Agent:
|
||||
- '{"bindings_version":"5.29.0","lang":"ruby","lang_version":"2.6.3 p62 (2019-04-16)","platform":"x86_64-darwin18","engine":"ruby","publisher":"stripe","uname":"Darwin
|
||||
MacBook-Pro-Sleede-Peng 20.6.0 Darwin Kernel Version 20.6.0: Thu Sep 29 20:15:11
|
||||
PDT 2022; root:xnu-7195.141.42~1/RELEASE_X86_64 x86_64","hostname":"MacBook-Pro-Sleede-Peng"}'
|
||||
Accept-Encoding:
|
||||
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
||||
Accept:
|
||||
- "*/*"
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
Server:
|
||||
- nginx
|
||||
Date:
|
||||
- Mon, 07 Nov 2022 16:37:43 GMT
|
||||
Content-Type:
|
||||
- application/json
|
||||
Content-Length:
|
||||
- '930'
|
||||
Connection:
|
||||
- keep-alive
|
||||
Access-Control-Allow-Credentials:
|
||||
- 'true'
|
||||
Access-Control-Allow-Methods:
|
||||
- GET, POST, HEAD, OPTIONS, DELETE
|
||||
Access-Control-Allow-Origin:
|
||||
- "*"
|
||||
Access-Control-Expose-Headers:
|
||||
- Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required
|
||||
Access-Control-Max-Age:
|
||||
- '300'
|
||||
Cache-Control:
|
||||
- no-cache, no-store
|
||||
Idempotency-Key:
|
||||
- 79f4b0fa-8f75-413e-9d49-d676004060f3
|
||||
Original-Request:
|
||||
- req_XjXHG1cRekGj4r
|
||||
Request-Id:
|
||||
- req_XjXHG1cRekGj4r
|
||||
Stripe-Should-Retry:
|
||||
- 'false'
|
||||
Stripe-Version:
|
||||
- '2019-08-14'
|
||||
Strict-Transport-Security:
|
||||
- max-age=63072000; includeSubDomains; preload
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: |-
|
||||
{
|
||||
"id": "pm_1M1YKR2sOmf47Nz9zhudFmj4",
|
||||
"object": "payment_method",
|
||||
"billing_details": {
|
||||
"address": {
|
||||
"city": null,
|
||||
"country": null,
|
||||
"line1": null,
|
||||
"line2": null,
|
||||
"postal_code": null,
|
||||
"state": null
|
||||
},
|
||||
"email": null,
|
||||
"name": null,
|
||||
"phone": null
|
||||
},
|
||||
"card": {
|
||||
"brand": "visa",
|
||||
"checks": {
|
||||
"address_line1_check": null,
|
||||
"address_postal_code_check": null,
|
||||
"cvc_check": "unchecked"
|
||||
},
|
||||
"country": "US",
|
||||
"exp_month": 4,
|
||||
"exp_year": 2023,
|
||||
"fingerprint": "o52jybR7bnmNn6AT",
|
||||
"funding": "credit",
|
||||
"generated_from": null,
|
||||
"last4": "4242",
|
||||
"networks": {
|
||||
"available": [
|
||||
"visa"
|
||||
],
|
||||
"preferred": null
|
||||
},
|
||||
"three_d_secure_usage": {
|
||||
"supported": true
|
||||
},
|
||||
"wallet": null
|
||||
},
|
||||
"created": 1667839063,
|
||||
"customer": null,
|
||||
"livemode": false,
|
||||
"metadata": {},
|
||||
"type": "card"
|
||||
}
|
||||
recorded_at: Mon, 07 Nov 2022 16:37:43 GMT
|
||||
- request:
|
||||
method: post
|
||||
uri: https://api.stripe.com/v1/payment_intents
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: payment_method=pm_1M1YKR2sOmf47Nz9zhudFmj4&amount=262500¤cy=usd&confirmation_method=manual&confirm=true&customer=cus_8CyNk3UTi8lvCc
|
||||
headers:
|
||||
User-Agent:
|
||||
- Stripe/v1 RubyBindings/5.29.0
|
||||
Authorization:
|
||||
- Bearer sk_test_testfaketestfaketestfake
|
||||
Content-Type:
|
||||
- application/x-www-form-urlencoded
|
||||
X-Stripe-Client-Telemetry:
|
||||
- '{"last_request_metrics":{"request_id":"req_XjXHG1cRekGj4r","request_duration_ms":747}}'
|
||||
Stripe-Version:
|
||||
- '2019-08-14'
|
||||
X-Stripe-Client-User-Agent:
|
||||
- '{"bindings_version":"5.29.0","lang":"ruby","lang_version":"2.6.3 p62 (2019-04-16)","platform":"x86_64-darwin18","engine":"ruby","publisher":"stripe","uname":"Darwin
|
||||
MacBook-Pro-Sleede-Peng 20.6.0 Darwin Kernel Version 20.6.0: Thu Sep 29 20:15:11
|
||||
PDT 2022; root:xnu-7195.141.42~1/RELEASE_X86_64 x86_64","hostname":"MacBook-Pro-Sleede-Peng"}'
|
||||
Accept-Encoding:
|
||||
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
||||
Accept:
|
||||
- "*/*"
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
Server:
|
||||
- nginx
|
||||
Date:
|
||||
- Mon, 07 Nov 2022 16:37:45 GMT
|
||||
Content-Type:
|
||||
- application/json
|
||||
Content-Length:
|
||||
- '4476'
|
||||
Connection:
|
||||
- keep-alive
|
||||
Access-Control-Allow-Credentials:
|
||||
- 'true'
|
||||
Access-Control-Allow-Methods:
|
||||
- GET, POST, HEAD, OPTIONS, DELETE
|
||||
Access-Control-Allow-Origin:
|
||||
- "*"
|
||||
Access-Control-Expose-Headers:
|
||||
- Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required
|
||||
Access-Control-Max-Age:
|
||||
- '300'
|
||||
Cache-Control:
|
||||
- no-cache, no-store
|
||||
Idempotency-Key:
|
||||
- e3937b40-2f56-48ad-a6f0-45cd4f8561b6
|
||||
Original-Request:
|
||||
- req_OOfatPeQh69g1l
|
||||
Request-Id:
|
||||
- req_OOfatPeQh69g1l
|
||||
Stripe-Should-Retry:
|
||||
- 'false'
|
||||
Stripe-Version:
|
||||
- '2019-08-14'
|
||||
Strict-Transport-Security:
|
||||
- max-age=63072000; includeSubDomains; preload
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: |-
|
||||
{
|
||||
"id": "pi_3M1YKR2sOmf47Nz91drXiltW",
|
||||
"object": "payment_intent",
|
||||
"amount": 262500,
|
||||
"amount_capturable": 0,
|
||||
"amount_details": {
|
||||
"tip": {}
|
||||
},
|
||||
"amount_received": 262500,
|
||||
"application": null,
|
||||
"application_fee_amount": null,
|
||||
"automatic_payment_methods": null,
|
||||
"canceled_at": null,
|
||||
"cancellation_reason": null,
|
||||
"capture_method": "automatic",
|
||||
"charges": {
|
||||
"object": "list",
|
||||
"data": [
|
||||
{
|
||||
"id": "ch_3M1YKR2sOmf47Nz91vWs1pmT",
|
||||
"object": "charge",
|
||||
"amount": 262500,
|
||||
"amount_captured": 262500,
|
||||
"amount_refunded": 0,
|
||||
"application": null,
|
||||
"application_fee": null,
|
||||
"application_fee_amount": null,
|
||||
"balance_transaction": "txn_3M1YKR2sOmf47Nz91H5LYpIY",
|
||||
"billing_details": {
|
||||
"address": {
|
||||
"city": null,
|
||||
"country": null,
|
||||
"line1": null,
|
||||
"line2": null,
|
||||
"postal_code": null,
|
||||
"state": null
|
||||
},
|
||||
"email": null,
|
||||
"name": null,
|
||||
"phone": null
|
||||
},
|
||||
"calculated_statement_descriptor": "Stripe",
|
||||
"captured": true,
|
||||
"created": 1667839064,
|
||||
"currency": "usd",
|
||||
"customer": "cus_8CyNk3UTi8lvCc",
|
||||
"description": null,
|
||||
"destination": null,
|
||||
"dispute": null,
|
||||
"disputed": false,
|
||||
"failure_balance_transaction": null,
|
||||
"failure_code": null,
|
||||
"failure_message": null,
|
||||
"fraud_details": {},
|
||||
"invoice": null,
|
||||
"livemode": false,
|
||||
"metadata": {},
|
||||
"on_behalf_of": null,
|
||||
"order": null,
|
||||
"outcome": {
|
||||
"network_status": "approved_by_network",
|
||||
"reason": null,
|
||||
"risk_level": "normal",
|
||||
"risk_score": 45,
|
||||
"seller_message": "Payment complete.",
|
||||
"type": "authorized"
|
||||
},
|
||||
"paid": true,
|
||||
"payment_intent": "pi_3M1YKR2sOmf47Nz91drXiltW",
|
||||
"payment_method": "pm_1M1YKR2sOmf47Nz9zhudFmj4",
|
||||
"payment_method_details": {
|
||||
"card": {
|
||||
"brand": "visa",
|
||||
"checks": {
|
||||
"address_line1_check": null,
|
||||
"address_postal_code_check": null,
|
||||
"cvc_check": "pass"
|
||||
},
|
||||
"country": "US",
|
||||
"exp_month": 4,
|
||||
"exp_year": 2023,
|
||||
"fingerprint": "o52jybR7bnmNn6AT",
|
||||
"funding": "credit",
|
||||
"installments": null,
|
||||
"last4": "4242",
|
||||
"mandate": null,
|
||||
"network": "visa",
|
||||
"three_d_secure": null,
|
||||
"wallet": null
|
||||
},
|
||||
"type": "card"
|
||||
},
|
||||
"receipt_email": null,
|
||||
"receipt_number": null,
|
||||
"receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xMDNyRTYyc09tZjQ3Tno5KNnopJsGMgYH2kV57SE6LBZXrW4wqlWRDUWQvuladk_TMDrnHcxaLwpAjVvyXY2T71ztlsFRB6pt77PJ",
|
||||
"refunded": false,
|
||||
"refunds": {
|
||||
"object": "list",
|
||||
"data": [],
|
||||
"has_more": false,
|
||||
"total_count": 0,
|
||||
"url": "/v1/charges/ch_3M1YKR2sOmf47Nz91vWs1pmT/refunds"
|
||||
},
|
||||
"review": null,
|
||||
"shipping": null,
|
||||
"source": null,
|
||||
"source_transfer": null,
|
||||
"statement_descriptor": null,
|
||||
"statement_descriptor_suffix": null,
|
||||
"status": "succeeded",
|
||||
"transfer_data": null,
|
||||
"transfer_group": null
|
||||
}
|
||||
],
|
||||
"has_more": false,
|
||||
"total_count": 1,
|
||||
"url": "/v1/charges?payment_intent=pi_3M1YKR2sOmf47Nz91drXiltW"
|
||||
},
|
||||
"client_secret": "pi_3M1YKR2sOmf47Nz91drXiltW_secret_0gbfWYm7cOart4zGoozKDSQP0",
|
||||
"confirmation_method": "manual",
|
||||
"created": 1667839063,
|
||||
"currency": "usd",
|
||||
"customer": "cus_8CyNk3UTi8lvCc",
|
||||
"description": null,
|
||||
"invoice": null,
|
||||
"last_payment_error": null,
|
||||
"livemode": false,
|
||||
"metadata": {},
|
||||
"next_action": null,
|
||||
"on_behalf_of": null,
|
||||
"payment_method": "pm_1M1YKR2sOmf47Nz9zhudFmj4",
|
||||
"payment_method_options": {
|
||||
"card": {
|
||||
"installments": null,
|
||||
"mandate_options": null,
|
||||
"network": null,
|
||||
"request_three_d_secure": "automatic"
|
||||
}
|
||||
},
|
||||
"payment_method_types": [
|
||||
"card"
|
||||
],
|
||||
"processing": null,
|
||||
"receipt_email": null,
|
||||
"review": null,
|
||||
"setup_future_usage": null,
|
||||
"shipping": null,
|
||||
"source": null,
|
||||
"statement_descriptor": null,
|
||||
"statement_descriptor_suffix": null,
|
||||
"status": "succeeded",
|
||||
"transfer_data": null,
|
||||
"transfer_group": null
|
||||
}
|
||||
recorded_at: Mon, 07 Nov 2022 16:37:45 GMT
|
||||
recorded_with: VCR 6.0.0
|
@ -0,0 +1,338 @@
|
||||
---
|
||||
http_interactions:
|
||||
- request:
|
||||
method: post
|
||||
uri: https://api.stripe.com/v1/payment_methods
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: type=card&card[number]=4242424242424242&card[exp_month]=4&card[exp_year]=2023&card[cvc]=314
|
||||
headers:
|
||||
User-Agent:
|
||||
- Stripe/v1 RubyBindings/5.29.0
|
||||
Authorization:
|
||||
- Bearer sk_test_testfaketestfaketestfake
|
||||
Content-Type:
|
||||
- application/x-www-form-urlencoded
|
||||
Stripe-Version:
|
||||
- '2019-08-14'
|
||||
X-Stripe-Client-User-Agent:
|
||||
- '{"bindings_version":"5.29.0","lang":"ruby","lang_version":"2.6.3 p62 (2019-04-16)","platform":"x86_64-darwin18","engine":"ruby","publisher":"stripe","uname":"Darwin
|
||||
MacBook-Pro-Sleede-Peng 20.6.0 Darwin Kernel Version 20.6.0: Thu Sep 29 20:15:11
|
||||
PDT 2022; root:xnu-7195.141.42~1/RELEASE_X86_64 x86_64","hostname":"MacBook-Pro-Sleede-Peng"}'
|
||||
Accept-Encoding:
|
||||
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
||||
Accept:
|
||||
- "*/*"
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
Server:
|
||||
- nginx
|
||||
Date:
|
||||
- Mon, 07 Nov 2022 17:46:28 GMT
|
||||
Content-Type:
|
||||
- application/json
|
||||
Content-Length:
|
||||
- '930'
|
||||
Connection:
|
||||
- keep-alive
|
||||
Access-Control-Allow-Credentials:
|
||||
- 'true'
|
||||
Access-Control-Allow-Methods:
|
||||
- GET, POST, HEAD, OPTIONS, DELETE
|
||||
Access-Control-Allow-Origin:
|
||||
- "*"
|
||||
Access-Control-Expose-Headers:
|
||||
- Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required
|
||||
Access-Control-Max-Age:
|
||||
- '300'
|
||||
Cache-Control:
|
||||
- no-cache, no-store
|
||||
Idempotency-Key:
|
||||
- 1f9773d4-f524-44dc-90f2-dde90fea1744
|
||||
Original-Request:
|
||||
- req_Fbkchw5l1kFzvM
|
||||
Request-Id:
|
||||
- req_Fbkchw5l1kFzvM
|
||||
Stripe-Should-Retry:
|
||||
- 'false'
|
||||
Stripe-Version:
|
||||
- '2019-08-14'
|
||||
Strict-Transport-Security:
|
||||
- max-age=63072000; includeSubDomains; preload
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: |-
|
||||
{
|
||||
"id": "pm_1M1ZOy2sOmf47Nz9S0LQW3tB",
|
||||
"object": "payment_method",
|
||||
"billing_details": {
|
||||
"address": {
|
||||
"city": null,
|
||||
"country": null,
|
||||
"line1": null,
|
||||
"line2": null,
|
||||
"postal_code": null,
|
||||
"state": null
|
||||
},
|
||||
"email": null,
|
||||
"name": null,
|
||||
"phone": null
|
||||
},
|
||||
"card": {
|
||||
"brand": "visa",
|
||||
"checks": {
|
||||
"address_line1_check": null,
|
||||
"address_postal_code_check": null,
|
||||
"cvc_check": "unchecked"
|
||||
},
|
||||
"country": "US",
|
||||
"exp_month": 4,
|
||||
"exp_year": 2023,
|
||||
"fingerprint": "o52jybR7bnmNn6AT",
|
||||
"funding": "credit",
|
||||
"generated_from": null,
|
||||
"last4": "4242",
|
||||
"networks": {
|
||||
"available": [
|
||||
"visa"
|
||||
],
|
||||
"preferred": null
|
||||
},
|
||||
"three_d_secure_usage": {
|
||||
"supported": true
|
||||
},
|
||||
"wallet": null
|
||||
},
|
||||
"created": 1667843188,
|
||||
"customer": null,
|
||||
"livemode": false,
|
||||
"metadata": {},
|
||||
"type": "card"
|
||||
}
|
||||
recorded_at: Mon, 07 Nov 2022 17:46:28 GMT
|
||||
- request:
|
||||
method: post
|
||||
uri: https://api.stripe.com/v1/payment_intents
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: payment_method=pm_1M1ZOy2sOmf47Nz9S0LQW3tB&amount=400¤cy=usd&confirmation_method=manual&confirm=true&customer=cus_IhIynmoJbzLpwX
|
||||
headers:
|
||||
User-Agent:
|
||||
- Stripe/v1 RubyBindings/5.29.0
|
||||
Authorization:
|
||||
- Bearer sk_test_testfaketestfaketestfake
|
||||
Content-Type:
|
||||
- application/x-www-form-urlencoded
|
||||
X-Stripe-Client-Telemetry:
|
||||
- '{"last_request_metrics":{"request_id":"req_Fbkchw5l1kFzvM","request_duration_ms":681}}'
|
||||
Stripe-Version:
|
||||
- '2019-08-14'
|
||||
X-Stripe-Client-User-Agent:
|
||||
- '{"bindings_version":"5.29.0","lang":"ruby","lang_version":"2.6.3 p62 (2019-04-16)","platform":"x86_64-darwin18","engine":"ruby","publisher":"stripe","uname":"Darwin
|
||||
MacBook-Pro-Sleede-Peng 20.6.0 Darwin Kernel Version 20.6.0: Thu Sep 29 20:15:11
|
||||
PDT 2022; root:xnu-7195.141.42~1/RELEASE_X86_64 x86_64","hostname":"MacBook-Pro-Sleede-Peng"}'
|
||||
Accept-Encoding:
|
||||
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
||||
Accept:
|
||||
- "*/*"
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
Server:
|
||||
- nginx
|
||||
Date:
|
||||
- Mon, 07 Nov 2022 17:46:31 GMT
|
||||
Content-Type:
|
||||
- application/json
|
||||
Content-Length:
|
||||
- '4464'
|
||||
Connection:
|
||||
- keep-alive
|
||||
Access-Control-Allow-Credentials:
|
||||
- 'true'
|
||||
Access-Control-Allow-Methods:
|
||||
- GET, POST, HEAD, OPTIONS, DELETE
|
||||
Access-Control-Allow-Origin:
|
||||
- "*"
|
||||
Access-Control-Expose-Headers:
|
||||
- Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required
|
||||
Access-Control-Max-Age:
|
||||
- '300'
|
||||
Cache-Control:
|
||||
- no-cache, no-store
|
||||
Idempotency-Key:
|
||||
- 9452e086-c4bb-4c4e-94fe-ddef5a8f8cc1
|
||||
Original-Request:
|
||||
- req_GIkX2D4yu7OXRO
|
||||
Request-Id:
|
||||
- req_GIkX2D4yu7OXRO
|
||||
Stripe-Should-Retry:
|
||||
- 'false'
|
||||
Stripe-Version:
|
||||
- '2019-08-14'
|
||||
Strict-Transport-Security:
|
||||
- max-age=63072000; includeSubDomains; preload
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: |-
|
||||
{
|
||||
"id": "pi_3M1ZOz2sOmf47Nz90tK9gllB",
|
||||
"object": "payment_intent",
|
||||
"amount": 400,
|
||||
"amount_capturable": 0,
|
||||
"amount_details": {
|
||||
"tip": {}
|
||||
},
|
||||
"amount_received": 400,
|
||||
"application": null,
|
||||
"application_fee_amount": null,
|
||||
"automatic_payment_methods": null,
|
||||
"canceled_at": null,
|
||||
"cancellation_reason": null,
|
||||
"capture_method": "automatic",
|
||||
"charges": {
|
||||
"object": "list",
|
||||
"data": [
|
||||
{
|
||||
"id": "ch_3M1ZOz2sOmf47Nz90wkd0Upl",
|
||||
"object": "charge",
|
||||
"amount": 400,
|
||||
"amount_captured": 400,
|
||||
"amount_refunded": 0,
|
||||
"application": null,
|
||||
"application_fee": null,
|
||||
"application_fee_amount": null,
|
||||
"balance_transaction": "txn_3M1ZOz2sOmf47Nz90XN9Q2k6",
|
||||
"billing_details": {
|
||||
"address": {
|
||||
"city": null,
|
||||
"country": null,
|
||||
"line1": null,
|
||||
"line2": null,
|
||||
"postal_code": null,
|
||||
"state": null
|
||||
},
|
||||
"email": null,
|
||||
"name": null,
|
||||
"phone": null
|
||||
},
|
||||
"calculated_statement_descriptor": "Stripe",
|
||||
"captured": true,
|
||||
"created": 1667843190,
|
||||
"currency": "usd",
|
||||
"customer": "cus_IhIynmoJbzLpwX",
|
||||
"description": null,
|
||||
"destination": null,
|
||||
"dispute": null,
|
||||
"disputed": false,
|
||||
"failure_balance_transaction": null,
|
||||
"failure_code": null,
|
||||
"failure_message": null,
|
||||
"fraud_details": {},
|
||||
"invoice": null,
|
||||
"livemode": false,
|
||||
"metadata": {},
|
||||
"on_behalf_of": null,
|
||||
"order": null,
|
||||
"outcome": {
|
||||
"network_status": "approved_by_network",
|
||||
"reason": null,
|
||||
"risk_level": "normal",
|
||||
"risk_score": 49,
|
||||
"seller_message": "Payment complete.",
|
||||
"type": "authorized"
|
||||
},
|
||||
"paid": true,
|
||||
"payment_intent": "pi_3M1ZOz2sOmf47Nz90tK9gllB",
|
||||
"payment_method": "pm_1M1ZOy2sOmf47Nz9S0LQW3tB",
|
||||
"payment_method_details": {
|
||||
"card": {
|
||||
"brand": "visa",
|
||||
"checks": {
|
||||
"address_line1_check": null,
|
||||
"address_postal_code_check": null,
|
||||
"cvc_check": "pass"
|
||||
},
|
||||
"country": "US",
|
||||
"exp_month": 4,
|
||||
"exp_year": 2023,
|
||||
"fingerprint": "o52jybR7bnmNn6AT",
|
||||
"funding": "credit",
|
||||
"installments": null,
|
||||
"last4": "4242",
|
||||
"mandate": null,
|
||||
"network": "visa",
|
||||
"three_d_secure": null,
|
||||
"wallet": null
|
||||
},
|
||||
"type": "card"
|
||||
},
|
||||
"receipt_email": null,
|
||||
"receipt_number": null,
|
||||
"receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xMDNyRTYyc09tZjQ3Tno5KPaIpZsGMgYxLskxGmo6LBa54zBFlRI8uQmwFIdZImPLTv2fAl6N6X554JBe_MnNGACgZ-jJ5M4MYK4R",
|
||||
"refunded": false,
|
||||
"refunds": {
|
||||
"object": "list",
|
||||
"data": [],
|
||||
"has_more": false,
|
||||
"total_count": 0,
|
||||
"url": "/v1/charges/ch_3M1ZOz2sOmf47Nz90wkd0Upl/refunds"
|
||||
},
|
||||
"review": null,
|
||||
"shipping": null,
|
||||
"source": null,
|
||||
"source_transfer": null,
|
||||
"statement_descriptor": null,
|
||||
"statement_descriptor_suffix": null,
|
||||
"status": "succeeded",
|
||||
"transfer_data": null,
|
||||
"transfer_group": null
|
||||
}
|
||||
],
|
||||
"has_more": false,
|
||||
"total_count": 1,
|
||||
"url": "/v1/charges?payment_intent=pi_3M1ZOz2sOmf47Nz90tK9gllB"
|
||||
},
|
||||
"client_secret": "pi_3M1ZOz2sOmf47Nz90tK9gllB_secret_8DSGuKQHUpisoFx6hdLYsPtTy",
|
||||
"confirmation_method": "manual",
|
||||
"created": 1667843189,
|
||||
"currency": "usd",
|
||||
"customer": "cus_IhIynmoJbzLpwX",
|
||||
"description": null,
|
||||
"invoice": null,
|
||||
"last_payment_error": null,
|
||||
"livemode": false,
|
||||
"metadata": {},
|
||||
"next_action": null,
|
||||
"on_behalf_of": null,
|
||||
"payment_method": "pm_1M1ZOy2sOmf47Nz9S0LQW3tB",
|
||||
"payment_method_options": {
|
||||
"card": {
|
||||
"installments": null,
|
||||
"mandate_options": null,
|
||||
"network": null,
|
||||
"request_three_d_secure": "automatic"
|
||||
}
|
||||
},
|
||||
"payment_method_types": [
|
||||
"card"
|
||||
],
|
||||
"processing": null,
|
||||
"receipt_email": null,
|
||||
"review": null,
|
||||
"setup_future_usage": null,
|
||||
"shipping": null,
|
||||
"source": null,
|
||||
"statement_descriptor": null,
|
||||
"statement_descriptor_suffix": null,
|
||||
"status": "succeeded",
|
||||
"transfer_data": null,
|
||||
"transfer_group": null
|
||||
}
|
||||
recorded_at: Mon, 07 Nov 2022 17:46:31 GMT
|
||||
recorded_with: VCR 6.0.0
|
Loading…
Reference in New Issue
Block a user