Skip to content

Commit 491988d

Browse files
authored
Merge pull request #700 from paypal/feature/DTPPCPSDK-3867-tsdoc
feat: tsdoc
2 parents 61aba9f + 84f62e8 commit 491988d

File tree

9 files changed

+112
-49
lines changed

9 files changed

+112
-49
lines changed

.changeset/fuzzy-parrots-invent.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@paypal/paypal-js": patch
3+
---
4+
5+
feat: use tsdoc for v6 public interface

package-lock.json

Lines changed: 53 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/paypal-js/.eslintrc.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,14 @@
2121
},
2222
"settings": {
2323
"polyfills": ["Promise", "fetch"]
24-
}
24+
},
25+
"overrides": [
26+
{
27+
"files": ["types/v6/**/*.d.ts"],
28+
"plugins": ["eslint-plugin-tsdoc"],
29+
"rules": {
30+
"tsdoc/syntax": "warn"
31+
}
32+
}
33+
]
2534
}

packages/paypal-js/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"@typescript-eslint/parser": "6.15.0",
7070
"@vitest/coverage-v8": "^1.1.0",
7171
"eslint": "8.56.0",
72+
"eslint-plugin-tsdoc": "^0.4.0",
7273
"filesize": "10.1.0",
7374
"husky": "8.0.3",
7475
"jsdom": "^23.0.1",

packages/paypal-js/types/v6/components/base-component.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type OnCompleteData = {
1111
export type OnErrorData = Error;
1212

1313
/**
14-
* use Omit<BasePaymentSessionOptions, "onApprove"> to change the arguments for onApprove()
14+
* use Omit\<BasePaymentSessionOptions, "onApprove"\> to change the arguments for onApprove()
1515
*/
1616
export type BasePaymentSessionOptions = {
1717
onApprove: (data: OnApproveDataOneTimePayments) => Promise<void>;
@@ -47,7 +47,7 @@ export type PresentationModeOptionsForAuto = {
4747
export type BasePaymentSessionPromise = Promise<{ orderId: string }>;
4848

4949
/**
50-
* use Omit<BasePaymentSession, "start"> to change the arguments for start()
50+
* use Omit\<BasePaymentSession, "start"\> to change the arguments for start()
5151
*/
5252
export type BasePaymentSession = {
5353
start: (

packages/paypal-js/types/v6/components/paypal-legacy-billing-agreements.d.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ export type PayPalLegacyBillingAgreementsSession = Omit<
4949
* @deprecated This interface provides legacy billing agreement methods that should not be used for new implementations.
5050
* Use the newer vault setup token approach with {@link PayPalPaymentsInstance.createPayPalSavePaymentSession} instead.
5151
*
52-
* @interface PayPalLegacyBillingInstance
53-
* @description Provides methods for creating billing agreements without requiring an immediate purchase.
52+
* @remarks
53+
* Provides methods for creating billing agreements without requiring an immediate purchase.
5454
* This legacy interface allows merchants to set up recurring payment agreements with customers
5555
* that can be used for future transactions.
5656
*
@@ -81,14 +81,16 @@ export type PayPalLegacyBillingAgreementsSession = Omit<
8181
export interface PayPalLegacyBillingInstance {
8282
/**
8383
* Creates a PayPal billing agreement session without requiring an immediate purchase.
84-
* This legacy method allows merchants to set up recurring payment agreements with customers
85-
* that can be used for future transactions.
8684
*
8785
* @deprecated This method is legacy and should not be used for new implementations.
8886
* Use the newer vault setup token approach with {@link PayPalPaymentsInstance.createPayPalSavePaymentSession} instead.
8987
*
90-
* @param {PayPalLegacyBillingAgreementsSessionOptions} paymentSessionOptions - Configuration options for the billing agreement session
91-
* @returns {PayPalLegacyBillingAgreementsSession} - A session object that can be used to start the billing agreement flow
88+
* @remarks
89+
* This legacy method allows merchants to set up recurring payment agreements with customers
90+
* that can be used for future transactions.
91+
*
92+
* @param paymentSessionOptions - Configuration options for the billing agreement session
93+
* @returns A session object that can be used to start the billing agreement flow
9294
*
9395
* @example
9496
* ```typescript

packages/paypal-js/types/v6/components/paypal-payments.d.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export type PayPalCreditOneTimePaymentSessionOptions =
124124
/**
125125
* PayPal Payments Instance interface for creating and managing different types of PayPal payment sessions.
126126
*
127+
* @remarks
127128
* This interface provides methods to create various PayPal payment flows including:
128129
* - One-time payments with standard PayPal
129130
* - Save payment methods for future use (vaulting)
@@ -133,8 +134,6 @@ export type PayPalCreditOneTimePaymentSessionOptions =
133134
* Each method returns a payment session object that can be used to initiate the corresponding
134135
* payment flow with different presentation modes (popup, modal, redirect, etc.).
135136
*
136-
* @interface PayPalPaymentsInstance
137-
*
138137
* @example
139138
* ```typescript
140139
* // Create a one-time payment session
@@ -151,12 +150,14 @@ export type PayPalCreditOneTimePaymentSessionOptions =
151150
export interface PayPalPaymentsInstance {
152151
/**
153152
* Creates a PayPal one-time payment session for processing single payments through PayPal.
153+
*
154+
* @remarks
154155
* This method allows you to configure callback functions to handle different stages
155156
* of the PayPal checkout process, including payment approval, shipping address changes,
156157
* shipping option changes, cancelation, and errors.
157158
*
158-
* @param {PayPalOneTimePaymentSessionOptions} paymentSessionOptions - Configuration options for the PayPal payment session
159-
* @returns {OneTimePaymentSession} - A session object that can be used to start the payment flow
159+
* @param paymentSessionOptions - Configuration options for the PayPal payment session
160+
* @returns A session object that can be used to start the payment flow
160161
*
161162
* @example
162163
* ```typescript
@@ -184,11 +185,13 @@ export interface PayPalPaymentsInstance {
184185
) => OneTimePaymentSession;
185186
/**
186187
* Creates a PayPal save payment session for storing payment methods for future use.
188+
*
189+
* @remarks
187190
* This method allows you to set up vault payment sessions where customers can save
188191
* their PayPal payment method for future transactions without re-entering details.
189192
*
190-
* @param {SavePaymentSessionOptions} paymentSessionOptions - Configuration options for the save payment session
191-
* @returns {SavePaymentSession} - A session object that can be used to start the vault setup flow
193+
* @param paymentSessionOptions - Configuration options for the save payment session
194+
* @returns A session object that can be used to start the vault setup flow
192195
*
193196
* @example
194197
* ```typescript
@@ -211,11 +214,13 @@ export interface PayPalPaymentsInstance {
211214
) => SavePaymentSession;
212215
/**
213216
* Creates a PayPal Pay Later one-time payment session for buy now, pay later transactions.
217+
*
218+
* @remarks
214219
* This method enables customers to make purchases and pay for them over time through
215220
* PayPal's Pay Later financing options. Available in supported countries.
216221
*
217-
* @param {PayLaterOneTimePaymentSessionOptions} paymentSessionOptions - Configuration options for the Pay Later payment session
218-
* @returns {OneTimePaymentSession} - A session object that can be used to start the Pay Later flow
222+
* @param paymentSessionOptions - Configuration options for the Pay Later payment session
223+
* @returns A session object that can be used to start the Pay Later flow
219224
*
220225
* @example
221226
* ```typescript
@@ -237,11 +242,13 @@ export interface PayPalPaymentsInstance {
237242
) => OneTimePaymentSession;
238243
/**
239244
* Creates a PayPal Credit one-time payment session for credit-based transactions.
245+
*
246+
* @remarks
240247
* This method enables customers to make purchases using PayPal Credit, allowing them
241248
* to pay over time with financing options. Available in supported countries.
242249
*
243-
* @param {PayPalCreditOneTimePaymentSessionOptions} paymentSessionOptions - Configuration options for the PayPal Credit payment session
244-
* @returns {OneTimePaymentSession} - A session object that can be used to start the PayPal Credit flow
250+
* @param paymentSessionOptions - Configuration options for the PayPal Credit payment session
251+
* @returns A session object that can be used to start the PayPal Credit flow
245252
*
246253
* @example
247254
* ```typescript

packages/paypal-js/types/v6/components/venmo-payments.d.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,24 @@ export type VenmoOneTimePaymentSession = Omit<BasePaymentSession, "start"> & {
2828

2929
/**
3030
* Interface for managing Venmo payment operations within the PayPal SDK.
31+
*
32+
* @remarks
3133
* This interface provides methods for creating and managing Venmo payment sessions,
3234
* allowing merchants to integrate Venmo as a payment method in their applications.
3335
*
3436
* The {@link VenmoPaymentsInstance} enables seamless integration with Venmo's payment flow,
3537
* providing a secure and user-friendly way to process payments through the Venmo platform.
36-
*
37-
* @interface VenmoPaymentsInstance
3838
*/
3939
export interface VenmoPaymentsInstance {
4040
/**
4141
* Creates a Venmo one-time payment session for processing payments through Venmo.
42+
*
43+
* @remarks
4244
* This method allows you to configure callback functions to handle different stages
4345
* of the Venmo checkout process, including payment approval, cancelation, and errors.
4446
*
45-
* @param {VenmoOneTimePaymentSessionOptions} paymentSessionOptions - Configuration options for the Venmo payment session
46-
* @returns {VenmoOneTimePaymentSession} - A session object that can be used to start the payment flow
47+
* @param paymentSessionOptions - Configuration options for the Venmo payment session
48+
* @returns A session object that can be used to start the payment flow
4749
*
4850
* @example
4951
* ```typescript

packages/paypal-js/types/v6/index.d.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ export interface PayPalV6Namespace {
1010
/**
1111
* Creates an SDK instance, which is the first step in an SDK integration. This instance serves as the base layer for all SDK components.
1212
*
13+
* @remarks
1314
* This is an asynchronous method that initializes the PayPal SDK with the provided
1415
* client token and components.
1516
*
16-
* @param {CreateInstanceOptions} createInstanceOptions - Configuration options for creating the SDK instance
17-
* @returns {Promise<SdkInstance<Components[]>>} - A promise that resolves to an SDK instance with methods based on the specified components
17+
* @param createInstanceOptions - Configuration options for creating the SDK instance
18+
* @returns A promise that resolves to an SDK instance with methods based on the specified components
1819
*
1920
* @example
2021
* ```typescript
@@ -59,6 +60,7 @@ export type CreateInstanceOptions<T extends readonly Components[]> = {
5960
/**
6061
* Dynamically typed SDK instance based on the components array provided to createInstance.
6162
*
63+
* @remarks
6264
* The return type changes based on which components are specified in the components array.
6365
*
6466
* **Always includes:**
@@ -103,12 +105,13 @@ export interface BaseInstance {
103105
/**
104106
* Checks eligibility for specific payment methods.
105107
*
108+
* @remarks
106109
* This method verifies buyer and merchant eligibility by interacting with PayPal's
107110
* public API to determine whether payment methods (such as PayPal or Venmo) can be used.
108111
* Use this to conditionally render the appropriate payment buttons on your site.
109112
*
110-
* @param {FindEligibleMethodsOptions} findEligibleMethodsOptions - Options for checking payment method eligibility
111-
* @returns {Promise<EligiblePaymentMethodsOutput>} - A promise that resolves to payment methods eligibility information
113+
* @param findEligibleMethodsOptions - Options for checking payment method eligibility
114+
* @returns A promise that resolves to payment methods eligibility information
112115
*
113116
* @example
114117
* ```typescript
@@ -125,11 +128,12 @@ export interface BaseInstance {
125128
/**
126129
* Updates the locale for the SDK instance.
127130
*
131+
* @remarks
128132
* This method allows you to dynamically change the locale of the SDK instance
129133
* after it has been initialized. The locale should be specified using a BCP-47 code.
130134
*
131-
* @param {string} locale - The new locale to set, specified as a BCP-47 code (e.g., "en-US", "es-ES")
132-
* @returns {void}
135+
* @param locale - The new locale to set, specified as a BCP-47 code (e.g., "en-US", "es-ES")
136+
* @returns void
133137
*
134138
* @example
135139
* ```typescript

0 commit comments

Comments
 (0)