mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-12 03:50:22 +00:00
Add some logic to check whether a saved card has been selected before making a request from Stripe
This commit is contained in:
@@ -5,7 +5,7 @@ Darkswarm.factory 'Checkout', ($injector, CurrentOrder, ShippingMethods, StripeJ
|
||||
order: CurrentOrder.order
|
||||
|
||||
purchase: ->
|
||||
if @paymentMethod()?.method_type == 'stripe'
|
||||
if @paymentMethod()?.method_type == 'stripe' && !@secrets.selected_card
|
||||
StripeJS.requestToken(@secrets, @submit)
|
||||
else
|
||||
@submit()
|
||||
@@ -60,14 +60,21 @@ Darkswarm.factory 'Checkout', ($injector, CurrentOrder, ShippingMethods, StripeJ
|
||||
}
|
||||
|
||||
if @paymentMethod()?.method_type == 'stripe'
|
||||
angular.extend munged_order.payments_attributes[0], {
|
||||
source_attributes:
|
||||
gateway_payment_profile_id: @secrets.token
|
||||
cc_type: @secrets.cc_type
|
||||
last_digits: @secrets.card.last4
|
||||
month: @secrets.card.exp_month
|
||||
year: @secrets.card.exp_year
|
||||
}
|
||||
if @secrets.selected_card
|
||||
angular.extend munged_order.payments_attributes[0], {
|
||||
source_attributes:
|
||||
id: @secrets.selected_card
|
||||
type: 'Spree::CreditCard'
|
||||
}
|
||||
else
|
||||
angular.extend munged_order.payments_attributes[0], {
|
||||
source_attributes:
|
||||
gateway_payment_profile_id: @secrets.token
|
||||
cc_type: @secrets.cc_type
|
||||
last_digits: @secrets.card.last4
|
||||
month: @secrets.card.exp_month
|
||||
year: @secrets.card.exp_year
|
||||
}
|
||||
|
||||
munged_order
|
||||
|
||||
|
||||
Reference in New Issue
Block a user