prepare for bn codes

This commit is contained in:
David Remer 2020-07-15 19:49:32 +03:00
parent 20d4786943
commit e4a4ec3acb
6 changed files with 46 additions and 3 deletions

View file

@ -55,6 +55,7 @@ document.addEventListener(
}
if (
! document.querySelector(PayPalCommerceGateway.button.wrapper) &&
! document.querySelector(PayPalCommerceGateway.button.mini_cart_wrapper) &&
! document.querySelector(PayPalCommerceGateway.hosted_fields.wrapper)
) {
return;

View file

@ -11,11 +11,14 @@ class CartActionHandler {
configuration() {
const createOrder = (data, actions) => {
const payer = payerData();
const bnCode = typeof this.config.bn_codes[this.config.context] !== 'undefined' ?
this.config.bn_codes[this.config.context] : '';
return fetch(this.config.ajax.create_order.endpoint, {
method: 'POST',
body: JSON.stringify({
nonce: this.config.ajax.create_order.nonce,
purchase_units: [],
bn_code:bnCode,
payer
}),
}).then(function(res) {

View file

@ -12,11 +12,14 @@ class CheckoutActionHandler {
const createOrder = (data, actions) => {
const payer = payerData();
const bnCode = typeof this.config.bn_codes[this.config.context] !== 'undefined' ?
this.config.bn_codes[this.config.context] : '';
return fetch(this.config.ajax.create_order.endpoint, {
method: 'POST',
body: JSON.stringify({
nonce: this.config.ajax.create_order.nonce,
payer
payer,
bn_code:bnCode
})
}).then(function (res) {
return res.json();

View file

@ -75,12 +75,15 @@ class SingleProductActionHandler {
const onResolve = (purchase_units) => {
const payer = payerData();
const bnCode = typeof this.config.bn_codes[this.config.context] !== 'undefined' ?
this.config.bn_codes[this.config.context] : '';
return fetch(this.config.ajax.create_order.endpoint, {
method: 'POST',
body: JSON.stringify({
nonce: this.config.ajax.create_order.nonce,
purchase_units,
payer
payer,
bn_code:bnCode
})
}).then(function (res) {
return res.json();