Skip to content

Support Venmo vault without purchase with a feature flag #2403

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

Merged
merged 11 commits into from
Jun 12, 2024
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
"readmeFilename": "README.md",
"devDependencies": {
"@bunchtogether/vite-plugin-flow": "^1.0.2",
"@krakenjs/grumbler-scripts": "^8.1.5",
"@krakenjs/eslint-config-grumbler": "8.1.3",
"@krakenjs/grumbler-scripts": "^8.1.5",
"@krakenjs/sync-browser-mocks": "^3.0.0",
"@percy/cli": "1.28.5",
"@percy/playwright": "^1.0.4",
Expand Down
1 change: 1 addition & 0 deletions src/funding/funding.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export function isFundingEligible(
enableFunding,
components,
experiment,
flow,
fundingSource,
fundingEligibility,
layout,
Expand Down
13 changes: 11 additions & 2 deletions src/funding/venmo/config.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "@paypal/sdk-logos/src";
import { DISPLAY_ONLY_VALUES, PLATFORM } from "@paypal/sdk-constants/src";

import { BUTTON_COLOR, BUTTON_LAYOUT } from "../../constants";
import { BUTTON_COLOR, BUTTON_LAYOUT, BUTTON_FLOW } from "../../constants";
import { DEFAULT_FUNDING_CONFIG, type FundingSourceConfig } from "../common";

import { WalletLabel, Label } from "./template";
Expand All @@ -17,9 +17,11 @@ export function getVenmoConfig(): FundingSourceConfig {
return {
...DEFAULT_FUNDING_CONFIG,

flows: [BUTTON_FLOW.PURCHASE, BUTTON_FLOW.VAULT_WITHOUT_PURCHASE],

layouts: [BUTTON_LAYOUT.HORIZONTAL, BUTTON_LAYOUT.VERTICAL],

eligible: ({ experiment, shippingChange, displayOnly }) => {
eligible: ({ experiment, shippingChange, displayOnly, flow }) => {
if (experiment && experiment.enableVenmo === false) {
return false;
}
Expand All @@ -39,6 +41,13 @@ export function getVenmoConfig(): FundingSourceConfig {
return false;
}

if (
flow === BUTTON_FLOW.VAULT_WITHOUT_PURCHASE &&
experiment?.venmoVaultWithoutPurchase !== true
) {
return false;
}

return true;
},

Expand Down
23 changes: 23 additions & 0 deletions src/funding/venmo/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import { describe, expect } from "vitest";

import { BUTTON_FLOW } from "../../constants";

import { getVenmoConfig } from "./config";

describe("Venmo eligibility", () => {
Expand Down Expand Up @@ -46,4 +48,25 @@ describe("Venmo eligibility", () => {

expect(isVenmoEligible).toEqual(true);
});

test("should not be eligible if flow is VAULT_WITHOUT_PURCHASE and venmoVaultWithoutPurchase is false", () => {
const isVenmoEligible = venmoConfig.eligible?.({
...baseEligibilityProps,
flow: BUTTON_FLOW.VAULT_WITHOUT_PURCHASE,
});

expect(isVenmoEligible).toEqual(false);
});

test("should be eligible if flow is VAULT_WITHOUT_PURCHASE and venmoVaultWithoutPurchase is true", () => {
const isVenmoEligible = venmoConfig.eligible?.({
...baseEligibilityProps,
flow: BUTTON_FLOW.VAULT_WITHOUT_PURCHASE,
experiment: {
venmoVaultWithoutPurchase: true,
},
});

expect(isVenmoEligible).toEqual(true);
});
});
12 changes: 7 additions & 5 deletions src/zoid/buttons/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
getVersion,
getDisableSetCookie,
getExperimentation,
getFirstRenderExperiments,
getSDKAttribute,
getJsSdkLibrary,
} from "@paypal/sdk-client/src";
Expand Down Expand Up @@ -472,12 +473,13 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
experiment: {
type: "object",
queryParam: true,
value: () => {
const experiments = getButtonExperiments();
return experiments;
},
value: () => ({
...getButtonExperiments(),
...getFirstRenderExperiments(),
}),
},

// TODO first-render-experiment-cleanup
// verify if this is needed/used now that were putting the first render experiments in experiment param above
experimentation: {
type: "object",
queryParam: true,
Expand Down
Loading