Skip to content

Commit

Permalink
feature(venmo): add venmoEnableOnNonNativeBrowser experiment (#2468)
Browse files Browse the repository at this point in the history
* feature(venmo): add venmoEnableOnNonNativeBrowser experiment

* chore(refactor): naming

* chore(refactor): check native elig through config

* fix(venmo): elig test

* fix(venmo): elig test

* chore(refactor): revert experiment logic

* chore(refactor): fix test

* chore(refactor): fix test
  • Loading branch information
mnicpt authored Jan 29, 2025
1 parent 76df556 commit e14fc3e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
18 changes: 10 additions & 8 deletions src/funding/venmo/config.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@ export function getVenmoConfig(): FundingSourceConfig {

eligible: ({ experiment, shippingChange, displayOnly, flow }) => {
/**
* This could probably be removed if the enableVenmo experiment is
* rolled out to 100%.
* enableVenmo checks native browser compatibility and ramp
* ignore above compatibility if forcing to web
*/
if (experiment && experiment.enableVenmo === false) {
if (
experiment &&
experiment.enableVenmo === false &&
experiment.venmoWebEnabled !== true &&
experiment.venmoEnableWebOnNonNativeBrowser !== true
) {
return false;
}

/**
* Shipping callbacks will not work with Venmo unless venmo web is enabled.
*
* Note that this could cause the Venmo button to not show up on first render
* if a merchant passes a shipping callback but does not have a client ID
* that has Venmo Web enabled.
*/
if (!experiment?.venmoWebEnabled && shippingChange) {
return false;
Expand All @@ -62,7 +63,8 @@ export function getVenmoConfig(): FundingSourceConfig {
if (
platform === PLATFORM.MOBILE &&
experiment &&
experiment.venmoWebEnabled === false
experiment.venmoWebEnabled !== true &&
experiment.venmoEnableWebOnNonNativeBrowser !== true
) {
return {
native: true,
Expand Down
5 changes: 3 additions & 2 deletions src/funding/venmo/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe("Venmo eligibility", () => {
fundingEligibility: {},
experiment: {
venmoWebEnabled: true,
venmoEnableWebOnNonNativeBrowser: true,
},
wallet: expect.any,
flow: BUTTON_FLOW.PURCHASE,
Expand Down Expand Up @@ -74,7 +75,7 @@ describe("Venmo eligibility", () => {
expect(isVenmoEligible).toEqual(true);
});

test("should not be eligible if a shipping callback is passed & experiment does not include venmoWebEnabled", () => {
test("should not be eligible if a shipping callback is passed & experiment does not include venmoWebEnabled or venmoEnableWebOnNonNativeBrowser", () => {
const isVenmoEligible = venmoConfig.eligible?.({
...baseEligibilityProps,
experiment: {},
Expand All @@ -84,7 +85,7 @@ describe("Venmo eligibility", () => {
expect(isVenmoEligible).toEqual(false);
});

test("should be eligible if shipping callback exists & experiment includes venmoWebEnabled", () => {
test("should be eligible if shipping callback exists & experiment includes venmoWebEnabled or venmoEnableWebOnNonNativeBrowser", () => {
const isVenmoEligible = venmoConfig.eligible?.({
...baseEligibilityProps,
shippingChange: true,
Expand Down
1 change: 1 addition & 0 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export type Experiment = {|
venmoWebEnabled?: boolean,
// first render experiments
venmoVaultWithoutPurchase?: boolean,
venmoEnableWebOnNonNativeBrowser?: boolean,
|};

export type Requires = {|
Expand Down
6 changes: 6 additions & 0 deletions src/zoid/venmo/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,12 @@ export function getVenmoCheckoutComponent(): VenmoCheckoutComponent {
required: false,
},

venmoEnableWebOnNonNativeBrowser: {
type: "boolean",
queryParam: true,
required: false,
},

venmoVaultEnabled: {
type: "boolean",
queryParam: true,
Expand Down

0 comments on commit e14fc3e

Please sign in to comment.