Skip to content

Commit

Permalink
feat: support PL2GO and the PL Hub in the universal modal (#922)
Browse files Browse the repository at this point in the history
* support pl2go and pl hub

* add to func tests

* update test config files
  • Loading branch information
yeul committed Apr 18, 2023
1 parent b45aa38 commit c438325
Show file tree
Hide file tree
Showing 11 changed files with 424 additions and 5 deletions.
41 changes: 41 additions & 0 deletions content/modals/US/PL2GO/pl2go_long_term.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"meta": {
"product": "PAY_LATER_LONG_TERM",
"offerCountry": "US",
"variables": {
"transaction_amount": "${eval(transaction_amount ? transaction_amount : '-')}",
"qualifying_offer": "${eval(CREDIT_OFFERS_DS.qualifying_offer ? CREDIT_OFFERS_DS.qualifying_offer : 'false')}",
"financing_code": "${CREDIT_OFFERS_DS.financing_code}",
"formattedPeriodicPayment": "${CREDIT_OFFERS_DS.formattedPeriodicPayment}",
"total_payments": "${CREDIT_OFFERS_DS.total_payments}",
"formattedMinAmount": "${CREDIT_OFFERS_DS.formattedMinAmount}",
"formattedMaxAmount": "${CREDIT_OFFERS_DS.formattedMaxAmount}",
"formattedTotalCost": "${CREDIT_OFFERS_DS.formattedTotalCost}",
"minAmount": "${CREDIT_OFFERS_DS.minAmount}",
"maxAmount": "${CREDIT_OFFERS_DS.maxAmount}",
"apr": "${CREDIT_OFFERS_DS.apr}",
"nominal_rate": "${CREDIT_OFFERS_DS.nominal_rate}"
}
},
"content": {
"headline": "Pay Monthly",
"subheadline": "Get more time to pay, with no down payment or late fees.",
"calculator": {
"title": "How much is your purchase?",
"inputLabel": "Purchase amount",
"inputPlaceholder": "Enter amount",
"genericError": "Something went wrong. Please try again later."
},
"genericDisclaimer": "Terms may vary based on purchase amount.",
"instructions": [
"Apply for Pay Monthly. Available for purchases of {formattedMinAmount} to {formattedMaxAmount}.",
"Shop almost anywhere after receiving a single-use virtual card number.",
"Pay back what you spend in monthly installments. $0 due today."
],
"disclosure": [
"Pay Monthly is subject to consumer credit approval. Payments may change based on shipping, taxes, updates to your purchase, or missed payments. Offer availability depends on the merchant and may not be available for subscriptions or recurring payments. Pay Monthly is currently not available to residents of AK, CO, HI, MA, NE, NV, NY, or TX. You must be of legal age in your U.S. state of residence. Missed payments may have an impact on your credit score. The lender for Pay Monthly is WebBank. PayPal, Inc. (NMLS #910457): CT Small Loan Licensee. RI Loan Broker Licensee. VT Loan Solicitation Licensee. VT residents:",
["Find more disclosures ", "https://www.paypal.com/us/digital-wallet/ways-to-pay/buy-now-pay-later"],
"by going to PayPal's page on Pay Later."
]
}
}
39 changes: 39 additions & 0 deletions content/modals/US/PL2GO/pl2go_short_term.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"meta": {
"product": "PAY_LATER_SHORT_TERM",
"periodicPayment": "{formattedPeriodicPayment}",
"minAmount": "{minAmount}",
"maxAmount": "{maxAmount}",
"qualifying": "{qualifying_offer}",
"amount": "{transaction_amount}",
"apr": "{apr}",
"variables": {
"transaction_amount": "${eval(transaction_amount ? transaction_amount : '-')}",
"qualifying_offer": "${eval(CREDIT_OFFERS_DS.qualifying_offer ? CREDIT_OFFERS_DS.qualifying_offer : 'false')}",
"financing_code": "${CREDIT_OFFERS_DS.financing_code}",
"formattedPeriodicPayment": "${CREDIT_OFFERS_DS.formattedPeriodicPayment}",
"total_payments": "${CREDIT_OFFERS_DS.total_payments}",
"formattedMinAmount": "${CREDIT_OFFERS_DS.formattedMinAmount}",
"formattedMaxAmount": "${CREDIT_OFFERS_DS.formattedMaxAmount}",
"formattedTotalCost": "${CREDIT_OFFERS_DS.formattedTotalCost}",
"minAmount": "${CREDIT_OFFERS_DS.minAmount}",
"maxAmount": "${CREDIT_OFFERS_DS.maxAmount}",
"apr": "${CREDIT_OFFERS_DS.apr}",
"nominal_rate": "${CREDIT_OFFERS_DS.nominal_rate}"
}
},
"content": {
"headline": "Pay in 4 interest-free payments",
"subheadline": "No impact on credit score and no late fees. Available for purchases of {formattedMinAmount} to {formattedMaxAmount}.",
"qualifyingSubheadline": "Split your purchase of {formattedTotalCost} into {total_payments} with no impact on credit score and no late fees.",
"donutTimestamps": ["Today", "2 weeks", "4 weeks", "6 weeks"],
"instructions": [
"Apply for Pay in 4. Available for purchases of {formattedMinAmount} to {formattedMaxAmount}. ",
"Shop almost anywhere after receiving a single-use virtual card number.",
"Pay back what you spend in 4 payments, every 2 weeks, starting today."
],
"disclosure": [
"Pay in 4 is available to consumers upon approval for purchases of <span aria-hidden='true'>{formattedMinAmount}-{formattedMaxAmount}</span><span class='sr-only'>{formattedMinAmount} to {formattedMaxAmount}</span>. Pay in 4 is not currently available to residents of Missouri, Nevada, New Mexico, or North Dakota. Offer availability depends on the merchant and also may not be available for certain recurring, subscription services. When applying, a soft credit check may be needed, but will not affect your credit score. You must be of legal age in your U.S. state of residence to use Pay in 4. Loans to California residents are made or arranged pursuant to a California Financing Law License. PayPal, Inc. is a Georgia Installment Lender Licensee, NMLS #910457. Rhode Island Small Loan Lender Licensee."
]
}
}
42 changes: 42 additions & 0 deletions content/modals/US/PLHub/plhub_long_term.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"meta": {
"product": "PAY_LATER_LONG_TERM",
"offerCountry": "US",
"variables": {
"transaction_amount": "${eval(transaction_amount ? transaction_amount : '-')}",
"qualifying_offer": "${eval(CREDIT_OFFERS_DS.qualifying_offer ? CREDIT_OFFERS_DS.qualifying_offer : 'false')}",
"financing_code": "${CREDIT_OFFERS_DS.financing_code}",
"formattedPeriodicPayment": "${CREDIT_OFFERS_DS.formattedPeriodicPayment}",
"total_payments": "${CREDIT_OFFERS_DS.total_payments}",
"formattedMinAmount": "${CREDIT_OFFERS_DS.formattedMinAmount}",
"formattedMaxAmount": "${CREDIT_OFFERS_DS.formattedMaxAmount}",
"formattedTotalCost": "${CREDIT_OFFERS_DS.formattedTotalCost}",
"minAmount": "${CREDIT_OFFERS_DS.minAmount}",
"maxAmount": "${CREDIT_OFFERS_DS.maxAmount}",
"apr": "${CREDIT_OFFERS_DS.apr}",
"nominal_rate": "${CREDIT_OFFERS_DS.nominal_rate}"
}
},
"content": {
"headline": "Pay Monthly",
"subheadline": "Get more time to pay, with no down payment or late fees.",
"calculator": {
"title": "How much is your purchase?",
"inputLabel": "Purchase amount",
"inputPlaceholder": "Enter amount",
"genericError": "Something went wrong. Please try again later."
},
"genericDisclaimer": "Terms may vary based on purchase amount.",
"instructions": [
"Choose PayPal at checkout to pay later with <strong>Pay Monthly</strong>.",
"Get a decision in seconds and complete your purchase.",
"Use autopay for your payments. It's easy!"
],
"disclosure": [
"Pay Monthly is subject to consumer credit approval. Payments may change based on shipping, taxes, updates to your purchase, or missed payments. Offer availability depends on the merchant and may not be available for subscriptions or recurring payments. Pay Monthly is currently not available to residents of AK, CO, HI, MA, NE, NV, NY, or TX. You must be of legal age in your U.S. state of residence. Missed payments may have an impact on your credit score. The lender for Pay Monthly is WebBank. PayPal, Inc. (NMLS #910457): CT Small Loan Licensee. RI Loan Broker Licensee. VT Loan Solicitation Licensee. VT residents:",
["Find more disclosures ", "https://www.paypal.com/us/digital-wallet/ways-to-pay/buy-now-pay-later"],
"by going to PayPal's page on Pay Later."
],
"linkToProductList": "See other ways to pay over time"
}
}
40 changes: 40 additions & 0 deletions content/modals/US/PLHub/plhub_short_term.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"meta": {
"product": "PAY_LATER_SHORT_TERM",
"periodicPayment": "{formattedPeriodicPayment}",
"minAmount": "{minAmount}",
"maxAmount": "{maxAmount}",
"qualifying": "{qualifying_offer}",
"amount": "{transaction_amount}",
"apr": "{apr}",
"variables": {
"transaction_amount": "${eval(transaction_amount ? transaction_amount : '-')}",
"qualifying_offer": "${eval(CREDIT_OFFERS_DS.qualifying_offer ? CREDIT_OFFERS_DS.qualifying_offer : 'false')}",
"financing_code": "${CREDIT_OFFERS_DS.financing_code}",
"formattedPeriodicPayment": "${CREDIT_OFFERS_DS.formattedPeriodicPayment}",
"total_payments": "${CREDIT_OFFERS_DS.total_payments}",
"formattedMinAmount": "${CREDIT_OFFERS_DS.formattedMinAmount}",
"formattedMaxAmount": "${CREDIT_OFFERS_DS.formattedMaxAmount}",
"formattedTotalCost": "${CREDIT_OFFERS_DS.formattedTotalCost}",
"minAmount": "${CREDIT_OFFERS_DS.minAmount}",
"maxAmount": "${CREDIT_OFFERS_DS.maxAmount}",
"apr": "${CREDIT_OFFERS_DS.apr}",
"nominal_rate": "${CREDIT_OFFERS_DS.nominal_rate}"
}
},
"content": {
"headline": "Pay in 4 interest-free payments",
"subheadline": "No impact on credit score and no late fees. Available for purchases of {formattedMinAmount} to {formattedMaxAmount}.",
"qualifyingSubheadline": "Split your purchase of {formattedTotalCost} into {total_payments} with no impact on credit score and no late fees.",
"donutTimestamps": ["Today", "2 weeks", "4 weeks", "6 weeks"],
"instructions": [
"Choose PayPal at checkout to pay later with <strong>Pay in 4</strong>. ",
"Complete your purchase with a 25% down payment.",
"Use autopay for the rest of your payments. It's easy!"
],
"disclosure": [
"Pay in 4 is available to consumers upon approval for purchases of <span aria-hidden='true'>{formattedMinAmount}-{formattedMaxAmount}</span><span class='sr-only'>{formattedMinAmount} to {formattedMaxAmount}</span>. Pay in 4 is not currently available to residents of Missouri, Nevada, New Mexico, or North Dakota. Offer availability depends on the merchant and also may not be available for certain recurring, subscription services. When applying, a soft credit check may be needed, but will not affect your credit score. You must be of legal age in your U.S. state of residence to use Pay in 4. Loans to California residents are made or arranged pursuant to a California Financing Law License. PayPal, Inc. is a Georgia Installment Lender Licensee, NMLS #910457. Rhode Island Small Loan Lender Licensee."
],
"linkToProductList": "See other ways to pay later"
}
}
6 changes: 5 additions & 1 deletion src/components/modal/v2/parts/BodyContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ const BodyContent = () => {
}

let defaultViewName;

const productViews = views.filter(view => view?.meta?.product !== 'PRODUCT_LIST');
const hasProductList = views.find(view => view?.meta?.product === 'PRODUCT_LIST');
if (productViews?.length === 1) {
defaultViewName = productViews[0]?.meta?.product;
} else if (productViews?.length > 1) {
} else if (productViews?.length > 1 && hasProductList) {
defaultViewName = 'PRODUCT_LIST';
} else if (productViews?.length > 1 && !hasProductList) {
defaultViewName = productViews[0]?.meta?.product;
}

return defaultViewName;
Expand Down
3 changes: 2 additions & 1 deletion src/components/modal/v2/parts/Instructions.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @jsx h */
import { h } from 'preact';
import { currencyFormat } from '../lib';

const Instructions = ({ instructions, expandedState = false, className = '' }) => {
const renderBullet = index => {
Expand All @@ -18,7 +19,7 @@ const Instructions = ({ instructions, expandedState = false, className = '' }) =
<li className="instructions__item-wrapper">
{renderBullet(index + 1)}
{/* eslint-disable-next-line react/no-danger */}
<div dangerouslySetInnerHTML={{ __html: instruction }} />
<div dangerouslySetInnerHTML={{ __html: currencyFormat(instruction) }} />
</li>
);
})}
Expand Down
9 changes: 6 additions & 3 deletions src/library/zoid/message/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,14 @@ export default {
},
channel: ({ props: { channel } }) => {
if (typeof channel !== 'undefined') {
const options = ['UPSTREAM', 'CHECKOUT'];
// Acceptable values include any case-sensitive alphanumeric string with optional underscores.
const acceptedValues = /^[A-Z0-9_]+$/;
if (!validateType(Types.STRING, channel)) {
logInvalidType('channel', Types.STRING, channel);
} else if (!arrayIncludes(options, channel)) {
logInvalidOption('channel', options, channel);
} else if (!acceptedValues.test(channel)) {
// Return undefined if supplied channel value is not an accepted value.
// We do not surface a warning here as we do not want instances where a channel is used in an incorrect context.
return undefined;
} else {
return channel;
}
Expand Down
18 changes: 18 additions & 0 deletions tests/functional/v2/config/US/DEV_US_LONG_TERM_PL2GO.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const DEV_US_LONG_TERM_PL2GO = {
testFileName: 'longTermPL2GO',
country: 'US',
description: 'US merchant showing long term Pay Later to Go content',
minAmount: 199,
maxAmount: 20000,
amounts: [
{
value: '199.00',
modalContent: {
offerHeadline: '$33.17/mo. for 6 months',
updatedOfferHeadline: '$83.33/mo. for 6 months',
offerFieldValues: ['0%', '$0.00', '$199.00'],
aprDisclaimer: 'Terms may vary based on purchase amount.'
}
}
]
};
27 changes: 27 additions & 0 deletions tests/functional/v2/config/US/DEV_US_SHORT_TERM_PL2GO.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export const DEV_US_SHORT_TERM_PL2GO = {
testFileName: 'shortTermPL2GO',
country: 'US',
description: 'US merchant showing short term Pay Later to Go content',
minAmount: 30,
maxAmount: 1500,
amounts: [
{
value: '30.00',
message: 'Qualifying Pay in 4',
expectedValue: 'Pay in 4 interest-free payments of $7.50',
modalContent: {
subheadline: 'Split your purchase of $30.00 into 4 with no impact on credit score and no late fees.',
periodicPayment: '$7.50'
}
},
{
value: '1500.01',
message: 'Non-qualifying Pay in 4',
expectedValue: 'Pay in 4 interest-free payments on qualifying purchases',
modalContent: {
subheadline: 'No impact on credit score and no late fees. Available for purchases of $30 to $1,500.',
periodicPayment: ''
}
}
]
};
2 changes: 2 additions & 0 deletions tests/functional/v2/config/US/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export { DEV_US_LONG_TERM } from './DEV_US_LONG_TERM';
export { DEV_US_LONG_TERM_CHECKOUT } from './DEV_US_LONG_TERM_CHECKOUT';
export { DEV_US_LONG_TERM_PL2GO } from './DEV_US_LONG_TERM_PL2GO';
export { DEV_US_MULTI } from './DEV_US_MULTI';
export { DEV_US_NO_INTEREST } from './DEV_US_NO_INTEREST';
export { DEV_US_SHORT_TERM } from './DEV_US_SHORT_TERM';
export { DEV_US_SHORT_TERM_PL2GO } from './DEV_US_SHORT_TERM_PL2GO';
Loading

0 comments on commit c438325

Please sign in to comment.