Skip to content

Commit

Permalink
Release braintree-web 3.113.0 source
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Dec 17, 2024
1 parent fd61c46 commit f122ec1
Show file tree
Hide file tree
Showing 14 changed files with 372 additions and 95 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## 3.113.0

- Local Payment Methods
- Fix hasTokenizationParams to account for token URL param
- Hosted Fields
- add support for `-webkit-text-fill-color` CSS rule

## 3.112.1

- Venmo
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "braintree-web",
"version": "3.112.1",
"version": "3.113.0",
"license": "MIT",
"main": "src/index.js",
"private": true,
Expand Down
1 change: 1 addition & 0 deletions src/hosted-fields/shared/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ var constants = {
"-webkit-box-shadow",
"-webkit-font-smoothing",
"-webkit-tap-highlight-color",
"-webkit-text-fill-color",
"-webkit-transition",
"appearance",
"box-shadow",
Expand Down
35 changes: 35 additions & 0 deletions src/lib/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@

var constants = require("./constants");
var metadata = require("./add-metadata");
var assign = require("./assign").assign;

function sendPaypalEvent(clientInstanceOrPromise, eventName, callback) {
return sendPaypalEventPlusFields(
clientInstanceOrPromise,
eventName,
{},
callback
);
}

function sendPaypalEventPlusFields(
clientInstanceOrPromise,
eventName,
extraFields,
callback
) {
var timestamp = Date.now();

return Promise.resolve(clientInstanceOrPromise)
Expand Down Expand Up @@ -35,6 +50,10 @@ function sendPaypalEvent(clientInstanceOrPromise, eventName, callback) {
];
data.tracking = [trackingMeta];

if (extraFields && typeof extraFields === "object") {
data.tracking = [appendExtraFieldsTo(trackingMeta, extraFields)];
}

return request(
{
url: url,
Expand All @@ -52,6 +71,22 @@ function sendPaypalEvent(clientInstanceOrPromise, eventName, callback) {
});
}

function appendExtraFieldsTo(trackingMeta, extraFields) {
var result = {};
var allowedExtraFields = assign({}, extraFields);

Object.keys(allowedExtraFields).forEach(function (field) {
if (constants.ALLOWED_EXTRA_EVENT_FIELDS.indexOf(field) === -1) {
delete allowedExtraFields[field];
}
});

result = assign(trackingMeta, allowedExtraFields);

return result;
}

module.exports = {
sendEvent: sendPaypalEvent,
sendEventPlus: sendPaypalEventPlusFields,
};
1 change: 1 addition & 0 deletions src/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ module.exports = {
SOURCE: "client",
PLATFORM: PLATFORM,
BRAINTREE_LIBRARY_VERSION: "braintree/" + PLATFORM + "/" + VERSION,
ALLOWED_EXTRA_EVENT_FIELDS: ["paypal_context_id"],
};
6 changes: 5 additions & 1 deletion src/local-payment/external/local-payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,10 @@ LocalPayment.prototype._formatTokenizePayload = function (response) {
* // ?btLpToken=token&btLpPaymentId=payment-id&btLpPayerId=payer-id
* localPaymentInstance.hasTokenizationParams(); // true
*
* // if query string has token: (full page redirect flow)
* // ?token=abcdefg123456789
* localPaymentInstance.hasTokenizationParams(); // true
*
* // if query string is missing required params
* localPaymentInstance.hasTokenizationParams(); // false
*
Expand All @@ -883,7 +887,7 @@ LocalPayment.prototype._formatTokenizePayload = function (response) {
LocalPayment.prototype.hasTokenizationParams = function () {
var params = querystring.parse();

if (params.errorcode) {
if (params.errorcode || params.token) {
return true;
}

Expand Down
117 changes: 86 additions & 31 deletions src/paypal-checkout/paypal-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ PayPalCheckout.prototype._setupFrameService = function (client) {
* @returns {(promise|void)} returns a promise if no callback is provided.
*/
PayPalCheckout.prototype.createPayment = function (options) {
var self = this;

if (!options || !constants.FLOW_ENDPOINTS.hasOwnProperty(options.flow)) {
return Promise.reject(
new BraintreeError(errors.PAYPAL_FLOW_OPTION_REQUIRED)
Expand All @@ -593,6 +595,8 @@ PayPalCheckout.prototype.createPayment = function (options) {
flowToken = response.agreementSetup.tokenId;
}

self._contextId = flowToken;

return flowToken;
});
};
Expand Down Expand Up @@ -729,9 +733,12 @@ PayPalCheckout.prototype.updatePayment = function (options) {
var endpoint = "paypal_hermes/patch_payment_resource";

if (!options || this._hasMissingOption(options, constants.REQUIRED_OPTIONS)) {
analytics.sendEvent(
analytics.sendEventPlus(
self._clientPromise,
"paypal-checkout.updatePayment.missing-options"
"paypal-checkout.updatePayment.missing-options",
{
paypal_context_id: self._contextId, // eslint-disable-line camelcase
}
);

return Promise.reject(
Expand All @@ -740,9 +747,12 @@ PayPalCheckout.prototype.updatePayment = function (options) {
}

if (!this._verifyConsistentCurrency(options)) {
analytics.sendEvent(
analytics.sendEventPlus(
self._clientPromise,
"paypal-checkout.updatePayment.inconsistent-currencies"
"paypal-checkout.updatePayment.inconsistent-currencies",
{
paypal_context_id: self._contextId, // eslint-disable-line camelcase
}
);

return Promise.reject(
Expand All @@ -759,7 +769,13 @@ PayPalCheckout.prototype.updatePayment = function (options) {
);
}

analytics.sendEvent(this._clientPromise, "paypal-checkout.updatePayment");
analytics.sendEventPlus(
this._clientPromise,
"paypal-checkout.updatePayment",
{
paypal_context_id: self._contextId, // eslint-disable-line camelcase
}
);

return this._clientPromise
.then(function (client) {
Expand All @@ -773,9 +789,12 @@ PayPalCheckout.prototype.updatePayment = function (options) {
var status = err.details && err.details.httpStatus;

if (status === 422) {
analytics.sendEvent(
analytics.sendEventPlus(
self._clientPromise,
"paypal-checkout.updatePayment.invalid"
"paypal-checkout.updatePayment.invalid",
{
paypal_context_id: self._contextId, // eslint-disable-line camelcase
}
);

return Promise.reject(
Expand All @@ -790,9 +809,12 @@ PayPalCheckout.prototype.updatePayment = function (options) {
);
}

analytics.sendEvent(
analytics.sendEventPlus(
self._clientPromise,
"paypal-checkout.updatePayment." + errors.PAYPAL_FLOW_FAILED.code
"paypal-checkout.updatePayment." + errors.PAYPAL_FLOW_FAILED.code,
{
paypal_context_id: self._contextId, // eslint-disable-line camelcase
}
);

return Promise.reject(
Expand Down Expand Up @@ -839,9 +861,12 @@ PayPalCheckout.prototype.startVaultInitiatedCheckout = function (options) {
var self = this;

if (this._vaultInitiatedCheckoutInProgress) {
analytics.sendEvent(
analytics.sendEventPlus(
this._clientPromise,
"paypal-checkout.startVaultInitiatedCheckout.error.already-in-progress"
"paypal-checkout.startVaultInitiatedCheckout.error.already-in-progress",
{
paypal_context_id: self._contextId, // eslint-disable-line camelcase
}
);

return Promise.reject(
Expand Down Expand Up @@ -874,9 +899,12 @@ PayPalCheckout.prototype.startVaultInitiatedCheckout = function (options) {
flow: "checkout",
});

analytics.sendEvent(
analytics.sendEventPlus(
this._clientPromise,
"paypal-checkout.startVaultInitiatedCheckout.started"
"paypal-checkout.startVaultInitiatedCheckout.started",
{
paypal_context_id: self._contextId, // eslint-disable-line camelcase
}
);

return this._waitForVaultInitiatedCheckoutDependencies()
Expand Down Expand Up @@ -907,9 +935,12 @@ PayPalCheckout.prototype.startVaultInitiatedCheckout = function (options) {
self._removeModalBackdrop();

if (err.code === "FRAME_SERVICE_FRAME_CLOSED") {
analytics.sendEvent(
analytics.sendEventPlus(
self._clientPromise,
"paypal-checkout.startVaultInitiatedCheckout.canceled.by-customer"
"paypal-checkout.startVaultInitiatedCheckout.canceled.by-customer",
{
paypal_context_id: self._contextId, // eslint-disable-line camelcase
}
);

return Promise.reject(
Expand All @@ -927,9 +958,12 @@ PayPalCheckout.prototype.startVaultInitiatedCheckout = function (options) {
err.code &&
err.code.indexOf("FRAME_SERVICE_FRAME_OPEN_FAILED") > -1
) {
analytics.sendEvent(
analytics.sendEventPlus(
self._clientPromise,
"paypal-checkout.startVaultInitiatedCheckout.failed.popup-not-opened"
"paypal-checkout.startVaultInitiatedCheckout.failed.popup-not-opened",
{
paypal_context_id: self._contextId, // eslint-disable-line camelcase
}
);

return Promise.reject(
Expand All @@ -954,9 +988,12 @@ PayPalCheckout.prototype.startVaultInitiatedCheckout = function (options) {
self._frameService.close();
self._vaultInitiatedCheckoutInProgress = false;
self._removeModalBackdrop();
analytics.sendEvent(
analytics.sendEventPlus(
self._clientPromise,
"paypal-checkout.startVaultInitiatedCheckout.succeeded"
"paypal-checkout.startVaultInitiatedCheckout.succeeded",
{
paypal_context_id: self._contextId, // eslint-disable-line camelcase
}
);

return Promise.resolve(response);
Expand Down Expand Up @@ -1012,9 +1049,12 @@ PayPalCheckout.prototype._removeModalBackdrop = function () {
*/
PayPalCheckout.prototype.closeVaultInitiatedCheckoutWindow = function () {
if (this._vaultInitiatedCheckoutInProgress) {
analytics.sendEvent(
analytics.sendEventPlus(
this._clientPromise,
"paypal-checkout.startVaultInitiatedCheckout.canceled.by-merchant"
"paypal-checkout.startVaultInitiatedCheckout.canceled.by-merchant",
{
paypal_context_id: this._contextId, // eslint-disable-line camelcase
}
);
}

Expand Down Expand Up @@ -1147,9 +1187,12 @@ PayPalCheckout.prototype.tokenizePayment = function (tokenizeOptions) {

options.vault = shouldVault;

analytics.sendEvent(
analytics.sendEventPlus(
this._clientPromise,
"paypal-checkout.tokenization.started"
"paypal-checkout.tokenization.started",
{
paypal_context_id: self._contextId, // eslint-disable-line camelcase
}
);

return this._clientPromise
Expand All @@ -1163,14 +1206,20 @@ PayPalCheckout.prototype.tokenizePayment = function (tokenizeOptions) {
.then(function (response) {
payload = self._formatTokenizePayload(response);

analytics.sendEvent(
analytics.sendEventPlus(
self._clientPromise,
"paypal-checkout.tokenization.success"
"paypal-checkout.tokenization.success",
{
paypal_context_id: self._contextId, // eslint-disable-line camelcase
}
);
if (payload.creditFinancingOffered) {
analytics.sendEvent(
analytics.sendEventPlus(
self._clientPromise,
"paypal-checkout.credit.accepted"
"paypal-checkout.credit.accepted",
{
paypal_context_id: self._contextId, // eslint-disable-line camelcase
}
);
}

Expand All @@ -1181,9 +1230,12 @@ PayPalCheckout.prototype.tokenizePayment = function (tokenizeOptions) {
return Promise.reject(self._setupError);
}

analytics.sendEvent(
analytics.sendEventPlus(
self._clientPromise,
"paypal-checkout.tokenization.failed"
"paypal-checkout.tokenization.failed",
{
paypal_context_id: self._contextId, // eslint-disable-line camelcase
}
);

return Promise.reject(
Expand Down Expand Up @@ -1592,9 +1644,12 @@ PayPalCheckout.prototype._formatUpdatePaymentData = function (options) {

/* shippingAddress not supported yet */
if (options.hasOwnProperty("shippingAddress")) {
analytics.sendEvent(
analytics.sendEventPlus(
self._clientPromise,
"paypal-checkout.updatePayment.shippingAddress.provided.by-the-merchant"
"paypal-checkout.updatePayment.shippingAddress.provided.by-the-merchant",
{
paypal_context_id: self._contextId, // eslint-disable-line camelcase
}
);

paymentResource.line1 = options.shippingAddress.line1;
Expand Down
2 changes: 1 addition & 1 deletion src/three-d-secure/external/three-d-secure.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var FRAMEWORKS = require("./frameworks");
* @property {string} threeDSecureInfo.cavv Cardholder authentication verification value or CAVV. The main encrypted message issuers and card networks use to verify authentication has occurred. Mastercard uses an AVV message and American Express uses an AEVV message, each of which should also be passed in the cavv parameter.
* @property {string} threeDSecureInfo.dsTransactionId Transaction identifier resulting from 3D Secure 2 authentication.
* @property {string} threeDSecureInfo.eciFlag The value of the electronic commerce indicator (ECI) flag, which indicates the outcome of the 3DS authentication. This will be a two-digit value.
* @property {boolean} threeDSecureInfo.enrolled Indicates the status of 3D Secure authentication eligibility with the card issuer.
* @property {string} threeDSecureInfo.enrolled Indicates the status of 3D Secure authentication eligibility with the card issuer.
* @property {boolean} threeDSecureInfo.liabilityShifted Indicates whether the liability for fraud has been shifted away from the merchant.
* @property {boolean} threeDSecureInfo.liabilityShiftPossible Indicates whether liability shift is still possible on a retry.
* @property {string} threeDSecureInfo.paresStatus Transaction status result identifier.
Expand Down
Loading

0 comments on commit f122ec1

Please sign in to comment.