|
| 1 | +export type PayLaterCountryCodes = |
| 2 | + | "AU" |
| 3 | + | "DE" |
| 4 | + | "ES" |
| 5 | + | "FR" |
| 6 | + | "GB" |
| 7 | + | "IT" |
| 8 | + | "US"; |
| 9 | + |
| 10 | +export type PayLaterProductCodes = "PAYLATER" | "PAY_LATER_SHORT_TERM"; |
| 11 | + |
| 12 | +export type PayPalCreditCountryCodes = "US" | "GB"; |
| 13 | + |
| 14 | +export type ShippingAddressErrorType = |
| 15 | + | "ADDRESS_ERROR" |
| 16 | + | "COUNTRY_ERROR" |
| 17 | + | "STATE_ERROR" |
| 18 | + | "ZIP_ERROR"; |
| 19 | + |
| 20 | +export type ShippingAddressErrorMessages = Record< |
| 21 | + ShippingAddressErrorType, |
| 22 | + string |
| 23 | +>; |
| 24 | + |
| 25 | +export type ShippingOptionsErrorType = |
| 26 | + | "METHOD_UNAVAILABLE" |
| 27 | + | "STORE_UNAVAILABLE"; |
| 28 | + |
| 29 | +export type ShippingOptionsErrorMessages = Record< |
| 30 | + ShippingOptionsErrorType, |
| 31 | + string |
| 32 | +>; |
| 33 | + |
| 34 | +export type OnShippingAddressChangeData = { |
| 35 | + errors: ShippingAddressErrorMessages; |
| 36 | + orderId: string; |
| 37 | + shippingAddress: { |
| 38 | + city?: string; |
| 39 | + countryCode: string; |
| 40 | + postalCode?: string; |
| 41 | + state?: string; |
| 42 | + }; |
| 43 | +}; |
| 44 | + |
| 45 | +export type OnShippingOptionsChangeData = { |
| 46 | + errors: ShippingOptionsErrorMessages; |
| 47 | + orderId: string; |
| 48 | + selectedShippingOption: { |
| 49 | + amount: { |
| 50 | + currencyCode: string; |
| 51 | + value: string; |
| 52 | + }; |
| 53 | + id: string; |
| 54 | + label: string; |
| 55 | + selected: boolean; |
| 56 | + type: string; |
| 57 | + }; |
| 58 | +}; |
| 59 | + |
| 60 | +export type OnApproveDataOneTimePayments = { |
| 61 | + orderId: string; |
| 62 | + payerId?: string; |
| 63 | + billingToken?: string; |
| 64 | +}; |
| 65 | + |
| 66 | +export type OnApproveDataSavePayments = { |
| 67 | + vaultSetupToken: string; |
| 68 | + payerId?: string; |
| 69 | +}; |
| 70 | + |
| 71 | +export type OnCompleteData = { |
| 72 | + paymentSessionState?: string; |
| 73 | +}; |
| 74 | + |
| 75 | +export type OnCancelData = { |
| 76 | + orderId: string; |
| 77 | +}; |
| 78 | + |
| 79 | +export type OnErrorData = Error; |
| 80 | + |
| 81 | +export type BaseSessionOptions = { |
| 82 | + onCancel?: (data?: OnCancelData) => void; |
| 83 | + onComplete?: (data?: OnCompleteData) => void; |
| 84 | + onError?: (data: OnErrorData) => void; |
| 85 | + testBuyerCountry?: string; |
| 86 | +}; |
| 87 | + |
| 88 | +export type PayPalOneTimePaymentSessionOptions = BaseSessionOptions & { |
| 89 | + onApprove?: (data: OnApproveDataOneTimePayments) => Promise<void>; |
| 90 | + onShippingAddressChange?: ( |
| 91 | + data: OnShippingAddressChangeData, |
| 92 | + ) => Promise<void>; |
| 93 | + onShippingOptionsChange?: ( |
| 94 | + data: OnShippingOptionsChangeData, |
| 95 | + ) => Promise<void>; |
| 96 | + savePayment?: boolean; |
| 97 | +}; |
| 98 | + |
| 99 | +export type SavePaymentSessionOptions = BaseSessionOptions & { |
| 100 | + clientMetadataId?: string; |
| 101 | + orderId?: never; |
| 102 | + vaultSetupToken?: string; |
| 103 | + onApprove?: (data?: OnApproveDataSavePayments) => void; |
| 104 | +}; |
| 105 | + |
| 106 | +export type PayLaterOneTimePaymentSessionOptions = |
| 107 | + PayPalOneTimePaymentSessionOptions; |
| 108 | + |
| 109 | +export type PayPalCreditOneTimePaymentSessionOptions = |
| 110 | + PayPalOneTimePaymentSessionOptions; |
0 commit comments