@etsoo/braintree
Advanced tools
@@ -96,3 +96,3 @@ import React from "react"; | ||
| */ | ||
| onPaymentRequestable: (payload: PaymentPayload) => Promise<void>; | ||
| onPaymentRequestable: (method: PaymentMethod, payload: PaymentPayload) => Promise<void>; | ||
| /** | ||
@@ -99,0 +99,0 @@ * Payment start callback |
@@ -480,4 +480,4 @@ "use strict"; | ||
| // Default callback | ||
| const onPaymentRequestableLocal = (button, payload) => __awaiter(this, void 0, void 0, function* () { | ||
| yield onPaymentRequestable(payload); | ||
| const createPaymentCallback = (method) => (button, payload) => __awaiter(this, void 0, void 0, function* () { | ||
| yield onPaymentRequestable(method, payload); | ||
| if (onPaymentEnd) | ||
@@ -525,3 +525,3 @@ onPaymentEnd(button); | ||
| try { | ||
| const alipayRef = yield createLocalPayment(clientInstance, Object.assign(Object.assign({}, alipay), { method: "alipay" }), environment, amount, onPaymentRequestableLocal, onPaymentErrorLocal, onPaymentStart); | ||
| const alipayRef = yield createLocalPayment(clientInstance, Object.assign(Object.assign({}, alipay), { method: "alipay" }), environment, amount, createPaymentCallback("alipay"), onPaymentErrorLocal, onPaymentStart); | ||
| items.alipay = alipayRef; | ||
@@ -539,3 +539,3 @@ } | ||
| ApplePaySessionClass.canMakePayments()) { | ||
| const applePayRef = yield createApplePay(clientInstance, applePay, environment, amount, ApplePaySessionClass, onPaymentRequestableLocal, onPaymentErrorLocal, onPaymentStart); | ||
| const applePayRef = yield createApplePay(clientInstance, applePay, environment, amount, ApplePaySessionClass, createPaymentCallback("applePay"), onPaymentErrorLocal, onPaymentStart); | ||
| items.applePay = applePayRef; | ||
@@ -557,3 +557,3 @@ } | ||
| try { | ||
| const cardRef = yield createCard(clientInstance, card, amount, onPaymentRequestableLocal, onPaymentErrorLocal, threeDSecureInstance, onPaymentStart); | ||
| const cardRef = yield createCard(clientInstance, card, amount, createPaymentCallback("card"), onPaymentErrorLocal, threeDSecureInstance, onPaymentStart); | ||
| items.card = cardRef; | ||
@@ -567,3 +567,3 @@ } | ||
| try { | ||
| const googlePayRef = yield createGooglePay(clientInstance, googlePay, environment, amount, onPaymentRequestableLocal, onPaymentErrorLocal, onPaymentStart); | ||
| const googlePayRef = yield createGooglePay(clientInstance, googlePay, environment, amount, createPaymentCallback("googlePay"), onPaymentErrorLocal, onPaymentStart); | ||
| if (googlePayRef == null) { | ||
@@ -582,3 +582,3 @@ onError("googlePay", new Error("GooglePay API isReadyToPay failed")); | ||
| try { | ||
| const paypalRef = yield createPaypal(clientInstance, paypal, environment, amount, onPaymentRequestableLocal, onPaymentErrorLocal, onPaymentStart); | ||
| const paypalRef = yield createPaypal(clientInstance, paypal, environment, amount, createPaymentCallback("paypal"), onPaymentErrorLocal, onPaymentStart); | ||
| items.paypal = paypalRef; | ||
@@ -585,0 +585,0 @@ } |
@@ -96,3 +96,3 @@ import React from "react"; | ||
| */ | ||
| onPaymentRequestable: (payload: PaymentPayload) => Promise<void>; | ||
| onPaymentRequestable: (method: PaymentMethod, payload: PaymentPayload) => Promise<void>; | ||
| /** | ||
@@ -99,0 +99,0 @@ * Payment start callback |
@@ -473,4 +473,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
| // Default callback | ||
| const onPaymentRequestableLocal = (button, payload) => __awaiter(this, void 0, void 0, function* () { | ||
| yield onPaymentRequestable(payload); | ||
| const createPaymentCallback = (method) => (button, payload) => __awaiter(this, void 0, void 0, function* () { | ||
| yield onPaymentRequestable(method, payload); | ||
| if (onPaymentEnd) | ||
@@ -518,3 +518,3 @@ onPaymentEnd(button); | ||
| try { | ||
| const alipayRef = yield createLocalPayment(clientInstance, Object.assign(Object.assign({}, alipay), { method: "alipay" }), environment, amount, onPaymentRequestableLocal, onPaymentErrorLocal, onPaymentStart); | ||
| const alipayRef = yield createLocalPayment(clientInstance, Object.assign(Object.assign({}, alipay), { method: "alipay" }), environment, amount, createPaymentCallback("alipay"), onPaymentErrorLocal, onPaymentStart); | ||
| items.alipay = alipayRef; | ||
@@ -532,3 +532,3 @@ } | ||
| ApplePaySessionClass.canMakePayments()) { | ||
| const applePayRef = yield createApplePay(clientInstance, applePay, environment, amount, ApplePaySessionClass, onPaymentRequestableLocal, onPaymentErrorLocal, onPaymentStart); | ||
| const applePayRef = yield createApplePay(clientInstance, applePay, environment, amount, ApplePaySessionClass, createPaymentCallback("applePay"), onPaymentErrorLocal, onPaymentStart); | ||
| items.applePay = applePayRef; | ||
@@ -550,3 +550,3 @@ } | ||
| try { | ||
| const cardRef = yield createCard(clientInstance, card, amount, onPaymentRequestableLocal, onPaymentErrorLocal, threeDSecureInstance, onPaymentStart); | ||
| const cardRef = yield createCard(clientInstance, card, amount, createPaymentCallback("card"), onPaymentErrorLocal, threeDSecureInstance, onPaymentStart); | ||
| items.card = cardRef; | ||
@@ -560,3 +560,3 @@ } | ||
| try { | ||
| const googlePayRef = yield createGooglePay(clientInstance, googlePay, environment, amount, onPaymentRequestableLocal, onPaymentErrorLocal, onPaymentStart); | ||
| const googlePayRef = yield createGooglePay(clientInstance, googlePay, environment, amount, createPaymentCallback("googlePay"), onPaymentErrorLocal, onPaymentStart); | ||
| if (googlePayRef == null) { | ||
@@ -575,3 +575,3 @@ onError("googlePay", new Error("GooglePay API isReadyToPay failed")); | ||
| try { | ||
| const paypalRef = yield createPaypal(clientInstance, paypal, environment, amount, onPaymentRequestableLocal, onPaymentErrorLocal, onPaymentStart); | ||
| const paypalRef = yield createPaypal(clientInstance, paypal, environment, amount, createPaymentCallback("paypal"), onPaymentErrorLocal, onPaymentStart); | ||
| items.paypal = paypalRef; | ||
@@ -578,0 +578,0 @@ } |
+2
-2
| { | ||
| "name": "@etsoo/braintree", | ||
| "version": "1.0.97", | ||
| "version": "1.0.98", | ||
| "description": "React components for Braintree", | ||
@@ -52,3 +52,3 @@ "main": "lib/cjs/index.js", | ||
| "@testing-library/react": "^14.0.0", | ||
| "@types/braintree-web": "^3.96.2", | ||
| "@types/braintree-web": "^3.96.3", | ||
| "@types/googlepay": "^0.7.1", | ||
@@ -55,0 +55,0 @@ "@types/jest": "^29.5.4", |
+15
-13
@@ -165,3 +165,6 @@ import { | ||
| */ | ||
| onPaymentRequestable: (payload: PaymentPayload) => Promise<void>; | ||
| onPaymentRequestable: ( | ||
| method: PaymentMethod, | ||
| payload: PaymentPayload | ||
| ) => Promise<void>; | ||
@@ -802,9 +805,8 @@ /** | ||
| // Default callback | ||
| const onPaymentRequestableLocal = async ( | ||
| button: HTMLElement, | ||
| payload: PaymentPayload | ||
| ) => { | ||
| await onPaymentRequestable(payload); | ||
| if (onPaymentEnd) onPaymentEnd(button); | ||
| }; | ||
| const createPaymentCallback = | ||
| (method: PaymentMethod) => | ||
| async (button: HTMLElement, payload: PaymentPayload) => { | ||
| await onPaymentRequestable(method, payload); | ||
| if (onPaymentEnd) onPaymentEnd(button); | ||
| }; | ||
@@ -865,3 +867,3 @@ const onPaymentErrorLocal: PaymentErrorHandler = (button, method, reason) => { | ||
| amount, | ||
| onPaymentRequestableLocal, | ||
| createPaymentCallback("alipay"), | ||
| onPaymentErrorLocal, | ||
@@ -893,3 +895,3 @@ onPaymentStart | ||
| ApplePaySessionClass, | ||
| onPaymentRequestableLocal, | ||
| createPaymentCallback("applePay"), | ||
| onPaymentErrorLocal, | ||
@@ -919,3 +921,3 @@ onPaymentStart | ||
| amount, | ||
| onPaymentRequestableLocal, | ||
| createPaymentCallback("card"), | ||
| onPaymentErrorLocal, | ||
@@ -938,3 +940,3 @@ threeDSecureInstance, | ||
| amount, | ||
| onPaymentRequestableLocal, | ||
| createPaymentCallback("googlePay"), | ||
| onPaymentErrorLocal, | ||
@@ -964,3 +966,3 @@ onPaymentStart | ||
| amount, | ||
| onPaymentRequestableLocal, | ||
| createPaymentCallback("paypal"), | ||
| onPaymentErrorLocal, | ||
@@ -967,0 +969,0 @@ onPaymentStart |
| import { ApplePayPayload, GooglePaymentTokenizePayload, HostedFieldsTokenizePayload, ThreeDSecureVerifyPayload } from "braintree-web"; | ||
| import { PaymentPayload } from "./data/PaymentPayload"; | ||
| /** | ||
| * Etsoo Braintree utilities | ||
| */ | ||
| export declare namespace EtsooBraintreeUtils { | ||
| /** | ||
| * Is Apple Pay response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isApplePayResponse(payload: PaymentPayload): payload is ApplePayPayload; | ||
| /** | ||
| * Is card payment response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isCardResponse(payload: PaymentPayload): payload is HostedFieldsTokenizePayload; | ||
| /** | ||
| * Is card payment 3DS response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isCard3DSResponse(payload: PaymentPayload): payload is ThreeDSecureVerifyPayload; | ||
| /** | ||
| * Is Google Pay response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isGooglePayResponse(payload: PaymentPayload): payload is GooglePaymentTokenizePayload; | ||
| /** | ||
| * Is Paypal response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isPaypalResponse(payload: PaymentPayload): payload is paypal.AuthorizationResponse; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.EtsooBraintreeUtils = void 0; | ||
| /** | ||
| * Etsoo Braintree utilities | ||
| */ | ||
| var EtsooBraintreeUtils; | ||
| (function (EtsooBraintreeUtils) { | ||
| /** | ||
| * Is Apple Pay response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isApplePayResponse(payload) { | ||
| return payload.type === "ApplePayCard"; | ||
| } | ||
| EtsooBraintreeUtils.isApplePayResponse = isApplePayResponse; | ||
| /** | ||
| * Is card payment response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isCardResponse(payload) { | ||
| return payload.type === "CreditCard"; | ||
| } | ||
| EtsooBraintreeUtils.isCardResponse = isCardResponse; | ||
| /** | ||
| * Is card payment 3DS response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isCard3DSResponse(payload) { | ||
| return payload.type === "CreditCard" && "threeDSecureInfo" in payload; | ||
| } | ||
| EtsooBraintreeUtils.isCard3DSResponse = isCard3DSResponse; | ||
| /** | ||
| * Is Google Pay response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isGooglePayResponse(payload) { | ||
| const type = payload.type; | ||
| return (type === "AndroidPayCard" || | ||
| (type === "CreditCard" && "binData" in payload)); | ||
| } | ||
| EtsooBraintreeUtils.isGooglePayResponse = isGooglePayResponse; | ||
| /** | ||
| * Is Paypal response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isPaypalResponse(payload) { | ||
| return payload.type === "PayPalAccount"; | ||
| } | ||
| EtsooBraintreeUtils.isPaypalResponse = isPaypalResponse; | ||
| })(EtsooBraintreeUtils || (exports.EtsooBraintreeUtils = EtsooBraintreeUtils = {})); |
| import { ApplePayPayload, GooglePaymentTokenizePayload, HostedFieldsTokenizePayload, ThreeDSecureVerifyPayload } from "braintree-web"; | ||
| import { PaymentPayload } from "./data/PaymentPayload"; | ||
| /** | ||
| * Etsoo Braintree utilities | ||
| */ | ||
| export declare namespace EtsooBraintreeUtils { | ||
| /** | ||
| * Is Apple Pay response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isApplePayResponse(payload: PaymentPayload): payload is ApplePayPayload; | ||
| /** | ||
| * Is card payment response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isCardResponse(payload: PaymentPayload): payload is HostedFieldsTokenizePayload; | ||
| /** | ||
| * Is card payment 3DS response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isCard3DSResponse(payload: PaymentPayload): payload is ThreeDSecureVerifyPayload; | ||
| /** | ||
| * Is Google Pay response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isGooglePayResponse(payload: PaymentPayload): payload is GooglePaymentTokenizePayload; | ||
| /** | ||
| * Is Paypal response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isPaypalResponse(payload: PaymentPayload): payload is paypal.AuthorizationResponse; | ||
| } |
| /** | ||
| * Etsoo Braintree utilities | ||
| */ | ||
| export var EtsooBraintreeUtils; | ||
| (function (EtsooBraintreeUtils) { | ||
| /** | ||
| * Is Apple Pay response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isApplePayResponse(payload) { | ||
| return payload.type === "ApplePayCard"; | ||
| } | ||
| EtsooBraintreeUtils.isApplePayResponse = isApplePayResponse; | ||
| /** | ||
| * Is card payment response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isCardResponse(payload) { | ||
| return payload.type === "CreditCard"; | ||
| } | ||
| EtsooBraintreeUtils.isCardResponse = isCardResponse; | ||
| /** | ||
| * Is card payment 3DS response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isCard3DSResponse(payload) { | ||
| return payload.type === "CreditCard" && "threeDSecureInfo" in payload; | ||
| } | ||
| EtsooBraintreeUtils.isCard3DSResponse = isCard3DSResponse; | ||
| /** | ||
| * Is Google Pay response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isGooglePayResponse(payload) { | ||
| const type = payload.type; | ||
| return (type === "AndroidPayCard" || | ||
| (type === "CreditCard" && "binData" in payload)); | ||
| } | ||
| EtsooBraintreeUtils.isGooglePayResponse = isGooglePayResponse; | ||
| /** | ||
| * Is Paypal response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| function isPaypalResponse(payload) { | ||
| return payload.type === "PayPalAccount"; | ||
| } | ||
| EtsooBraintreeUtils.isPaypalResponse = isPaypalResponse; | ||
| })(EtsooBraintreeUtils || (EtsooBraintreeUtils = {})); |
| import { | ||
| ApplePayPayload, | ||
| GooglePaymentTokenizePayload, | ||
| HostedFieldsTokenizePayload, | ||
| ThreeDSecureVerifyPayload | ||
| } from "braintree-web"; | ||
| import { PaymentPayload } from "./data/PaymentPayload"; | ||
| /** | ||
| * Etsoo Braintree utilities | ||
| */ | ||
| export namespace EtsooBraintreeUtils { | ||
| /** | ||
| * Is Apple Pay response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| export function isApplePayResponse( | ||
| payload: PaymentPayload | ||
| ): payload is ApplePayPayload { | ||
| return payload.type === "ApplePayCard"; | ||
| } | ||
| /** | ||
| * Is card payment response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| export function isCardResponse( | ||
| payload: PaymentPayload | ||
| ): payload is HostedFieldsTokenizePayload { | ||
| return payload.type === "CreditCard"; | ||
| } | ||
| /** | ||
| * Is card payment 3DS response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| export function isCard3DSResponse( | ||
| payload: PaymentPayload | ||
| ): payload is ThreeDSecureVerifyPayload { | ||
| return payload.type === "CreditCard" && "threeDSecureInfo" in payload; | ||
| } | ||
| /** | ||
| * Is Google Pay response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| export function isGooglePayResponse( | ||
| payload: PaymentPayload | ||
| ): payload is GooglePaymentTokenizePayload { | ||
| const type = payload.type; | ||
| return ( | ||
| type === "AndroidPayCard" || | ||
| (type === "CreditCard" && "binData" in payload) | ||
| ); | ||
| } | ||
| /** | ||
| * Is Paypal response payload or not | ||
| * @param payload Response payload | ||
| * @returns Result | ||
| */ | ||
| export function isPaypalResponse( | ||
| payload: PaymentPayload | ||
| ): payload is paypal.AuthorizationResponse { | ||
| return payload.type === "PayPalAccount"; | ||
| } | ||
| } |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
115460
-6.3%74
-6.33%2878
-7.9%