mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2024-10-07 16:52:15 +08:00
fix(paypal): fix helper classes
This commit is contained in:
parent
e30ccabf7b
commit
f0026572e7
@ -18,10 +18,11 @@ import { Plugin, Cordova } from './plugin';
|
|||||||
* ```
|
* ```
|
||||||
* @interfaces
|
* @interfaces
|
||||||
* PayPalEnvironment
|
* PayPalEnvironment
|
||||||
|
* PayPalConfigurationOptions
|
||||||
|
* @classes
|
||||||
* PayPalPayment
|
* PayPalPayment
|
||||||
* PayPalItem
|
* PayPalItem
|
||||||
* PayPalPaymentDetails
|
* PayPalPaymentDetails
|
||||||
* PayPalConfigurationOptions
|
|
||||||
* PayPalShippingAddress
|
* PayPalShippingAddress
|
||||||
*/
|
*/
|
||||||
@Plugin({
|
@Plugin({
|
||||||
@ -91,7 +92,11 @@ export interface PayPalEnvironment {
|
|||||||
PayPalEnvironmentProduction: string;
|
PayPalEnvironmentProduction: string;
|
||||||
PayPalEnvironmentSandbox: string;
|
PayPalEnvironmentSandbox: string;
|
||||||
}
|
}
|
||||||
export declare var PayPalPayment: {
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export class PayPalPayment {
|
||||||
/**
|
/**
|
||||||
* Convenience constructor.
|
* Convenience constructor.
|
||||||
* Returns a PayPalPayment with the specified amount, currency code, and short description.
|
* Returns a PayPalPayment with the specified amount, currency code, and short description.
|
||||||
@ -100,12 +105,13 @@ export declare var PayPalPayment: {
|
|||||||
* @param {String} shortDescription: A short description of the payment.
|
* @param {String} shortDescription: A short description of the payment.
|
||||||
* @param {String} intent: "Sale" for an immediate payment.
|
* @param {String} intent: "Sale" for an immediate payment.
|
||||||
*/
|
*/
|
||||||
new(amount: string, currencyCode: string, shortDescription: string, intent: string): PayPalPayment;
|
constructor(amount: string, currencyCode: string, shortDescription: string, intent: string) {
|
||||||
};
|
this.amount = amount;
|
||||||
/**
|
this.currencyCode = currencyCode;
|
||||||
* @private
|
this.shortDescription = shortDescription;
|
||||||
*/
|
this.intent = intent;
|
||||||
export interface PayPalPayment {
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The amount of the payment.
|
* The amount of the payment.
|
||||||
*/
|
*/
|
||||||
@ -126,7 +132,7 @@ export interface PayPalPayment {
|
|||||||
* Optional Build Notation code ("BN code"), obtained from partnerprogram@paypal.com,
|
* Optional Build Notation code ("BN code"), obtained from partnerprogram@paypal.com,
|
||||||
* for your tracking purposes.
|
* for your tracking purposes.
|
||||||
*/
|
*/
|
||||||
bnCode: string;
|
bnCode: string = 'PhoneGap_SP';
|
||||||
/**
|
/**
|
||||||
* Optional invoice number, for your tracking purposes. (up to 256 characters)
|
* Optional invoice number, for your tracking purposes. (up to 256 characters)
|
||||||
*/
|
*/
|
||||||
@ -153,7 +159,27 @@ export interface PayPalPayment {
|
|||||||
shippingAddress: string;
|
shippingAddress: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PayPalItem {
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export class PayPalItem {
|
||||||
|
/**
|
||||||
|
* The PayPalItem class defines an optional itemization for a payment.
|
||||||
|
* @see https://developer.paypal.com/docs/api/#item-object for more details.
|
||||||
|
* @param {String} name: Name of the item. 127 characters max
|
||||||
|
* @param {Number} quantity: Number of units. 10 characters max.
|
||||||
|
* @param {String} price: Unit price for this item 10 characters max.
|
||||||
|
* May be negative for "coupon" etc
|
||||||
|
* @param {String} currency: ISO standard currency code.
|
||||||
|
* @param {String} sku: The stock keeping unit for this item. 50 characters max (optional)
|
||||||
|
*/
|
||||||
|
constructor(name: string, quantity: number, price: string, currency: string, sku: string) {
|
||||||
|
this.name = name;
|
||||||
|
this.quantity = quantity;
|
||||||
|
this.price = price;
|
||||||
|
this.currency = currency;
|
||||||
|
this.sku = sku;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Name of the item. 127 characters max
|
* Name of the item. 127 characters max
|
||||||
*/
|
*/
|
||||||
@ -176,21 +202,21 @@ export interface PayPalItem {
|
|||||||
sku: string;
|
sku: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare var PayPalItem: {
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export class PayPalPaymentDetails {
|
||||||
/**
|
/**
|
||||||
* The PayPalItem class defines an optional itemization for a payment.
|
* The PayPalPaymentDetails class defines optional amount details.
|
||||||
* @see https://developer.paypal.com/docs/api/#item-object for more details.
|
* @param {String} subtotal: Sub-total (amount) of items being paid for. 10 characters max with support for 2 decimal places.
|
||||||
* @param {String} name: Name of the item. 127 characters max
|
* @param {String} shipping: Amount charged for shipping. 10 characters max with support for 2 decimal places.
|
||||||
* @param {Number} quantity: Number of units. 10 characters max.
|
* @param {String} tax: Amount charged for tax. 10 characters max with support for 2 decimal places.
|
||||||
* @param {String} price: Unit price for this item 10 characters max.
|
|
||||||
* May be negative for "coupon" etc
|
|
||||||
* @param {String} currency: ISO standard currency code.
|
|
||||||
* @param {String} sku: The stock keeping unit for this item. 50 characters max (optional)
|
|
||||||
*/
|
*/
|
||||||
new(name: string, quantity: number, price: string, currency: string, sku: string): PayPalItem;
|
constructor(subtotal: string, shipping: string, tax: string) {
|
||||||
};
|
this.subtotal = subtotal;
|
||||||
|
this.shipping = shipping;
|
||||||
export interface PayPalPaymentDetails {
|
this.tax = tax;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Sub-total (amount) of items being paid for. 10 characters max with support for 2 decimal places.
|
* Sub-total (amount) of items being paid for. 10 characters max with support for 2 decimal places.
|
||||||
*/
|
*/
|
||||||
@ -205,16 +231,6 @@ export interface PayPalPaymentDetails {
|
|||||||
tax: string;
|
tax: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare var PayPalPaymentDetails: {
|
|
||||||
/**
|
|
||||||
* The PayPalPaymentDetails class defines optional amount details.
|
|
||||||
* @param {String} subtotal: Sub-total (amount) of items being paid for. 10 characters max with support for 2 decimal places.
|
|
||||||
* @param {String} shipping: Amount charged for shipping. 10 characters max with support for 2 decimal places.
|
|
||||||
* @param {String} tax: Amount charged for tax. 10 characters max with support for 2 decimal places.
|
|
||||||
*/
|
|
||||||
new(subtotal: string, shipping: string, tax: string): PayPalPaymentDetails;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
@ -238,11 +254,11 @@ export interface PayPalConfigurationOptions {
|
|||||||
/**
|
/**
|
||||||
* URL of your company's privacy policy, which will be offered to the user when requesting consent via a PayPalFuturePaymentViewController.
|
* URL of your company's privacy policy, which will be offered to the user when requesting consent via a PayPalFuturePaymentViewController.
|
||||||
*/
|
*/
|
||||||
merchantPrivacyPolicyUrl?: string;
|
merchantPrivacyPolicyURL?: string;
|
||||||
/**
|
/**
|
||||||
* URL of your company's user agreement, which will be offered to the user when requesting consent via a PayPalFuturePaymentViewController.
|
* URL of your company's user agreement, which will be offered to the user when requesting consent via a PayPalFuturePaymentViewController.
|
||||||
*/
|
*/
|
||||||
merchantUserAgreementUrl?: string;
|
merchantUserAgreementURL?: string;
|
||||||
/**
|
/**
|
||||||
* If set to NO, the SDK will only support paying with PayPal, not with credit cards.
|
* If set to NO, the SDK will only support paying with PayPal, not with credit cards.
|
||||||
* This applies only to single payments (via PayPalPaymentViewController).
|
* This applies only to single payments (via PayPalPaymentViewController).
|
||||||
@ -316,35 +332,47 @@ export interface PayPalConfigurationOptions {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
export declare var PayPalConfiguration: {
|
export class PayPalConfiguration implements PayPalConfigurationOptions {
|
||||||
/**
|
/**
|
||||||
* You use a PayPalConfiguration object to configure many aspects of how the SDK behaves.
|
* You use a PayPalConfiguration object to configure many aspects of how the SDK behaves.
|
||||||
* see defaults for options available
|
* see defaults for options available
|
||||||
*/
|
*/
|
||||||
new(options: PayPalConfigurationOptions): PayPalConfiguration;
|
constructor(options?: PayPalConfigurationOptions) {
|
||||||
};
|
|
||||||
|
|
||||||
export interface PayPalConfiguration {
|
let defaults: PayPalConfigurationOptions = {
|
||||||
defaultUserEmail: string;
|
defaultUserEmail: null,
|
||||||
defaultUserPhoneCountryCode: string;
|
defaultUserPhoneCountryCode: null,
|
||||||
defaultUserPhoneNumber: string;
|
defaultUserPhoneNumber: null,
|
||||||
merchantName: string;
|
merchantName: null,
|
||||||
merchantPrivacyPolicyUrl: string;
|
merchantPrivacyPolicyURL: null,
|
||||||
merchantUserAgreementUrl: string;
|
merchantUserAgreementURL: null,
|
||||||
acceptCreditCards: boolean;
|
acceptCreditCards: true,
|
||||||
payPalShippingAddressOption: number;
|
payPalShippingAddressOption: 0,
|
||||||
rememberUser: boolean;
|
rememberUser: true,
|
||||||
languageOrLocale: string;
|
languageOrLocale: null,
|
||||||
disableBlurWhenBackgrounding: boolean;
|
disableBlurWhenBackgrounding: false,
|
||||||
presentingInPopover: boolean;
|
presentingInPopover: false,
|
||||||
forceDefaultsInSandbox: boolean;
|
forceDefaultsInSandbox: false,
|
||||||
sandboxUserPassword: string;
|
sandboxUserPassword: null,
|
||||||
sandboxUserPin: string;
|
sandboxUserPin: null
|
||||||
|
};
|
||||||
|
|
||||||
|
if (options && typeof options === 'object') {
|
||||||
|
for (var i in options) {
|
||||||
|
if (defaults.hasOwnProperty(i)) {
|
||||||
|
defaults[i] = options[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaults;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
export declare var PayPalShippingAddress: {
|
export class PayPalShippingAddress {
|
||||||
/**
|
/**
|
||||||
* See the documentation of the individual properties for more detail.
|
* See the documentation of the individual properties for more detail.
|
||||||
* @param {String} recipientName: Name of the recipient at this address. 50 characters max.
|
* @param {String} recipientName: Name of the recipient at this address. 50 characters max.
|
||||||
@ -355,10 +383,15 @@ export declare var PayPalShippingAddress: {
|
|||||||
* @param {String} postalCode: ZIP code or equivalent is usually required for countries that have them. 20 characters max. Required in certain countries.
|
* @param {String} postalCode: ZIP code or equivalent is usually required for countries that have them. 20 characters max. Required in certain countries.
|
||||||
* @param {String} countryCode: 2-letter country code. 2 characters max.
|
* @param {String} countryCode: 2-letter country code. 2 characters max.
|
||||||
*/
|
*/
|
||||||
new(recipientName: string, line1: string, line2: string, city: string, state: string, postalCode: string, countryCode: string): PayPalShippingAddress;
|
constructor(recipientName: string, line1: string, line2: string, city: string, state: string, postalCode: string, countryCode: string) {
|
||||||
};
|
this.recipientName = recipientName;
|
||||||
|
this.line1 = line1;
|
||||||
export interface PayPalShippingAddress {
|
this.line2 = line2;
|
||||||
|
this.city = city;
|
||||||
|
this.state = state;
|
||||||
|
this.postalCode = postalCode;
|
||||||
|
this.countryCode = countryCode;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Name of the recipient at this address. 50 characters max.
|
* Name of the recipient at this address. 50 characters max.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user