mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-28 09:24:24 +01:00
fix test on paymentSchedules
This commit is contained in:
parent
315e899540
commit
3349cc3a2d
@ -97,7 +97,7 @@ class API::StripeController < API::PaymentsController
|
||||
|
||||
cart = shopping_cart
|
||||
if subscription&.status == 'active'
|
||||
res = on_payment_success(subscription.latest_invoice.payment_intent, cart)
|
||||
res = on_payment_success(subscription, cart)
|
||||
render generate_payment_response(subscription.latest_invoice.payment_intent, 'subscription', res)
|
||||
else
|
||||
render generate_payment_response(subscription.latest_invoice.payment_intent, 'subscription', nil, subscription.id)
|
||||
|
@ -130,7 +130,7 @@ class Invoice < PaymentDocument
|
||||
return true if user.nil?
|
||||
|
||||
# workaround for reservation saved after invoice
|
||||
if main_item.object_type == 'Reservation' && main_item.object&.reservable_type == 'Training'
|
||||
if main_item&.object_type == 'Reservation' && main_item&.object&.reservable_type == 'Training'
|
||||
user.trainings.include?(main_item.object.reservable_id)
|
||||
else
|
||||
false
|
||||
|
@ -50,20 +50,16 @@ class Stripe::Service < Payment::Service
|
||||
stp_subscription
|
||||
end
|
||||
|
||||
def create_subscription(payment_schedule, payment_intent_id)
|
||||
def create_subscription(payment_schedule, stp_subscription_id)
|
||||
stripe_key = Setting.get('stripe_secret_key')
|
||||
|
||||
pi = Stripe::PaymentIntent.retrieve({ id: payment_intent_id, expand: %w[invoice] }, { api_key: stripe_key })
|
||||
stp_subscription = Stripe::Subscription.retrieve(pi.invoice.subscription, api_key: stripe_key)
|
||||
pgo = PaymentGatewayObject.new(item: payment_schedule)
|
||||
pgo.gateway_object = stp_subscription
|
||||
pgo.save!
|
||||
stp_subscription = Stripe::Subscription.retrieve({ id: stp_subscription_id }, { api_key: stripe_key })
|
||||
|
||||
payment_method_id = stp_subscription.default_payment_method
|
||||
payment_method = Stripe::PaymentMethod.retrieve(payment_method_id, api_key: stripe_key)
|
||||
pgo2 = PaymentGatewayObject.new(item: payment_schedule)
|
||||
pgo2.gateway_object = payment_method
|
||||
pgo2.save!
|
||||
pgo = PaymentGatewayObject.new(item: payment_schedule)
|
||||
pgo.gateway_object = payment_method
|
||||
pgo.save!
|
||||
end
|
||||
|
||||
def extend_subscription(payment_schedule, payment_method_id)
|
||||
|
@ -818,7 +818,8 @@ class Reservations::CreateTest < ActionDispatch::IntegrationTest
|
||||
}
|
||||
],
|
||||
payment_schedule: true,
|
||||
payment_method: 'cart'
|
||||
payment_method: 'card',
|
||||
coupon_code: 'GIME3EUR'
|
||||
}
|
||||
}.to_json, headers: default_headers
|
||||
|
||||
@ -831,9 +832,6 @@ class Reservations::CreateTest < ActionDispatch::IntegrationTest
|
||||
assert_not_nil res[:id]
|
||||
end
|
||||
|
||||
# Check response format & status
|
||||
assert_equal 201, response.status, response.body
|
||||
assert_equal Mime[:json], response.content_type
|
||||
assert_equal reservations_count + 1, Reservation.count, 'missing the reservation'
|
||||
assert_equal invoice_count, Invoice.count, "an invoice was generated but it shouldn't"
|
||||
assert_equal invoice_items_count, InvoiceItem.count, "some invoice items were generated but they shouldn't"
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user