|
@@ -17,6 +17,10 @@ define(['../base', '../directives/creditCards'], App =>
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $scope.ui = {
|
|
|
|
|
+ addCompanyDetails: false
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$scope.recurlyLoadError = false
|
|
$scope.recurlyLoadError = false
|
|
|
$scope.currencyCode = MultiCurrencyPricing.currencyCode
|
|
$scope.currencyCode = MultiCurrencyPricing.currencyCode
|
|
|
$scope.allCurrencies = MultiCurrencyPricing.plans
|
|
$scope.allCurrencies = MultiCurrencyPricing.plans
|
|
@@ -58,6 +62,8 @@ define(['../base', '../directives/creditCards'], App =>
|
|
|
address2: '',
|
|
address2: '',
|
|
|
state: '',
|
|
state: '',
|
|
|
city: '',
|
|
city: '',
|
|
|
|
|
+ company: '',
|
|
|
|
|
+ vat_number: '',
|
|
|
country: window.countryCode,
|
|
country: window.countryCode,
|
|
|
coupon: window.couponCode
|
|
coupon: window.couponCode
|
|
|
}
|
|
}
|
|
@@ -99,7 +105,9 @@ define(['../base', '../directives/creditCards'], App =>
|
|
|
|
|
|
|
|
pricing
|
|
pricing
|
|
|
.plan(window.plan_code, { quantity: 1 })
|
|
.plan(window.plan_code, { quantity: 1 })
|
|
|
- .address({ country: $scope.data.country })
|
|
|
|
|
|
|
+ .address({
|
|
|
|
|
+ country: $scope.data.country
|
|
|
|
|
+ })
|
|
|
.tax({ tax_code: 'digital', vat_number: '' })
|
|
.tax({ tax_code: 'digital', vat_number: '' })
|
|
|
.currency($scope.currencyCode)
|
|
.currency($scope.currencyCode)
|
|
|
.coupon($scope.data.coupon)
|
|
.coupon($scope.data.coupon)
|
|
@@ -219,7 +227,6 @@ define(['../base', '../directives/creditCards'], App =>
|
|
|
coupon_code: pricing.items.coupon ? pricing.items.coupon.code : '',
|
|
coupon_code: pricing.items.coupon ? pricing.items.coupon.code : '',
|
|
|
first_name: $scope.data.first_name,
|
|
first_name: $scope.data.first_name,
|
|
|
last_name: $scope.data.last_name,
|
|
last_name: $scope.data.last_name,
|
|
|
-
|
|
|
|
|
isPaypal: $scope.paymentMethod.value === 'paypal',
|
|
isPaypal: $scope.paymentMethod.value === 'paypal',
|
|
|
address: {
|
|
address: {
|
|
|
address1: $scope.data.address1,
|
|
address1: $scope.data.address1,
|
|
@@ -233,6 +240,21 @@ define(['../base', '../directives/creditCards'], App =>
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ postData.subscriptionDetails.isPaypal &&
|
|
|
|
|
+ $scope.ui.addCompanyDetails
|
|
|
|
|
+ ) {
|
|
|
|
|
+ postData.subscriptionDetails.billing_info = {}
|
|
|
|
|
+ if ($scope.data.company && $scope.data.company !== '') {
|
|
|
|
|
+ postData.subscriptionDetails.billing_info.company =
|
|
|
|
|
+ $scope.data.company
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($scope.data.vat_number && $scope.data.vat_number !== '') {
|
|
|
|
|
+ postData.subscriptionDetails.billing_info.vat_number =
|
|
|
|
|
+ $scope.data.vat_number
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
eventTracking.sendMB('subscription-form-submitted', {
|
|
eventTracking.sendMB('subscription-form-submitted', {
|
|
|
currencyCode: postData.subscriptionDetails.currencyCode,
|
|
currencyCode: postData.subscriptionDetails.currencyCode,
|
|
|
plan_code: postData.subscriptionDetails.plan_code,
|
|
plan_code: postData.subscriptionDetails.plan_code,
|
|
@@ -244,7 +266,6 @@ define(['../base', '../directives/creditCards'], App =>
|
|
|
'subscription-form-submitted',
|
|
'subscription-form-submitted',
|
|
|
postData.subscriptionDetails.plan_code
|
|
postData.subscriptionDetails.plan_code
|
|
|
)
|
|
)
|
|
|
-
|
|
|
|
|
return $http
|
|
return $http
|
|
|
.post('/user/subscription/create', postData)
|
|
.post('/user/subscription/create', postData)
|
|
|
.then(function() {
|
|
.then(function() {
|
|
@@ -274,9 +295,14 @@ define(['../base', '../directives/creditCards'], App =>
|
|
|
$scope.processing = true
|
|
$scope.processing = true
|
|
|
if ($scope.paymentMethod.value === 'paypal') {
|
|
if ($scope.paymentMethod.value === 'paypal') {
|
|
|
const opts = { description: $scope.planName }
|
|
const opts = { description: $scope.planName }
|
|
|
- return recurly.paypal(opts, completeSubscription)
|
|
|
|
|
|
|
+ recurly.paypal(opts, completeSubscription)
|
|
|
} else {
|
|
} else {
|
|
|
- return recurly.token($scope.data, completeSubscription)
|
|
|
|
|
|
|
+ const tokenData = _.cloneDeep($scope.data)
|
|
|
|
|
+ if (!$scope.ui.addCompanyDetails) {
|
|
|
|
|
+ delete tokenData.company
|
|
|
|
|
+ delete tokenData.vat_number
|
|
|
|
|
+ }
|
|
|
|
|
+ recurly.token(tokenData, completeSubscription)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|