Skip to content

feat(paypal-js): add v6 Local Payment Methods (LPM) types#992

Open
Mathanjeevika wants to merge 3 commits into
paypal:mainfrom
Mathanjeevika:feature/lpm-paypal-js-types
Open

feat(paypal-js): add v6 Local Payment Methods (LPM) types#992
Mathanjeevika wants to merge 3 commits into
paypal:mainfrom
Mathanjeevika:feature/lpm-paypal-js-types

Conversation

@Mathanjeevika

Copy link
Copy Markdown

Summary

  • Adds TypeScript type declarations for the v6 SDK's Local Payment Methods (LPM) surface: LPMComponents, LPMSessionMethodName, LPMOneTimePaymentSession, and related types in packages/paypal-js/types/v6/components/lpm-payments.d.ts.
  • Wires these types into packages/paypal-js/types/v6/index.d.ts.

Context

This is PR 1 of 3 split out from #926 per review feedback requesting the original monolithic PR be broken up. This PR contains only the paypal-js type declarations, with no runtime code changes. It's a foundational dependency for the React wrapper split out in a follow-up PR.

Test plan

  • npm run typecheck passes
  • packages/paypal-js/src/v6/index.test.ts updated and passing
  • Changeset included (.changeset/lpm-paypal-js-types.md)

Adds LPMPaymentsInstance and the LPMComponents union to the v6 SDK
types, and wires LPM component names into SdkInstance/Components/
CreateInstanceOptions so createInstance surfaces LPM methods.

Split out of PR paypal#926 per review (paypal-js portion).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Mathanjeevika
Mathanjeevika requested a review from a team as a code owner July 13, 2026 04:20
@changeset-bot

changeset-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 51755ca

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@paypal/paypal-js Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread packages/paypal-js/src/v6/index.test.ts Outdated
Comment on lines +153 to +154
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await loadCoreSdkScript({} as any);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this need to be added? Same with the as any below. I don't think we need to cast this in our tests.

Comment thread packages/paypal-js/types/v6/index.d.ts Outdated

export interface LoadCoreSdkScriptOptions extends CoreSdkScriptDataAttributes {
environment: "production" | "sandbox";
environment?: "production" | "sandbox";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is accidentally reverting a prior change.

Suggested change
environment?: "production" | "sandbox";
environment: "production" | "sandbox";

| "ovo-payments"
| "paysera-payments"
| "skrill-payments"
| "thailandbanks-payments"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

slightly different component name, which is odd b/c other component names do not have the hyphen indonesiabanks-payment for example.

Suggested change
| "thailandbanks-payments"
| "thailand-banks-payments"

Comment on lines +57 to +70
export type LPMOneTimePaymentSessionPromise = Promise<{
orderId: string;
phone?: { countryCode: string; nationalNumber: string };
billingAddress?: {
addressLine1: string;
addressLine2?: string;
adminArea1: string;
adminArea2?: string;
postalCode: string;
countryCode: string;
};
taxInfo?: { taxId: string; taxIdType: string };
expiryDate?: string;
}>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we re-use the types that are defined above? Maybe this type LPMSessionFields could be re-used more broadly?

export type LPMOneTimePaymentSessionPromise = Promise<{
  orderId: string;
  phone?: LPMSessionFieldPhone;
  billingAddress?: LPMSessionFieldBillingAddress;
  taxInfo?: LPMSessionFieldTaxInfo;
  expiryDate?: string;
}>;

| "createLithuaniaBanksOneTimePaymentSession"
| "createJeniuspayOneTimePaymentSession";

export type LPMPaymentsInstance = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add a JS Doc comment that is in line with the other instance interfaces/types? VenmoPaymentsInstance is a good example.

options: LPMStartOptions,
paymentSessionPromise?: LPMOneTimePaymentSessionPromise,
) => Promise<void>;
createPaymentFields: (options: { type: string; value?: string }) => HTMLElement;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see createPaymentFields option typed more tightly internally. Is there a reason to leave the style key off of the options here? Also should the type be more tightly typed to the actual values "email" | "name" | "tax_id" | "tax_id_type" ?

Mathanjeevika and others added 2 commits July 17, 2026 10:48
- Replace 'as any' casts with '@ts-expect-error' in index.test.ts
- Make 'environment' required again in LoadCoreSdkScriptOptions
- Reuse LPMSessionField* types in LPMOneTimePaymentSessionPromise
- Rename 'thailandbanks-payments' -> 'thailand-banks-payments'
- Add JSDoc comment for LPMPaymentsInstance
- Tighten createPaymentFields: narrow type union, add style key

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Extends the presentation-mode options with optional merchant-collected
* session fields (phone, billingAddress, taxInfo, etc.) required by some LPMs.
*/
export type LPMStartOptions = LPMPresentationModeOptions & LPMSessionFields;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are the LPM session fields being added to the LPMStartOptions? Looking at the internal code, the first argument for .start is options and can include either presentationMode or fullPageOverlay, why is options being expanded to include these other properties?

phone?: LPMSessionFieldPhone;
billingAddress?: LPMSessionFieldBillingAddress;
taxInfo?: LPMSessionFieldTaxInfo;
expiryDate?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking more closely at the internal code it looks like expiryDate is shaped like this

expiryDate: {expiry_date: string} <-- this is the shape of ExpiryDate type

billingAddress?: LPMSessionFieldBillingAddress;
taxInfo?: LPMSessionFieldTaxInfo;
expiryDate?: string;
}>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like this is also missing date of birth and number of installments fields, shouldn't we just re-use LPMSessionFields here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants