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