UNPKG

15.8 kBTypeScriptView Raw
1/**
2 * @name PayPal
3 * @description
4 * PayPal plugin for Cordova/Ionic Applications
5 *
6 * @usage
7 * ```
8 * import {PayPal, PayPalPayment, PayPalConfiguration} from "ionic-native";
9 *
10 * PayPal.init({
11 * "PayPalEnvironmentProduction": "YOUR_PRODUCTION_CLIENT_ID",
12 * "PayPalEnvironmentSandbox": "YOUR_SANDBOX_CLIENT_ID"
13 * }).then(() => {
14 * // Environments: PayPalEnvironmentNoNetwork, PayPalEnvironmentSandbox, PayPalEnvironmentProduction
15 * PayPal.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({
16 * // Only needed if you get an "Internal Service Error" after PayPal login!
17 * //payPalShippingAddressOption: 2 // PayPalShippingAddressOptionPayPal
18 * })).then(() => {
19 * let payment = new PayPalPayment('3.33', 'USD', 'Description', 'sale');
20 * PayPal.renderSinglePaymentUI(payment).then(() => {
21 * // Successfully paid
22 *
23 * // Example sandbox response
24 * //
25 * // {
26 * // "client": {
27 * // "environment": "sandbox",
28 * // "product_name": "PayPal iOS SDK",
29 * // "paypal_sdk_version": "2.16.0",
30 * // "platform": "iOS"
31 * // },
32 * // "response_type": "payment",
33 * // "response": {
34 * // "id": "PAY-1AB23456CD789012EF34GHIJ",
35 * // "state": "approved",
36 * // "create_time": "2016-10-03T13:33:33Z",
37 * // "intent": "sale"
38 * // }
39 * // }
40 * }, () => {
41 * // Error or render dialog closed without being successful
42 * });
43 * }, () => {
44 * // Error in configuration
45 * });
46 * }, () => {
47 * // Error in initialization, maybe PayPal isn't supported or something else
48 * });
49 * ```
50 * @interfaces
51 * PayPalEnvironment
52 * PayPalConfigurationOptions
53 * @classes
54 * PayPalPayment
55 * PayPalItem
56 * PayPalPaymentDetails
57 * PayPalShippingAddress
58 */
59export declare class PayPal {
60 /**
61 * Retrieve the version of the PayPal iOS SDK library. Useful when contacting support.
62 * @returns {Promise<string>}
63 */
64 static version(): Promise<string>;
65 /**
66 * You must preconnect to PayPal to prepare the device for processing payments.
67 * This improves the user experience, by making the presentation of the
68 * UI faster. The preconnect is valid for a limited time, so
69 * the recommended time to preconnect is on page load.
70 *
71 * @param {PayPalEnvironment} clientIdsForEnvironments: set of client ids for environments
72 * @returns {Promise<any>}
73 */
74 static init(clientIdsForEnvironments: PayPalEnvironment): Promise<any>;
75 /**
76 * You must preconnect to PayPal to prepare the device for processing payments.
77 * This improves the user experience, by making the presentation of the UI faster.
78 * The preconnect is valid for a limited time, so the recommended time to preconnect is on page load.
79 *
80 * @param {String} environment: available options are "PayPalEnvironmentNoNetwork", "PayPalEnvironmentProduction" and "PayPalEnvironmentSandbox"
81 * @param {PayPalConfiguration} configuration: PayPalConfiguration object, for Future Payments merchantName, merchantPrivacyPolicyURL and merchantUserAgreementURL must be set be set
82 * @returns {Promise<any>}
83 */
84 static prepareToRender(environment: string, configuration: PayPalConfiguration): Promise<any>;
85 /**
86 * Start PayPal UI to collect payment from the user.
87 * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/ios-integration-guide/
88 * for more documentation of the params.
89 *
90 * @param {PayPalPayment} payment PayPalPayment object
91 * @returns {Promise<any>}
92 */
93 static renderSinglePaymentUI(payment: PayPalPayment): Promise<any>;
94 /**
95 * Once a user has consented to future payments, when the user subsequently initiates a PayPal payment
96 * from their device to be completed by your server, PayPal uses a Correlation ID to verify that the
97 * payment is originating from a valid, user-consented device+application.
98 * This helps reduce fraud and decrease declines.
99 * This method MUST be called prior to initiating a pre-consented payment (a "future payment") from a mobile device.
100 * Pass the result to your server, to include in the payment request sent to PayPal.
101 * Do not otherwise cache or store this value.
102 * @returns {Promise<any>}
103 */
104 static clientMetadataID(): Promise<any>;
105 /**
106 * Please Read Docs on Future Payments at https://github.com/paypal/PayPal-iOS-SDK#future-payments
107 * @returns {Promise<any>}
108 */
109 static renderFuturePaymentUI(): Promise<any>;
110 /**
111 * Please Read Docs on Profile Sharing at https://github.com/paypal/PayPal-iOS-SDK#profile-sharing
112 *
113 * @param {Array<string>} scopes scopes Set of requested scope-values. Accepted scopes are: openid, profile, address, email, phone, futurepayments and paypalattributes
114 * See https://developer.paypal.com/docs/integration/direct/identity/attributes/ for more details
115 * @returns {Promise<any>}
116 */
117 static renderProfileSharingUI(scopes: string[]): Promise<any>;
118}
119export interface PayPalEnvironment {
120 PayPalEnvironmentProduction: string;
121 PayPalEnvironmentSandbox: string;
122}
123/**
124 * @private
125 */
126export declare class PayPalPayment {
127 constructor(amount: string, currency: string, shortDescription: string, intent: string, details?: PayPalPaymentDetails);
128 /**
129 * The amount of the payment.
130 */
131 amount: string;
132 /**
133 * The ISO 4217 currency for the payment.
134 */
135 currency: string;
136 /**
137 * A short description of the payment.
138 */
139 shortDescription: string;
140 /**
141 * "Sale" for an immediate payment.
142 */
143 intent: string;
144 /**
145 * Optional Build Notation code ("BN code"), obtained from partnerprogram@paypal.com,
146 * for your tracking purposes.
147 */
148 bnCode: string;
149 /**
150 * Optional invoice number, for your tracking purposes. (up to 256 characters)
151 */
152 invoiceNumber: string;
153 /**
154 * Optional text, for your tracking purposes. (up to 256 characters)
155 */
156 custom: string;
157 /**
158 * Optional text which will appear on the customer's credit card statement. (up to 22 characters)
159 */
160 softDescriptor: string;
161 /**
162 * Optional array of PayPalItem objects.
163 */
164 items: Array<PayPalItem>;
165 /**
166 * Optional customer shipping address, if your app wishes to provide this to the SDK.
167 */
168 shippingAddress: string;
169 /**
170 * Optional PayPalPaymentDetails object
171 */
172 details: PayPalPaymentDetails;
173}
174/**
175 * @private
176 */
177export declare class PayPalItem {
178 /**
179 * The PayPalItem class defines an optional itemization for a payment.
180 * @see https://developer.paypal.com/docs/api/#item-object for more details.
181 * @param {String} name: Name of the item. 127 characters max
182 * @param {Number} quantity: Number of units. 10 characters max.
183 * @param {String} price: Unit price for this item 10 characters max.
184 * May be negative for "coupon" etc
185 * @param {String} currency: ISO standard currency code.
186 * @param {String} sku: The stock keeping unit for this item. 50 characters max (optional)
187 */
188 constructor(name: string, quantity: number, price: string, currency: string, sku?: string);
189 /**
190 * Name of the item. 127 characters max
191 */
192 name: string;
193 /**
194 * Number of units. 10 characters max.
195 */
196 quantity: number;
197 /**
198 * Unit price for this item 10 characters max.
199 */
200 price: string;
201 /**
202 * ISO standard currency code.
203 */
204 currency: string;
205 /**
206 * The stock keeping unit for this item. 50 characters max (optional)
207 */
208 sku?: string;
209}
210/**
211 * @private
212 */
213export declare class PayPalPaymentDetails {
214 /**
215 * The PayPalPaymentDetails class defines optional amount details.
216 * @param {String} subtotal: Sub-total (amount) of items being paid for. 10 characters max with support for 2 decimal places.
217 * @param {String} shipping: Amount charged for shipping. 10 characters max with support for 2 decimal places.
218 * @param {String} tax: Amount charged for tax. 10 characters max with support for 2 decimal places.
219 */
220 constructor(subtotal: string, shipping: string, tax: string);
221 /**
222 * Sub-total (amount) of items being paid for. 10 characters max with support for 2 decimal places.
223 */
224 subtotal: string;
225 /**
226 * Amount charged for shipping. 10 characters max with support for 2 decimal places.
227 */
228 shipping: string;
229 /**
230 * Amount charged for tax. 10 characters max with support for 2 decimal places.
231 */
232 tax: string;
233}
234/**
235 * @private
236 */
237export interface PayPalConfigurationOptions {
238 /**
239 * Will be overridden by email used in most recent PayPal login.
240 */
241 defaultUserEmail?: string;
242 /**
243 * Will be overridden by phone country code used in most recent PayPal login
244 */
245 defaultUserPhoneCountryCode?: string;
246 /**
247 * Will be overridden by phone number used in most recent PayPal login.
248 */
249 defaultUserPhoneNumber?: string;
250 /**
251 * Your company name, as it should be displayed to the user when requesting consent via a PayPalFuturePaymentViewController.
252 */
253 merchantName?: string;
254 /**
255 * URL of your company's privacy policy, which will be offered to the user when requesting consent via a PayPalFuturePaymentViewController.
256 */
257 merchantPrivacyPolicyURL?: string;
258 /**
259 * URL of your company's user agreement, which will be offered to the user when requesting consent via a PayPalFuturePaymentViewController.
260 */
261 merchantUserAgreementURL?: string;
262 /**
263 * If set to NO, the SDK will only support paying with PayPal, not with credit cards.
264 * This applies only to single payments (via PayPalPaymentViewController).
265 * Future payments (via PayPalFuturePaymentViewController) always use PayPal.
266 * Defaults to true
267 */
268 acceptCreditCards?: boolean;
269 /**
270 * For single payments, options for the shipping address.
271 * - 0 - PayPalShippingAddressOptionNone: no shipping address applies.
272 * - 1 - PayPalShippingAddressOptionProvided: shipping address will be provided by your app,
273 * in the shippingAddress property of PayPalPayment.
274 * - 2 - PayPalShippingAddressOptionPayPal: user will choose from shipping addresses on file
275 * for their PayPal account.
276 * - 3 - PayPalShippingAddressOptionBoth: user will choose from the shipping address provided by your app,
277 * in the shippingAddress property of PayPalPayment, plus the shipping addresses on file for the user's PayPal account.
278 * Defaults to 0 (PayPalShippingAddressOptionNone).
279 */
280 payPalShippingAddressOption?: number;
281 /**
282 * If set to YES, then if the user pays via their PayPal account,
283 * the SDK will remember the user's PayPal username or phone number;
284 * if the user pays via their credit card, then the SDK will remember
285 * the PayPal Vault token representing the user's credit card.
286 *
287 * If set to NO, then any previously-remembered username, phone number, or
288 * credit card token will be erased, and subsequent payment information will
289 * not be remembered.
290 *
291 * Defaults to YES.
292 */
293 rememberUser?: boolean;
294 /**
295 * If not set, or if set to nil, defaults to the device's current language setting.
296 *
297 * Can be specified as a language code ("en", "fr", "zh-Hans", etc.) or as a locale ("en_AU", "fr_FR", "zh-Hant_HK", etc.).
298 * If the library does not contain localized strings for a specified locale, then will fall back to the language. E.g., "es_CO" -> "es".
299 * If the library does not contain localized strings for a specified language, then will fall back to American English.
300 *
301 * If you specify only a language code, and that code matches the device's currently preferred language,
302 * then the library will attempt to use the device's current region as well.
303 * E.g., specifying "en" on a device set to "English" and "United Kingdom" will result in "en_GB".
304 */
305 languageOrLocale?: string;
306 /**
307 * Normally, the SDK blurs the screen when the app is backgrounded,
308 * to obscure credit card or PayPal account details in the iOS-saved screenshot.
309 * If your app already does its own blurring upon backgrounding, you might choose to disable this.
310 * Defaults to NO.
311 */
312 disableBlurWhenBackgrounding?: boolean;
313 /**
314 * If you will present the SDK's view controller within a popover, then set this property to YES.
315 * Defaults to NO. (iOS only)
316 */
317 presentingInPopover?: boolean;
318 /**
319 * Sandbox credentials can be difficult to type on a mobile device. Setting this flag to YES will
320 * cause the sandboxUserPassword and sandboxUserPin to always be pre-populated into login fields.
321 */
322 forceDefaultsInSandbox?: boolean;
323 /**
324 * Password to use for sandbox if 'forceDefaultsInSandbox' is set.
325 */
326 sandboxUserPassword?: string;
327 /**
328 * PIN to use for sandbox if 'forceDefaultsInSandbox' is set.
329 */
330 sandboxUserPin?: string;
331}
332/**
333 * @private
334 */
335export declare class PayPalConfiguration implements PayPalConfigurationOptions {
336 /**
337 * You use a PayPalConfiguration object to configure many aspects of how the SDK behaves.
338 * see defaults for options available
339 */
340 constructor(options?: PayPalConfigurationOptions);
341}
342/**
343 * @private
344 */
345export declare class PayPalShippingAddress {
346 /**
347 * See the documentation of the individual properties for more detail.
348 * @param {String} recipientName: Name of the recipient at this address. 50 characters max.
349 * @param {String} line1: Line 1 of the address (e.g., Number, street, etc). 100 characters max.
350 * @param {String} line2: Line 2 of the address (e.g., Suite, apt #, etc). 100 characters max. Optional.
351 * @param {String} city: City name. 50 characters max.
352 * @param {String} state: 2-letter code for US states, and the equivalent for other countries. 100 characters max. Required in certain countries.
353 * @param {String} postalCode: ZIP code or equivalent is usually required for countries that have them. 20 characters max. Required in certain countries.
354 * @param {String} countryCode: 2-letter country code. 2 characters max.
355 */
356 constructor(recipientName: string, line1: string, line2: string, city: string, state: string, postalCode: string, countryCode: string);
357 /**
358 * Name of the recipient at this address. 50 characters max.
359 */
360 recipientName: string;
361 /**
362 * Line 1 of the address (e.g., Number, street, etc). 100 characters max.
363 */
364 line1: string;
365 /**
366 * Line 2 of the address (e.g., Suite, apt #, etc). 100 characters max. Optional.
367 */
368 line2: string;
369 /**
370 * City name. 50 characters max.
371 */
372 city: string;
373 /**
374 * 2-letter code for US states, and the equivalent for other countries. 100 characters max. Required in certain countries.
375 */
376 state: string;
377 /**
378 * ZIP code or equivalent is usually required for countries that have them. 20 characters max. Required in certain countries.
379 */
380 postalCode: string;
381 /**
382 * 2-letter country code. 2 characters max.
383 */
384 countryCode: string;
385}