Skip to content

Commit

Permalink
Release braintree-web 3.97.0 source
Browse files Browse the repository at this point in the history
Co-authored-by: Joe Plukarski <[email protected]>
  • Loading branch information
braintreeps committed Aug 8, 2023
1 parent cc50429 commit 831be9d
Show file tree
Hide file tree
Showing 12 changed files with 215 additions and 39 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# CHANGELOG

# 3.97.0

3D Secure

- Updated documentation for `requestVisaDAF` parameter on `verifyCard`

- SEPA
- Add support for new mandate params, `locale` and `billingAddress`
- PayPal
- Remove PayPal private url and user agreement url from PayPal configuration response as deprecated
- Venmo
- Change overlay container to `position: fixed` to cover the entire viewport.
- Package updates
- Updated @braintree/sanitize-url to 6.0.4
- Updated @braintree/browser-detection to 1.17.1

# 3.96.1

- Venmo
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "braintree-web",
"version": "3.96.1",
"version": "3.97.0",
"license": "MIT",
"main": "src/index.js",
"private": true,
Expand All @@ -21,11 +21,11 @@
},
"dependencies": {
"@braintree/asset-loader": "0.4.4",
"@braintree/browser-detection": "1.14.0",
"@braintree/browser-detection": "1.17.1",
"@braintree/event-emitter": "0.4.1",
"@braintree/extended-promise": "0.4.1",
"@braintree/iframer": "1.1.0",
"@braintree/sanitize-url": "6.0.2",
"@braintree/sanitize-url": "6.0.4",
"@braintree/uuid": "0.1.0",
"@braintree/wrap-promise": "2.1.0",
"card-validator": "8.1.1",
Expand Down
2 changes: 0 additions & 2 deletions src/client/request/graphql/generators/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ var CONFIGURATION_QUERY =
" paypal { " +
" displayName " +
" clientId " +
" privacyUrl " +
" userAgreementUrl " +
" assetsUrl " +
" environment " +
" environmentNoNetwork " +
Expand Down
29 changes: 25 additions & 4 deletions src/sepa/external/mandate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ var sepaErrors = require("../shared/errors");
var frameService = require("../../lib/frame-service/external");
var analytics = require("../../lib/analytics");
var useMin = require("../../lib/use-min");
var billingAddressOptions =
require("../shared/constants").BILLING_ADDRESS_OPTIONS;
var snakeCaseToCamelCase = require("../../lib/snake-case-to-camel-case");

var POPUP_WIDTH = 400;
var POPUP_HEIGHT = 570;
Expand All @@ -27,10 +30,17 @@ var POPUP_HEIGHT = 570;
* @param {object} client The Braintree client.
* @param {object} options All options for intiating the SEPA payment flow.
* @param {string} [options.accountHolderName] The account holder name.
* @param {object} [options.billingAddress] The customer's billing address
* @param {string} [options.billingAddress.addressLine1] Line 1 of the Address (eg. number, street, etc). An error will occur if this address is not valid.
* @param {string} [options.billingAddress.addressLine2] Line 2 of the Address (eg. suite, apt #, etc.). An error will occur if this address is not valid.
* @param {string} [options.billingAddress.adminArea1] Customer's city.
* @param {string} [options.billingAddress.adminArea2] Customer's region or state.
* @param {string} [options.billingAddress.postalCode] Customer's postal code.
* @param {string} [options.cancelUrl] The URL to redirect to if authorization is cancelled.
* @param {string} [options.countryCode] The customer's country code.
* @param {string} [options.countryCode] The customer's country code. Also used as billing address country code.
* @param {string} [options.customerId] The customer's id.
* @param {string} [options.iban] The customer's International Bank Account Number.
* @param {string} [options.locale] The BCP 47-formatted locale. See https://developer.paypal.com/reference/locale-codes/ for a list of possible values.
* @param {string} [options.mandateType] Specify ONE_OFF or RECURRENT payment.
* @param {string} [options.merchantAccountId] The merchant's account id.
* @param {string} [options.merchantId] The merchant id.
Expand All @@ -44,17 +54,28 @@ function createMandate(client, options) {
var data = {
sepa_debit: {
account_holder_name: options.accountHolderName,
merchant_or_partner_customer_id: options.customerId,
iban: options.iban,
mandate_type: options.mandateType,
billing_address: {
country_code: options.countryCode,
},
iban: options.iban,
merchant_or_partner_customer_id: options.customerId,
mandate_type: options.mandateType,
},
locale: options.locale,
cancel_url: options.cancelUrl,
return_url: options.returnUrl,
merchant_account_id: options.merchantAccountId,
};

if (options.billingAddress) {
billingAddressOptions.forEach(function (option) {
var ccOption = snakeCaseToCamelCase(option);
if (ccOption in options.billingAddress) {
data.sepa_debit.billing_address[option] =
options.billingAddress[ccOption]; // camelCase equivilent of option (eg. postal_code = postalCode) ]
}
});
}
/* eslint-enable */

return client
Expand Down
16 changes: 6 additions & 10 deletions src/sepa/external/sepa.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var mandates = require("./mandate");
var hasMissingOption = require("../shared/has-missing-option");
var analytics = require("../../lib/analytics");
var VERSION = process.env.npm_package_version;
var assign = require("../../lib/assign").assign;

/**
* @class
Expand Down Expand Up @@ -68,6 +69,10 @@ function SEPA(options) {
*/
SEPA.prototype.tokenize = function (options) {
var self = this;
var createMandateOptions = assign(
{ cancelUrl: self._cancelUrl, returnUrl: self._returnUrl },
options
);

if (!options || hasMissingOption(options, constants.REQUIRED_OPTIONS)) {
analytics.sendEvent(self._client, "sepa.input-validation.missing-options");
Expand All @@ -86,16 +91,7 @@ SEPA.prototype.tokenize = function (options) {
}

return mandates
.createMandate(self._client, {
accountHolderName: options.accountHolderName,
customerId: options.customerId,
iban: options.iban,
mandateType: options.mandateType,
countryCode: options.countryCode,
merchantAccountId: options.merchantAccountId,
cancelUrl: self._cancelUrl,
returnUrl: self._returnUrl,
})
.createMandate(self._client, createMandateOptions)
.then(function (mandateResponse) {
analytics.sendEvent(self._client, "sepa.create-mandate.success");
options.last4 = mandateResponse.last4;
Expand Down
7 changes: 7 additions & 0 deletions src/sepa/shared/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,12 @@ module.exports = {
"accountHolderName",
"countryCode",
],
BILLING_ADDRESS_OPTIONS: [
"address_line_1",
"address_line_2",
"admin_area_1",
"admin_area_2",
"postal_code",
],
MANDATE_TYPE_ENUM: ["ONE_OFF", "RECURRENT"],
};
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 @@ -405,7 +405,7 @@ EventEmitter.createChild(ThreeDSecure);
* @param {boolean} [options.challengeRequested] If set to true, an authentication challenge will be forced if possible.
* @param {boolean} [options.dataOnlyRequested] Indicates whether to use the data only flow. In this flow, frictionless 3DS is ensured for Mastercard cardholders as the card scheme provides a risk score for the issuer to determine whether to approve. If data only is not supported by the processor, a validation error will be raised. Non-Mastercard cardholders will fallback to a normal 3DS flow.
* @param {boolean} [options.exemptionRequested] *Deprecated:* Use `requestedExemptionType` instead.
* @param {boolean} [options.requestVisaDAF] Request to use VISA Digital Authentication Framework.
* @param {boolean} [options.requestVisaDAF] Request to use VISA Digital Authentication Framework. If set to true, a Visa DAF authenticated payment credential will be created and/or used for authentication if the merchant is eligible.
* @param {string} [options.merchantName] Allows to override the merchant name that is shown in the challenge.
* @param {string} [options.requestedExemptionType] If an exemption is requested and the exemption's conditions are satisfied, then it will be applied. The following supported exemptions are defined as per PSD2 regulation: `low_value`, `transaction_risk_analysis`
* @param {object} [options.customFields] Object where each key is the name of a custom field which has been configured in the Control Panel. In the Control Panel you can configure 3D Secure Rules which trigger on certain values.
Expand Down
2 changes: 1 addition & 1 deletion src/venmo/shared/web-login-backdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function getElementStyles() {
"}",
"#" + ELEMENT_IDS.backdrop + " {",
"cursor: pointer;",
"position: absolute;",
"position: fixed;",
"top: 0;",
"left: 0;",
"bottom: 0;",
Expand Down
4 changes: 0 additions & 4 deletions test/client/unit/request/graphql/adapters/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ describe("GraphQL Configuration", () => {
paypal: {
displayName: "display_name",
clientId: "client_id",
privacyUrl: "http://www.example.com/privacy_policy",
userAgreementUrl: "http://www.example.com/user_agreement",
assetsUrl: "https://localhost",
environmentNoNetwork: false,
environment: "CUSTOM",
Expand Down Expand Up @@ -206,8 +204,6 @@ describe("GraphQL Configuration", () => {
paypal: {
displayName: "display_name",
clientId: "client_id",
privacyUrl: "http://www.example.com/privacy_policy",
userAgreementUrl: "http://www.example.com/user_agreement",
assetsUrl: "https://localhost",
environment: "custom",
environmentNoNetwork: false,
Expand Down
102 changes: 102 additions & 0 deletions test/sepa/unit/mandate.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,108 @@ describe("mandate.js", () => {
expect(result).toEqual(expectedResult);
});

it("includes optional params in http request, locale & billing addr", async () => {
input.locale = "fr-XC";
input.billingAddress = {
addressLine1: "333 w 35th ST",
addressLine2: "Suit 223",
adminArea1: "IL",
adminArea2: "Chicago",
postalCode: "60606",
};
testContext.client.request = jest.fn();
jest.spyOn(testContext.client, "request");

testContext.client.request.mockResolvedValue(mockMandateResponse);
const expectedResult = {
approvalUrl,
last4: iban.slice(-4),
bankReferenceToken,
};

const result = await createMandate(testContext.client, input);

expect(testContext.client.request).toHaveBeenCalledWith(
expect.objectContaining({
// Disabling eslint because api is expecting snake_case format for the keys
/* eslint-disable */
api: "clientApi",
data: {
cancel_url: expect.anything(),
locale: "fr-XC",
sepa_debit: {
mandate_type: "ONE_OFF",
merchant_or_partner_customer_id: customerId,
iban: iban,
account_holder_name: "accountHolderName",
billing_address: {
address_line_1: "333 w 35th ST",
address_line_2: "Suit 223",
admin_area_1: "IL",
admin_area_2: "Chicago",
postal_code: "60606",
country_code: input.countryCode,
},
},
merchant_account_id: expect.anything(),
return_url: expect.anything(),
/* eslint-enable */
},
endpoint: expect.anything(),
method: expect.anything(),
})
);
expect(result).toEqual(expectedResult);

delete input.billingAddress;
delete input.locale;
});

it("includes optional params in http request, locale", async () => {
input.locale = "fr-XC";

testContext.client.request = jest.fn();
jest.spyOn(testContext.client, "request");

testContext.client.request.mockResolvedValue(mockMandateResponse);
const expectedResult = {
approvalUrl,
last4: iban.slice(-4),
bankReferenceToken,
};

const result = await createMandate(testContext.client, input);

expect(testContext.client.request).toHaveBeenCalledWith(
expect.objectContaining({
// Disabling eslint because api is expecting snake_case format for the keys
/* eslint-disable */
api: "clientApi",
data: {
cancel_url: expect.anything(),
locale: "fr-XC",
sepa_debit: {
mandate_type: "ONE_OFF",
merchant_or_partner_customer_id: customerId,
iban: iban,
account_holder_name: "accountHolderName",
billing_address: {
country_code: input.countryCode,
},
},
merchant_account_id: expect.anything(),
return_url: expect.anything(),
/* eslint-enable */
},
endpoint: expect.anything(),
method: expect.anything(),
})
);
expect(result).toEqual(expectedResult);

delete input.locale;
});

it("Client API return empty object", async () => {
testContext.client.request = jest.fn();

Expand Down
Loading

0 comments on commit 831be9d

Please sign in to comment.