Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cordova-plugin-purchase

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-purchase - npm Package Compare versions

Comparing version 13.1.1 to 13.1.2

api/enums/CdvPurchase.Braintree.GooglePay.BillingAddressFormat.md

18

api/interfaces/CdvPurchase.Braintree.AdapterOptions.md

@@ -11,2 +11,4 @@ # Interface: AdapterOptions

- [clientTokenProvider](CdvPurchase.Braintree.AdapterOptions.md#clienttokenprovider)
- [googlePay](CdvPurchase.Braintree.AdapterOptions.md#googlepay)
- [threeDSecure](CdvPurchase.Braintree.AdapterOptions.md#threedsecure)
- [tokenizationKey](CdvPurchase.Braintree.AdapterOptions.md#tokenizationkey)

@@ -32,2 +34,18 @@

### googlePay
• `Optional` **googlePay**: [`Request`](CdvPurchase.Braintree.GooglePay.Request.md)
Google Pay request parameters applied to all Braintree DropIn requests
___
### threeDSecure
• `Optional` **threeDSecure**: [`Request`](CdvPurchase.Braintree.ThreeDSecure.Request.md)
3DS request parameters applied to all Braintree DropIn requests
___
### tokenizationKey

@@ -34,0 +52,0 @@

4

api/interfaces/CdvPurchase.Braintree.AdditionalData.md

@@ -19,4 +19,4 @@ # Interface: AdditionalData

Specify the full DropIn Request parameters.
Specify the full DropIn Request parameters for full customization.
When specified, all fields from PaymentRequest will be ignored.
When set, this takes precedence over all other options.

@@ -15,2 +15,3 @@ # Interface: Request

- [cardholderNameStatus](CdvPurchase.Braintree.DropIn.Request.md#cardholdernamestatus)
- [googlePayRequest](CdvPurchase.Braintree.DropIn.Request.md#googlepayrequest)
- [maskCardNumber](CdvPurchase.Braintree.DropIn.Request.md#maskcardnumber)

@@ -66,2 +67,10 @@ - [maskSecurityCode](CdvPurchase.Braintree.DropIn.Request.md#masksecuritycode)

### googlePayRequest
• `Optional` **googlePayRequest**: [`Request`](CdvPurchase.Braintree.GooglePay.Request.md)
Provide the Google Pay request if you need Google Pay support
___
### maskCardNumber

@@ -101,2 +110,4 @@

Provide the ThreeDSecure request if you need 3DS support
___

@@ -103,0 +114,0 @@

@@ -46,8 +46,10 @@ # Interface: Request

• **amount**: `string`
• `Optional` **amount**: `string`
The amount for the transaction.
Amount for the transaction.
String representation of a decimal number.
Automatically filled from the `PaymentRequest`.
___

@@ -61,2 +63,4 @@

Automatically filled from the `PaymentRequest`
___

@@ -90,2 +94,4 @@

Automatically filled from the `PaymentRequest`
___

@@ -92,0 +98,0 @@

@@ -11,2 +11,3 @@ # Namespace: Braintree

- [DropIn](CdvPurchase.Braintree.DropIn.md)
- [GooglePay](CdvPurchase.Braintree.GooglePay.md)
- [IosBridge](CdvPurchase.Braintree.IosBridge.md)

@@ -13,0 +14,0 @@ - [ThreeDSecure](CdvPurchase.Braintree.ThreeDSecure.md)

@@ -25,2 +25,3 @@ # Namespace: CdvPurchase

- [GooglePlay](CdvPurchase.GooglePlay.md)
- [PlatformOptions](CdvPurchase.PlatformOptions.md)
- [Test](CdvPurchase.Test.md)

@@ -137,3 +138,3 @@ - [Utils](CdvPurchase.Utils.md)

Ƭ **PlatformWithOptions**: { `options`: [`AdapterOptions`](../interfaces/CdvPurchase.Braintree.AdapterOptions.md) ; `platform`: [`BRAINTREE`](../enums/CdvPurchase.Platform.md#braintree) } \| { `platform`: [`GOOGLE_PLAY`](../enums/CdvPurchase.Platform.md#google_play) } \| { `options?`: [`AdapterOptions`](../interfaces/CdvPurchase.AppleAppStore.AdapterOptions.md) ; `platform`: [`APPLE_APPSTORE`](../enums/CdvPurchase.Platform.md#apple_appstore) } \| { `platform`: [`TEST`](../enums/CdvPurchase.Platform.md#test) } \| { `platform`: [`WINDOWS_STORE`](../enums/CdvPurchase.Platform.md#windows_store) }
Ƭ **PlatformWithOptions**: [`Braintree`](../interfaces/CdvPurchase.PlatformOptions.Braintree.md) \| [`AppleAppStore`](../interfaces/CdvPurchase.PlatformOptions.AppleAppStore.md) \| [`GooglePlay`](../interfaces/CdvPurchase.PlatformOptions.GooglePlay.md) \| [`Test`](../interfaces/CdvPurchase.PlatformOptions.Test.md) \| [`WindowsStore`](../interfaces/CdvPurchase.PlatformOptions.WindowsStore.md)

@@ -156,3 +157,3 @@ Used to initialize a platform with some options

• `Const` **PLUGIN\_VERSION**: ``"13.1.1"``
• `Const` **PLUGIN\_VERSION**: ``"13.1.2"``

@@ -159,0 +160,0 @@ Current release number of the plugin.

{
"name": "cordova-plugin-purchase",
"version": "13.1.1",
"version": "13.1.2",
"description": "Cordova Purchase plugin for iOS, Android, Windows (AppStore, Play, UWP)",

@@ -5,0 +5,0 @@ "cordova": {

@@ -69,4 +69,12 @@ //

},
}
}
},
googlePay: {
countryCode: 'UK',
googleMerchantName: 'My Merchant Name',
environment: 'TEST'
},
threeDSecure: {
exemptionRequested: true
},
} as CdvPurchase.Braintree.AdapterOptions
}])

@@ -141,4 +149,11 @@ .then(() => {

platform: CdvPurchase.Platform.BRAINTREE,
amountMicros: 9990000,
items: [store.get('five_tokens')],
items: [{
id: 'silver_check',
title: 'Silver Check',
pricing: { // 11 GBP
priceMicros: 11 * 1000000,
currency: 'GBP',
}
}],
email: GetEmailAddress(),
})

@@ -145,0 +160,0 @@ request

namespace CdvPurchase
{
export namespace PlatformOptions {
export interface Braintree {
platform: Platform.BRAINTREE;
options: Braintree.AdapterOptions;
}
export interface GooglePlay {
platform: Platform.GOOGLE_PLAY;
}
export interface AppleAppStore {
platform: Platform.APPLE_APPSTORE;
options?: AppleAppStore.AdapterOptions;
}
export interface Test { platform: Platform.TEST; }
export interface WindowsStore { platform: Platform.WINDOWS_STORE; }
}
/**

@@ -10,7 +28,7 @@ * Used to initialize a platform with some options

export type PlatformWithOptions =
| { platform: Platform.BRAINTREE; options: Braintree.AdapterOptions; }
| { platform: Platform.GOOGLE_PLAY; }
| { platform: Platform.APPLE_APPSTORE; options?: AppleAppStore.AdapterOptions; }
| { platform: Platform.TEST; }
| { platform: Platform.WINDOWS_STORE; }
| PlatformOptions.Braintree
| PlatformOptions.AppleAppStore
| PlatformOptions.GooglePlay
| PlatformOptions.Test
| PlatformOptions.WindowsStore
;

@@ -17,0 +35,0 @@

@@ -39,3 +39,3 @@ namespace CdvPurchase

this.store = store;
this.prefix = prefix || 'CordovaPurchase';
this.prefix = prefix || 'CdvPurchase';
}

@@ -42,0 +42,0 @@

@@ -305,3 +305,3 @@ namespace CdvPurchase {

log = options.log || function (msg) {
console.log("[CordovaPurchase.AppAppStore.Bridge] " + msg);
console.log("[CdvPurchase.AppAppStore.Bridge] " + msg);
};

@@ -308,0 +308,0 @@ }

@@ -17,2 +17,12 @@ namespace CdvPurchase {

applePay?: IosBridge.ApplePayOptions;
/**
* Google Pay request parameters applied to all Braintree DropIn requests
*/
googlePay?: GooglePay.Request;
/**
* 3DS request parameters applied to all Braintree DropIn requests
*/
threeDSecure?: ThreeDSecure.Request;
}

@@ -290,54 +300,59 @@

this.log.info("requestPayment()" + JSON.stringify(paymentRequest));
let dropInResult: DropIn.Result;
if (additionalData?.braintree?.dropInRequest) {
// User provided a full DropInRequest, just passing it through
const response = await this.launchDropIn(paymentRequest, additionalData.braintree.dropInRequest);
if (!dropInResponseIsOK(response)) return dropInResponseError(this.log, response);
dropInResult = response;
const dropInRequest: DropIn.Request = additionalData?.braintree?.dropInRequest || {};
// Apple Pay
if (!await IosBridge.ApplePayPlugin.isSupported(this.log)) {
this.log.info("Apple Pay is not supported.");
dropInRequest.applePayDisabled = true;
}
/*
else if (!additionalData?.braintree?.method || additionalData.braintree.method === PaymentMethod.THREE_D_SECURE) {
// User requested a 3D Secure payment
const nonce = await this.getNonce(PaymentMethod.THREE_D_SECURE);
if ('code' in nonce) {
return nonce;
// Google Pay
if (this.options.googlePay || dropInRequest.googlePayRequest) {
const googlePay: GooglePay.Request = {
...(this.options.googlePay ?? {}),
...(dropInRequest.googlePayRequest ?? {}),
}
if (nonce.type !== PaymentMethod.THREE_D_SECURE) {
return {
code: ErrorCode.BAD_RESPONSE,
message: 'The returned nonce should be of type THREE_D_SECURE',
};
if (!googlePay.transactionInfo) {
googlePay.transactionInfo = {
currencyCode: (paymentRequest.currency ?? ''),
totalPrice: (paymentRequest.amountMicros ?? 0) / 1000000,
totalPriceStatus: GooglePay.TotalPriceStatus.FINAL,
}
}
const threeDSecureRequest: CdvPurchase.Braintree.ThreeDSecure.Request = {
amount: formatAmount(payment.amountMicros),
nonce: nonce.value,
email: payment.email,
mobilePhoneNumber: payment.mobilePhoneNumber,
billingAddress: {
givenName: payment.billingAddress?.givenName,
surname: payment.billingAddress?.surname,
streetAddress: payment.billingAddress?.streetAddress1,
extendedAddress: payment.billingAddress?.streetAddress2,
line3: payment.billingAddress?.streetAddress3,
locality: payment.billingAddress?.locality,
phoneNumber: payment.billingAddress?.phoneNumber,
postalCode: payment.billingAddress?.postalCode,
region: payment.billingAddress?.region,
countryCodeAlpha2: payment.billingAddress?.countryCode,
},
dropInRequest.googlePayRequest = googlePay;
}
// 3DS
if (this.options.threeDSecure || dropInRequest.threeDSecureRequest) {
const threeDS: ThreeDSecure.Request = {
...(this.options.threeDSecure ?? {}),
...(dropInRequest.threeDSecureRequest ?? {}),
}
const result = await this.androidBridge?.launchDropIn({ threeDSecureRequest });
if (result?.code) {
this.log.warn("launchDropIn failed: " + JSON.stringify(result));
return result;
if (!threeDS.amount) {
threeDS.amount = asDecimalString(paymentRequest.amountMicros ?? 0);
}
if (!threeDS.billingAddress && paymentRequest.billingAddress) {
threeDS.billingAddress = {
givenName: paymentRequest.billingAddress.givenName,
surname: paymentRequest.billingAddress.surname,
countryCodeAlpha2: paymentRequest.billingAddress.countryCode,
postalCode: paymentRequest.billingAddress.postalCode,
locality: paymentRequest.billingAddress.locality,
streetAddress: paymentRequest.billingAddress.streetAddress1,
extendedAddress: paymentRequest.billingAddress.streetAddress2,
line3: paymentRequest.billingAddress.streetAddress3,
phoneNumber: paymentRequest.billingAddress.phoneNumber,
region: paymentRequest.billingAddress.region,
}
}
if (!threeDS.email) {
threeDS.email = paymentRequest.email;
}
dropInRequest.threeDSecureRequest = threeDS;
}
*/
else {
// No other payment method as the moment...
const response = await this.launchDropIn(paymentRequest, {});
if (!dropInResponseIsOK(response)) return dropInResponseError(this.log, response);
dropInResult = response;
}
const response = await this.launchDropIn(paymentRequest, dropInRequest);
if (!dropInResponseIsOK(response)) return dropInResponseError(this.log, response);
const dropInResult: DropIn.Result = response;
this.log.info("launchDropIn success: " + JSON.stringify({ paymentRequest, dropInResult }));

@@ -411,6 +426,6 @@ if (!dropInResult.paymentMethodNonce?.nonce) {

// function formatAmount(amountMicros: number): string {
// const amountCents = '' + (amountMicros / 10000);
// return (amountCents.slice(0, -2) || '0') + '.' + (amountCents.slice(-2, -1) || '0') + (amountCents.slice(-1) || '0');
// }
function asDecimalString(amountMicros: number): string {
const amountCents = '' + (amountMicros / 10000);
return (amountCents.slice(0, -2) || '0') + '.' + (amountCents.slice(-2, -1) || '0') + (amountCents.slice(-1) || '0');
}

@@ -417,0 +432,0 @@ function isBraintreeReceipt(receipt: Receipt): receipt is BraintreeReceipt {

@@ -11,15 +11,9 @@ namespace CdvPurchase {

/**
* Specify the full DropIn Request parameters.
*
* When specified, all fields from PaymentRequest will be ignored.
*/
dropInRequest?: DropIn.Request,
/*
* Payment method (default to THREE_D_SECURE)
* Specify the full DropIn Request parameters for full customization.
*
* method?: PaymentMethod;
* When set, this takes precedence over all other options.
*/
dropInRequest?: DropIn.Request;
}
}
}
}

@@ -52,2 +52,6 @@ namespace CdvPurchase {

return new Promise(resolve => {
if (window.cordova.platformId !== 'ios') {
log.info('BraintreeApplePayPlugin is only available for ios.');
return resolve(false);
}
if (!ApplePayPlugin.get()?.installed) {

@@ -54,0 +58,0 @@ log.info('BraintreeApplePayPlugin does not appear to be installed.');

@@ -151,7 +151,2 @@ namespace CdvPurchase {

if (!await ApplePayPlugin.isSupported(this.log)) {
this.log.info("Apple Pay is not supported.");
dropInRequest.applePayDisabled = true;
}
this.clientTokenProvider((clientToken) => {

@@ -158,0 +153,0 @@ if (typeof clientToken === 'string')

@@ -8,4 +8,8 @@ namespace CdvPurchase {

/** Provide the ThreeDSecure request if you need 3DS support */
threeDSecureRequest?: ThreeDSecure.Request;
/** Provide the Google Pay request if you need Google Pay support */
googlePayRequest?: GooglePay.Request;
// requestThreeDSecureVerification?: boolean;

@@ -12,0 +16,0 @@ // collectDeviceData?: boolean;

@@ -10,7 +10,9 @@ namespace CdvPurchase {

/**
* The amount for the transaction.
* Amount for the transaction.
*
* String representation of a decimal number.
*
* Automatically filled from the `PaymentRequest`.
*/
amount: string;
amount?: string;

@@ -22,10 +24,16 @@ /**

/** The email used for verification. Optional. */
/**
* The email used for verification. Optional.
*
* Automatically filled from the `PaymentRequest`
*/
email?: string;
/** The billing address used for verification. Optional. */
/**
* The billing address used for verification. Optional.
*
* Automatically filled from the `PaymentRequest`
*/
billingAddress?: PostalAddress;
// THE BELOW IS NOT IMPLEMENTED TODO!!!
/**

@@ -51,3 +59,2 @@ * The mobile phone number used for verification.

/** Set to V2 if ThreeDSecure V2 flows are desired, when possible. Defaults to V2 */

@@ -54,0 +61,0 @@ versionRequested?: Version;

@@ -27,3 +27,3 @@ /// <reference path="validator/validator.ts" />

*/
export const PLUGIN_VERSION = '13.1.1';
export const PLUGIN_VERSION = '13.1.2';

@@ -425,3 +425,3 @@ /**

// fill-in missing total amount as the sum of all items.
if (typeof paymentRequest.amountMicros === 'undefined') {
if (!paymentRequest.amountMicros) {
paymentRequest.amountMicros = 0;

@@ -434,3 +434,3 @@ for (const item of paymentRequest.items) {

// fill-in the missing if set in the items.
if (typeof paymentRequest.currency === 'undefined') {
if (!paymentRequest.currency) {
for (const item of paymentRequest.items) {

@@ -442,2 +442,14 @@ if (item?.pricing?.currency) {

}
else {
for (const item of paymentRequest.items) {
if (item?.pricing?.currency) {
if (paymentRequest.currency !== item.pricing.currency) {
return PaymentRequestPromise.failed(ErrorCode.PAYMENT_INVALID, 'Currencies do not match');
}
}
else if (item?.pricing) {
item.pricing.currency = paymentRequest.currency;
}
}
}

@@ -448,3 +460,6 @@ // fill-in item amount when there's just 1 item.

if (item && !item.pricing) {
item.pricing = { priceMicros: paymentRequest.amountMicros ?? 0 }
item.pricing = {
priceMicros: paymentRequest.amountMicros ?? 0,
currency: paymentRequest.currency,
}
}

@@ -451,0 +466,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc