WIP: Send credit card details to server on checkout

This commit is contained in:
Rohan Mitchell
2014-06-04 16:20:48 +10:00
parent a99e18990d
commit 37c780ed70
7 changed files with 116 additions and 36 deletions

View File

@@ -2,6 +2,7 @@ Darkswarm.controller "CheckoutCtrl", ($scope, storage, CheckoutFormState, Order,
$scope.Order = Order
storage.bind $scope, "Order.order", {storeName: "order_#{Order.order.id}#{Order.order.user_id}"}
$scope.order = Order.order # Ordering is important
$scope.secrets = Order.secrets
$scope.enabled = if CurrentUser then true else false

View File

@@ -1,3 +1,8 @@
Darkswarm.controller "PaymentCtrl", ($scope) ->
angular.extend(this, new FieldsetMixin($scope))
$scope.name = "payment"
$scope.months = {1: "January", 2: "February", 3: "March", 4: "April", 5: "May", 6: "June", 7: "July", 8: "August", 9: "September", 10: "October", 11: "November", 12: "December"}
$scope.years = [moment().year()..(moment().year()+15)]
$scope.secrets.card_month = "1"
$scope.secrets.card_year = moment().year()

View File

@@ -1,6 +1,7 @@
Darkswarm.factory 'Order', ($resource, order, $http, CheckoutFormState, flash, Navigation)->
new class Order
errors: {}
secrets: {}
constructor: ->
@order = order
@@ -30,6 +31,17 @@ 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
}
munged_order
shippingMethod: ->