-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from bold-commerce/CHK-5127
As a brand with Braintree Wallet pays enabled, I am a offered these w…
- Loading branch information
Showing
42 changed files
with
789 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
view/frontend/web/js/action/create-wallet-pay-order-action.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
4 changes: 1 addition & 3 deletions
4
.../web/js/action/convert-magento-address.js → ...ess-pay/convert-magento-address-action.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
view/frontend/web/js/action/express-pay/create-wallet-pay-order-action.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
define( | ||
[ | ||
'Bold_CheckoutPaymentBooster/js/model/platform-client' | ||
], | ||
function ( | ||
platformClient | ||
) { | ||
'use strict'; | ||
|
||
/** | ||
* Create Wallet Pay order. | ||
* | ||
* @param {{}} | ||
* @return {Promise} | ||
*/ | ||
return async function (paymentPayload) { | ||
return platformClient.post( | ||
'rest/V1/express_pay/order/create', | ||
{ | ||
quoteMaskId: window.checkoutConfig.quoteData.entity_id, | ||
gatewayId: paymentPayload.gateway_id, | ||
shippingStrategy: paymentPayload.shipping_strategy || 'dynamic' | ||
} | ||
); | ||
}; | ||
}); |
File renamed without changes.
75 changes: 75 additions & 0 deletions
75
view/frontend/web/js/action/express-pay/get-required-order-data-action.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
define( | ||
[ | ||
'Magento_Checkout/js/model/quote', | ||
'Magento_Checkout/js/checkout-data', | ||
'Magento_Checkout/js/model/shipping-service', | ||
'Bold_CheckoutPaymentBooster/js/action/express-pay/convert-magento-address-action' | ||
], | ||
function ( | ||
quote, | ||
checkoutData, | ||
shippingService, | ||
convertMagentoAddressAction | ||
) { | ||
'use strict'; | ||
|
||
/** | ||
* Get required order data for express pay. | ||
* | ||
* @return {Promise} | ||
*/ | ||
return function (requirements) { | ||
const payload = {}; | ||
|
||
for (const requirement of requirements) { | ||
switch (requirement) { | ||
case 'customer': | ||
let billingAddress = quote.billingAddress(); | ||
const email = checkoutData.getValidatedEmailValue() | ||
? checkoutData.getValidatedEmailValue() | ||
: window.checkoutConfig.customerData.email; | ||
|
||
payload[requirement] = { | ||
first_name: billingAddress.firstname, | ||
last_name: billingAddress.lastname, | ||
email_address: email, | ||
}; | ||
break; | ||
case 'items': | ||
payload[requirement] = quote.getItems().map(item => ({ | ||
amount: parseInt(parseFloat(item.base_price) * 100), | ||
label: item.name | ||
})); | ||
break; | ||
case 'billing_address': | ||
payload[requirement] = convertMagentoAddressAction(quote.billingAddress()); | ||
break; | ||
case 'shipping_address': | ||
payload[requirement] = convertMagentoAddressAction(quote.shippingAddress()); | ||
break; | ||
case 'shipping_options': | ||
payload[requirement] = shippingService.getShippingRates().map(option => ({ | ||
label: `${option.carrier_title} - ${option.method_title}`, | ||
amount: parseFloat(option.amount) * 100, | ||
id: `${option.carrier_code}_${option.method_code}`, | ||
is_selected: option.carrier_code === quote.shippingMethod()?.carrier_code && | ||
option.method_code === quote.shippingMethod()?.method_code | ||
})); | ||
break; | ||
case 'totals': | ||
const totals = quote.getTotals(); | ||
payload[requirement] = { | ||
order_total: parseFloat(totals()['grand_total'] || 0) * 100, | ||
order_balance: parseFloat(totals()['grand_total'] || 0) * 100, | ||
shipping_total: parseFloat(totals()['shipping_amount'] || 0) * 100, | ||
discounts_total: parseFloat(totals()['discount_amount'] || 0) * 100, | ||
fees_total: parseFloat(totals()['fee_amount'] || 0) * 100, | ||
taxes_total: parseFloat(totals()['tax'] || 0) * 100, | ||
}; | ||
break; | ||
} | ||
} | ||
return payload; | ||
}; | ||
} | ||
); |
File renamed without changes.
45 changes: 45 additions & 0 deletions
45
view/frontend/web/js/action/express-pay/save-shipping-information-action.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
define( | ||
[ | ||
'Magento_Checkout/js/model/quote', | ||
'mage/storage', | ||
'Magento_Checkout/js/model/resource-url-manager', | ||
'Magento_Checkout/js/model/shipping-save-processor/payload-extender', | ||
'Magento_Checkout/js/model/error-processor' | ||
], | ||
function ( | ||
quote, | ||
storage, | ||
resourceUrlManager, | ||
payloadExtender, | ||
errorProcessor | ||
) { | ||
'use strict'; | ||
|
||
/** | ||
* Save shipping information. | ||
* | ||
* @param {Boolean} saveBillingAddress - Save billing address with shipping information. | ||
* @return {Deferred} | ||
*/ | ||
return function (saveBillingAddress = false) { | ||
let payload; | ||
payload = { | ||
addressInformation: { | ||
'shipping_address': quote.shippingAddress(), | ||
'shipping_method_code': quote.shippingMethod() ? quote.shippingMethod()['method_code'] : null, | ||
'shipping_carrier_code': quote.shippingMethod() ? quote.shippingMethod()['carrier_code'] : null, | ||
} | ||
}; | ||
if (saveBillingAddress) { | ||
payload.addressInformation.billing_address = quote.billingAddress(); | ||
} | ||
payloadExtender(payload); | ||
return storage.post( | ||
resourceUrlManager.getUrlForSetShippingInformation(quote), | ||
JSON.stringify(payload) | ||
).fail((response) => { | ||
errorProcessor.process(response); | ||
}); | ||
} | ||
} | ||
); |
Oops, something went wrong.