Skip to content
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

Add transaction fee covered label to new one-time checkout #6719

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import { getSettings, isSwitchOn } from 'helpers/globalsAndSwitches/globals';
import type { AppConfig } from 'helpers/globalsAndSwitches/window';
import type { IsoCountry } from 'helpers/internationalisation/country';
import * as cookie from 'helpers/storage/cookie';
import type { PaymentAPIAcquisitionData } from 'helpers/tracking/acquisitions';
import {
derivePaymentApiAcquisitionData,
getReferrerAcquisitionData,
Expand Down Expand Up @@ -197,6 +198,26 @@ function getFinalAmount(
return roundToDecimalPlaces(selectedPriceCard * transactionMultiplier);
}

function getAcquisitionData(
abParticipations: Participations,
billingPostcode: string,
coverTransactionCost: boolean,
): PaymentAPIAcquisitionData {
const referrerAcquisitionData = getReferrerAcquisitionData();
return derivePaymentApiAcquisitionData(
{
...referrerAcquisitionData,
labels: [
...(referrerAcquisitionData.labels ?? []),
'one-time-checkout',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can get rid of this now it's the only one time checkout left?

...(coverTransactionCost ? ['transaction-fee-covered'] : []),
],
},
abParticipations,
billingPostcode,
);
}

export function OneTimeCheckoutComponent({
geoId,
appConfig,
Expand Down Expand Up @@ -360,13 +381,10 @@ export function OneTimeCheckoutComponent({
),
cancelURL: payPalCancelUrl(countryGroupId),
});
const acquisitionData = derivePaymentApiAcquisitionData(
{
...getReferrerAcquisitionData(),
labels: ['one-time-checkout'],
},
const acquisitionData = getAcquisitionData(
abParticipations,
billingPostcode,
coverTransactionCost,
);
// We've only created a payment at this point, and the user has to get through
// the PayPal flow on their site before we can actually try and execute the payment.
Expand Down Expand Up @@ -444,13 +462,10 @@ export function OneTimeCheckoutComponent({
email,
stripePaymentMethod: stripePaymentMethod,
},
acquisitionData: derivePaymentApiAcquisitionData(
{
...getReferrerAcquisitionData(),
labels: ['one-time-checkout'],
},
acquisitionData: getAcquisitionData(
abParticipations,
billingPostcode,
coverTransactionCost,
),
publicKey: stripePublicKey,
recaptchaToken: recaptchaToken ?? '',
Expand Down
Loading