Skip to content

Commit

Permalink
Include branded in HCF eligibility check
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethmv committed Oct 12, 2023
1 parent e628f02 commit 37358d0
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/zoid/card-fields/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,10 @@ export const getCardFieldsComponent: () => CardFieldsComponent = memoize(

eligible: () => {
const fundingEligibility = getRefinedFundingEligibility();
if (fundingEligibility?.card?.eligible) {
if (
fundingEligibility?.card?.eligible &&
!fundingEligibility.card.branded
) {
return {
eligible: true,
};
Expand Down
55 changes: 55 additions & 0 deletions test/integration/tests/card-fields/eligibility.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* @flow */

import { FUNDING } from "@paypal/sdk-constants/src";

import {
createTestContainer,
destroyTestContainer,
mockProp,
assert,
} from "../common";

describe.only(`paypal card fields component`, () => {
beforeEach(() => {
createTestContainer();
});

afterEach(() => {
destroyTestContainer();
});

it(`should not be eligible or render when branded is true`, (done) => {
const fundingSource = FUNDING.CARD;
mockProp(window.__TEST_FUNDING_ELIGIBILITY__, fundingSource, {
eligible: true,
branded: true,
});

const cardButton = window.paypal.Buttons({
fundingSource,
});

const cardFields = window.paypal.CardFields({});

assert.equal(cardFields.isEligible(), false);
done();
});

it(`should be eligible when branded is false`, (done) => {
const fundingSource = FUNDING.CARD;
mockProp(window.__TEST_FUNDING_ELIGIBILITY__, fundingSource, {
eligible: true,
branded: false,
});
window.__COMPONENTS__ = ["buttons", "card-fields"];

const cardButton = window.paypal.Buttons({
fundingSource,
});

const cardFields = window.paypal.CardFields({});

assert.equal(cardFields.isEligible(), true);
done();
});
});
3 changes: 3 additions & 0 deletions test/integration/tests/card-fields/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* @flow */

import "./eligibility";
1 change: 1 addition & 0 deletions test/integration/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ import "./security";
import "./funding/paylater";
import "./funding/applepay";
import "./funding/venmo";
import "./card-fields";
5 changes: 5 additions & 0 deletions test/paypal.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as paypalWallet from "../src/interface/wallet"; // eslint-disable-line
import * as paypalMarks from "../src/interface/marks"; // eslint-disable-line import/no-namespace
import * as paypalFields from "../src/interface/fields"; // eslint-disable-line import/no-namespace
import * as paypalPaymentFields from "../src/interface/payment-fields"; // eslint-disable-line import/no-namespace
import * as paypalCardFields from "../src/interface/card-fields"; // eslint-disable-line import/no-namespace

// the enable-funding=venmo flag is temporarily needed for the venmo experiment
// the enable-funding=applepay flag is needed for applepay vertical stack and standalone buttons to render
Expand Down Expand Up @@ -34,4 +35,8 @@ setupSDK([
name: "paypal-fields",
requirer: () => ({ ...paypalFields, ...paypalPaymentFields }),
},
{
name: "paypal-card-fields",
requirer: () => paypalCardFields,
},
]);

0 comments on commit 37358d0

Please sign in to comment.