Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EP-2261: BCO Premium Selection #927

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ The `<branded-checkout>` element is where the branded checkout Angular app will
- `designation-number` - the designation number you would like donors to give to - **Required**
- `campaign-page` - the campaign page you would like to use, used for suggested amounts - *Optional*
- `campaign-code` - the campaign code you would like to use - *Optional*
- `premium-code` - the premium code you would like to use - *Optional* - make sure you use the proper premium code associated with the campaign
- `premium-name` - the name of the premium offered to donors - *Optional*
- `premium-image-url` - the custom image to appear when selecting a premium - *Optional*
caleballdrin marked this conversation as resolved.
Show resolved Hide resolved
- `tsys-device` - the device name that corresponds to the TSYS Merchant Account which will be used for tokenizing your site's credit cards with TSYS - **Required** - Will be provided by DPS when adding your domain to the TSYS whitelist. `cru` is the default and corresponds with Cru's main TSYS Merchant ID
- `amount` - defaults the gift's amount - *Optional*
- `frequency` - defaults the gift's frequency - *Optional* - can be one of the following values:
Expand Down
6 changes: 6 additions & 0 deletions src/app/branded/branded-checkout.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class BrandedCheckoutController {
console.error(err)
})
this.$translate.use(this.language || 'en')

this.itemConfig = {}
}

formatDonorDetails () {
Expand Down Expand Up @@ -175,6 +177,10 @@ export default angular
apiUrl: '@',
radioStationApiUrl: '@',
radioStationRadius: '@',
premiumCode: '@',
premiumName: '@',
premiumImageUrl: '@',
itemConfig: '=',
donorDetailsVariable: '@donorDetails',
defaultPaymentType: '@',
hidePaymentTypeOptions: '@',
Expand Down
10 changes: 8 additions & 2 deletions src/app/branded/branded-checkout.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@
next="$ctrl.next()"
on-payment-failed="$ctrl.onPaymentFailed($event.donorDetails)"
radio-station-api-url="$ctrl.radioStationApiUrl"
radio-station-radius="$ctrl.radioStationRadius">
radio-station-radius="$ctrl.radioStationRadius"
premium-code="$ctrl.premiumCode"
premium-name="$ctrl.premiumName"
premium-image-url="$ctrl.premiumImageUrl"
item-config="$ctrl.itemConfig">
wrandall22 marked this conversation as resolved.
Show resolved Hide resolved
</branded-checkout-step-1>
<branded-checkout-step-2
ng-if="$ctrl.checkoutStep === 'review'"
next="$ctrl.next()"
previous="$ctrl.previous(newStep)">
previous="$ctrl.previous(newStep)"
premium-name="$ctrl.premiumName"
item-config="$ctrl.itemConfig">
</branded-checkout-step-2>
<thank-you-summary
ng-if="$ctrl.checkoutStep === 'thankYou'"
Expand Down
23 changes: 22 additions & 1 deletion src/app/branded/step-1/branded-checkout-step-1.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class BrandedCheckoutStep1Controller {
}

initItemConfig () {
this.defaultItemConfig = angular.copy(this.itemConfig)
wrandall22 marked this conversation as resolved.
Show resolved Hide resolved

this.itemConfig = {}
this.itemConfig.CAMPAIGN_CODE = this.campaignCode
if (this.itemConfig.CAMPAIGN_CODE &&
Expand Down Expand Up @@ -60,6 +62,13 @@ class BrandedCheckoutStep1Controller {
}
this.itemConfig.RECURRING_DAY_OF_MONTH = this.day
this.itemConfig.frequency = this.frequency

this.premiumSelected = false

if (this.defaultItemConfig && this.defaultItemConfig.PREMIUM_CODE) {
this.itemConfig.PREMIUM_CODE = this.defaultItemConfig.PREMIUM_CODE
this.premiumSelected = true
}
}

initCart () {
Expand Down Expand Up @@ -151,6 +160,14 @@ class BrandedCheckoutStep1Controller {
}
}

onSelectPremiumOption () {
if (this.premiumSelected) {
this.itemConfig.PREMIUM_CODE = this.premiumCode
} else {
this.itemConfig.PREMIUM_CODE = undefined
}
}

checkSuccessfulSubmission () {
if (every(this.submission, 'completed')) {
if (every(this.submission, { error: false })) {
Expand Down Expand Up @@ -188,6 +205,10 @@ export default angular
next: '&',
onPaymentFailed: '&',
radioStationApiUrl: '<',
radioStationRadius: '<'
radioStationRadius: '<',
premiumCode: '<',
premiumName: '<',
premiumImageUrl: '<',
itemConfig: '='
}
})
29 changes: 29 additions & 0 deletions src/app/branded/step-1/branded-checkout-step-1.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ describe('branded checkout step 1', () => {
$ctrl.initItemConfig()
expect($ctrl.itemConfig.CAMPAIGN_CODE).toEqual('')
})

it('should persist premium-code in item config', () => {
$ctrl.itemConfig = { PREMIUM_CODE: '112233' }
$ctrl.initItemConfig()
expect($ctrl.itemConfig.PREMIUM_CODE).toEqual('112233')
})
})

describe('initCart', () => {
Expand Down Expand Up @@ -277,6 +283,29 @@ describe('branded checkout step 1', () => {
})
})

describe('onSelectPremiumOption', () => {
beforeEach(() => {
$ctrl.initItemConfig()
$ctrl.premiumCode = '112233'
})

it('premium selected', () => {
$ctrl.premiumSelected = true

$ctrl.onSelectPremiumOption()

expect($ctrl.itemConfig.PREMIUM_CODE).toEqual($ctrl.premiumCode)
})

it('premium deselected', () => {
$ctrl.premiumSelected = false

$ctrl.onSelectPremiumOption()

expect($ctrl.itemConfig.PREMIUM_CODE).toEqual(undefined)
})
})

describe('checkSuccessfulSubmission', () => {
beforeEach(() => {
$ctrl.resetSubmission()
Expand Down
34 changes: 34 additions & 0 deletions src/app/branded/step-1/branded-checkout-step-1.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,40 @@ <h3 class="panel-name" translate>{{'PAYMENT'}}</h3>
</checkout-step-2>
</div>
</div>
<div class="panel" ng-if="$ctrl.premiumCode">
<div class="panel-body">
<h3 class="panel-name" translate>{{'CHOOSE_RESOURCE'}}</h3>
<div class="row">
caleballdrin marked this conversation as resolved.
Show resolved Hide resolved
<div class="col-sm-3">
<div class="row">
<label class="radio-inline">
caleballdrin marked this conversation as resolved.
Show resolved Hide resolved
<input
type="radio"
name="premiumSelect"
ng-model="$ctrl.premiumSelected"
ng-value="true"
ng-change="$ctrl.onSelectPremiumOption()">
{{$ctrl.premiumName}}
</label>
</div>
<div class="row">
<label class="radio-inline">
<input
type="radio"
name="premiumSelect"
ng-model="$ctrl.premiumSelected"
ng-value="false"
ng-change="$ctrl.onSelectPremiumOption()">
<translate>{{'NO_THANK_YOU'}}</translate>
</label>
</div>
</div>
<div class="col-sm-4">
<img class="premium-thumbnail" ng-src="{{$ctrl.premiumImageUrl}}" />
caleballdrin marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>
</div>
</div>
<div class="panel">
<div class="panel-body text-right">
<button class="btn btn-primary"
Expand Down
4 changes: 3 additions & 1 deletion src/app/branded/step-2/branded-checkout-step-2.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export default angular
templateUrl: template,
bindings: {
previous: '&',
next: '&'
next: '&',
premiumName: '<',
itemConfig: '<'
}
})
4 changes: 3 additions & 1 deletion src/app/branded/step-2/branded-checkout-step-2.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ <h3 class="panel-name" translate>{{'REVIEW'}}</h3>
<checkout-step-3
cart-data="$ctrl.cartData"
change-step="$ctrl.changeStep(newStep)"
radio-station-name="$ctrl.radioStationName">
radio-station-name="$ctrl.radioStationName"
premium-name="$ctrl.premiumName"
branded-checkout-item="$ctrl.itemConfig">
</checkout-step-3>
</div>
</div>
4 changes: 3 additions & 1 deletion src/app/checkout/step-3/step-3.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ export default angular
onSubmitted: '&',
onSubmittingOrder: '&',
submittingOrder: '<',
radioStationName: '<'
radioStationName: '<',
premiumName: '<',
brandedCheckoutItem: '<'
}
})
16 changes: 16 additions & 0 deletions src/app/checkout/step-3/step-3.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,22 @@
</div>
</div>

<div class="mb" ng-if="!!$ctrl.brandedCheckoutItem['premium-code']">
<div class="panel panel-default">
<div class="panel-heading">
<translate>{{'CHOOSE_RESOURCE'}}</translate>
<button id="changePremiumButton" class="btn btn-default btn-panel-head pull-right" ng-click="$ctrl.changeStep({newStep: 'premium'})" translate>{{'CHANGE'}}</button>
caleballdrin marked this conversation as resolved.
Show resolved Hide resolved
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
{{$ctrl.premiumName}}
</div>
</div>
</div>
</div>
</div>

<div class="mb">
<div class="panel panel-default">
<div id="step3-header" class="panel-heading">
Expand Down
4 changes: 4 additions & 0 deletions src/assets/scss/_checkout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,7 @@
.cover-fees-text {
margin-left: 5px;
}

.premium-thumbnail {
width: 200px;
}
4 changes: 4 additions & 0 deletions src/common/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ export const appConfig = /* @ngInject */ function (envServiceProvider, $compileP
FIRST_GIFT: 'First Gift:',
ANNUAL_GIFT_TOTAL: 'Annual Gift Total:',
FREQUENCY_GIFT_TOTAL: '{{frequency}} Gift Total:',
CHOOSE_RESOURCE: 'Choose a Resource',
NO_THANK_YOU: 'Thank you, but please do not send me the resources.',
RADIO_STATION: 'Radio Station',
RADIO_STATION_LIST_ERROR: 'There was an error loading radio stations in your area.',
RADIO_STATION_SELECT_ERROR: 'There was an error selecting a radio station.',
Expand Down Expand Up @@ -564,6 +566,8 @@ export const appConfig = /* @ngInject */ function (envServiceProvider, $compileP
FIRST_GIFT: 'First Gift:',
ANNUAL_GIFT_TOTAL: 'Annual Gift Total:',
FREQUENCY_GIFT_TOTAL: '{{frequency}} Gift Total:',
CHOOSE_RESOURCE: 'Choose a Resource',
NO_THANK_YOU: 'Thank you, but please do not send me the resources.',
RADIO_STATION: 'Radio Station',
RADIO_STATION_LIST_ERROR: 'There was an error loading radio stations in your area.',
RADIO_STATION_SELECT_ERROR: 'There was an error selecting a radio station.',
Expand Down
Loading