Do not send attributes for card fields when no card is supplied

This commit is contained in:
Rohan Mitchell
2014-06-04 16:30:57 +10:00
parent 37c780ed70
commit 6a8def3d76
2 changed files with 15 additions and 9 deletions

View File

@@ -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