mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-31 21:37:16 +00:00
Do not send attributes for card fields when no card is supplied
This commit is contained in:
@@ -32,15 +32,16 @@ Darkswarm.factory 'Order', ($resource, order, $http, CheckoutFormState, flash, N
|
||||
if CheckoutFormState.ship_address_same_as_billing
|
||||
munged_order.ship_address_attributes = munged_order.bill_address_attributes
|
||||
|
||||
angular.extend munged_order.payments_attributes[0], {
|
||||
source_attributes:
|
||||
number: @secrets.card_number
|
||||
month: @secrets.card_month
|
||||
year: @secrets.card_year
|
||||
verification_value: @secrets.card_verification_value
|
||||
first_name: @order.bill_address.firstname
|
||||
last_name: @order.bill_address.lastname
|
||||
}
|
||||
if @secrets.card_number?.length > 0
|
||||
angular.extend munged_order.payments_attributes[0], {
|
||||
source_attributes:
|
||||
number: @secrets.card_number
|
||||
month: @secrets.card_month
|
||||
year: @secrets.card_year
|
||||
verification_value: @secrets.card_verification_value
|
||||
first_name: @order.bill_address.firstname
|
||||
last_name: @order.bill_address.lastname
|
||||
}
|
||||
|
||||
munged_order
|
||||
|
||||
|
||||
@@ -110,3 +110,8 @@ describe 'Order service', ->
|
||||
expect(source_attributes.verification_value).toBe Order.secrets.card_verification_value
|
||||
expect(source_attributes.first_name).toBe Order.order.bill_address.firstname
|
||||
expect(source_attributes.last_name).toBe Order.order.bill_address.lastname
|
||||
|
||||
it "does not create attributes for card fields when no card is supplied", ->
|
||||
Order.secrets.card_number = ''
|
||||
source_attributes = Order.preprocess().payments_attributes[0].source_attributes
|
||||
expect(source_attributes).not.toBeDefined()
|
||||
|
||||
Reference in New Issue
Block a user