@@ -121,16 +121,143 @@ export type PayLaterOneTimePaymentSessionOptions =
121121export type PayPalCreditOneTimePaymentSessionOptions =
122122 PayPalOneTimePaymentSessionOptions;
123123
124+ /**
125+ * PayPal Payments Instance interface for creating and managing different types of PayPal payment sessions.
126+ *
127+ * This interface provides methods to create various PayPal payment flows including:
128+ * - One-time payments with standard PayPal
129+ * - Save payment methods for future use (vaulting)
130+ * - PayPal Pay Later financing options
131+ * - PayPal Credit transactions
132+ *
133+ * Each method returns a payment session object that can be used to initiate the corresponding
134+ * payment flow with different presentation modes (popup, modal, redirect, etc.).
135+ *
136+ * @interface PayPalPaymentsInstance
137+ *
138+ * @example
139+ * ```typescript
140+ * // Create a one-time payment session
141+ * const paypalCheckout = sdkInstance.createPayPalOneTimePaymentSession({
142+ * onApprove: (data) => console.log('Payment approved:', data),
143+ * onCancel: () => console.log('Payment canceled'),
144+ * onError: (data) => console.error('Payment error:', data)
145+ * });
146+ *
147+ * // Start the payment flow
148+ * await paypalCheckout.start({ mode: 'auto' });
149+ * ```
150+ */
124151export interface PayPalPaymentsInstance {
152+ /**
153+ * Creates a PayPal one-time payment session for processing single payments through PayPal.
154+ * This method allows you to configure callback functions to handle different stages
155+ * of the PayPal checkout process, including payment approval, shipping address changes,
156+ * shipping option changes, cancelation, and errors.
157+ *
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
160+ *
161+ * @example
162+ * ```typescript
163+ * const paypalSession = sdkInstance.createPayPalOneTimePaymentSession({
164+ * onApprove: (data) => {
165+ * console.log('PayPal payment approved:', data);
166+ * },
167+ * onShippingAddressChange: (data) => {
168+ * console.log('Shipping address changed:', data);
169+ * },
170+ * onShippingOptionsChange: (data) => {
171+ * console.log('Shipping options changed:', data);
172+ * },
173+ * onCancel: () => {
174+ * console.log('PayPal payment canceled');
175+ * },
176+ * onError: (data) => {
177+ * console.error('PayPal payment error:', data);
178+ * }
179+ * });
180+ * ```
181+ */
125182 createPayPalOneTimePaymentSession: (
126183 paymentSessionOptions: PayPalOneTimePaymentSessionOptions,
127184 ) => OneTimePaymentSession;
185+ /**
186+ * Creates a PayPal save payment session for storing payment methods for future use.
187+ * This method allows you to set up vault payment sessions where customers can save
188+ * their PayPal payment method for future transactions without re-entering details.
189+ *
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
192+ *
193+ * @example
194+ * ```typescript
195+ * const savePaymentSession = sdkInstance.createPayPalSavePaymentSession({
196+ * vaultSetupToken: 'your-vault-setup-token',
197+ * onApprove: (data) => {
198+ * console.log('Payment method saved:', data);
199+ * },
200+ * onCancel: () => {
201+ * console.log('Save payment canceled');
202+ * },
203+ * onError: (data) => {
204+ * console.error('Save payment error:', data);
205+ * }
206+ * });
207+ * ```
208+ */
128209 createPayPalSavePaymentSession: (
129210 paymentSessionOptions: SavePaymentSessionOptions,
130211 ) => SavePaymentSession;
212+ /**
213+ * Creates a PayPal Pay Later one-time payment session for buy now, pay later transactions.
214+ * This method enables customers to make purchases and pay for them over time through
215+ * PayPal's Pay Later financing options. Available in supported countries.
216+ *
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
219+ *
220+ * @example
221+ * ```typescript
222+ * const payLaterSession = sdkInstance.createPayLaterOneTimePaymentSession({
223+ * onApprove: (data) => {
224+ * console.log('Pay Later payment approved:', data);
225+ * },
226+ * onCancel: () => {
227+ * console.log('Pay Later payment canceled');
228+ * },
229+ * onError: (data) => {
230+ * console.error('Pay Later payment error:', data);
231+ * }
232+ * });
233+ * ```
234+ */
131235 createPayLaterOneTimePaymentSession: (
132236 paymentSessionOptions: PayLaterOneTimePaymentSessionOptions,
133237 ) => OneTimePaymentSession;
238+ /**
239+ * Creates a PayPal Credit one-time payment session for credit-based transactions.
240+ * This method enables customers to make purchases using PayPal Credit, allowing them
241+ * to pay over time with financing options. Available in supported countries.
242+ *
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
245+ *
246+ * @example
247+ * ```typescript
248+ * const creditSession = sdkInstance.createPayPalCreditOneTimePaymentSession({
249+ * onApprove: (data) => {
250+ * console.log('PayPal Credit payment approved:', data);
251+ * },
252+ * onCancel: () => {
253+ * console.log('PayPal Credit payment canceled');
254+ * },
255+ * onError: (data) => {
256+ * console.error('PayPal Credit payment error:', data);
257+ * }
258+ * });
259+ * ```
260+ */
134261 createPayPalCreditOneTimePaymentSession: (
135262 paymentSessionOptions: PayPalCreditOneTimePaymentSessionOptions,
136263 ) => OneTimePaymentSession;
0 commit comments