Skip to content

Commit

Permalink
Change to PREMIUM_CODE
Browse files Browse the repository at this point in the history
  • Loading branch information
caleballdrin committed Nov 13, 2024
1 parent 53eb864 commit 9a1fc94
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ The `<branded-checkout>` element is where the branded checkout Angular app will
- `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*
- `premium-name` - the name of the premium offered to donors - *Optional*
- `premium-image-url` - the custom image to appear when selecting a premium - *Optional*
- `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
1 change: 1 addition & 0 deletions src/app/branded/branded-checkout.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export default angular
premiumCode: '@',
premiumName: '@',
premiumImageUrl: '@',
itemConfig: '=',
donorDetailsVariable: '@donorDetails',
defaultPaymentType: '@',
hidePaymentTypeOptions: '@',
Expand Down
12 changes: 6 additions & 6 deletions src/app/branded/step-1/branded-checkout-step-1.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BrandedCheckoutStep1Controller {
(this.itemConfig.CAMPAIGN_CODE.match(/^[a-z0-9]+$/i) === null || this.itemConfig.CAMPAIGN_CODE.length > 30)) {
this.itemConfig.CAMPAIGN_CODE = ''
}
this.itemConfig['campaign-page'] = this.campaignPage
this.itemConfig.CAMPAIGN_PAGE = this.campaignPage
this.itemConfig.AMOUNT = this.amount

// These lines calculate the price with fees for amounts coming in from the client site via component config
Expand All @@ -65,8 +65,8 @@ class BrandedCheckoutStep1Controller {

this.premiumSelected = false

if (this.defaultItemConfig && this.defaultItemConfig['premium-code']) {
this.itemConfig['premium-code'] = this.defaultItemConfig['premium-code']
if (this.defaultItemConfig && this.defaultItemConfig.PREMIUM_CODE) {
this.itemConfig.PREMIUM_CODE = this.defaultItemConfig.PREMIUM_CODE
this.premiumSelected = true
}
}
Expand All @@ -84,7 +84,7 @@ class BrandedCheckoutStep1Controller {
this.itemConfig = item.config

// add campaign page
this.itemConfig['campaign-page'] = this.campaignPage
this.itemConfig.CAMPAIGN_PAGE = this.campaignPage
}
this.loadingProductConfig = false
},
Expand Down Expand Up @@ -162,9 +162,9 @@ class BrandedCheckoutStep1Controller {

onSelectPremiumOption () {
if (this.premiumSelected) {
this.itemConfig['premium-code'] = this.premiumCode
this.itemConfig.PREMIUM_CODE = this.premiumCode
} else {
this.itemConfig['premium-code'] = undefined
this.itemConfig.PREMIUM_CODE = undefined
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/app/branded/step-1/branded-checkout-step-1.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('branded checkout step 1', () => {

expect($ctrl.itemConfig).toEqual({
CAMPAIGN_CODE: '1234',
'campaign-page': '135',
CAMPAIGN_PAGE: '135',
AMOUNT: '75',
priceWithFees: '$76.80',
'RECURRING_DAY_OF_MONTH': '9'
Expand Down Expand Up @@ -86,9 +86,9 @@ describe('branded checkout step 1', () => {
})

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

Expand All @@ -107,7 +107,7 @@ describe('branded checkout step 1', () => {
expect($ctrl.cartService.get).toHaveBeenCalled()
expect($ctrl.isEdit).toEqual(true)
expect($ctrl.item.code).toEqual('1234567')
expect($ctrl.itemConfig['campaign-page']).toEqual('campaign1')
expect($ctrl.itemConfig.CAMPAIGN_PAGE).toEqual('campaign1')
expect($ctrl.loadingProductConfig).toEqual(false)
})

Expand Down Expand Up @@ -294,15 +294,15 @@ describe('branded checkout step 1', () => {

$ctrl.onSelectPremiumOption()

expect($ctrl.itemConfig['premium-code']).toEqual($ctrl.premiumCode)
expect($ctrl.itemConfig.PREMIUM_CODE).toEqual($ctrl.premiumCode)
})

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

$ctrl.onSelectPremiumOption()

expect($ctrl.itemConfig['premium-code']).toEqual(undefined)
expect($ctrl.itemConfig.PREMIUM_CODE).toEqual(undefined)
})
})

Expand Down

0 comments on commit 9a1fc94

Please sign in to comment.