-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AD-49 [FE][Express checkout] Add ApplePayExpress button on cart page
- Loading branch information
Showing
7 changed files
with
131 additions
and
8 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
...koutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen_express_checkout.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,93 @@ | ||
var AdyenExpressCheckoutHybris = (function () { | ||
'use strict'; | ||
|
||
|
||
return { | ||
|
||
initiateCheckout: async function (initConfig) { | ||
const configuration = { | ||
...initConfig, | ||
analytics: { | ||
enabled: false // Set to false to not send analytics data to Adyen. | ||
}, | ||
risk: { | ||
enabled: false | ||
}, | ||
onPaymentCompleted: (result, component) => { | ||
console.info(result, component); | ||
}, | ||
onError: (error, component) => { | ||
console.error(error.name, error.message, error.stack, component); | ||
}, | ||
}; | ||
|
||
return await AdyenCheckout(configuration); | ||
}, | ||
|
||
initiateApplePayExpress: async function (params, config) { | ||
var checkoutPromise = this.initiateCheckout(config); | ||
const {amount, countryCode, applePayMerchantIdentifier, applePayMerchantName, label} = params; | ||
const applePayNode = document.getElementById('adyen-component-button-container-' + label); | ||
const self = this; | ||
const applePayConfiguration = { | ||
//onValidateMerchant is required if you're using your own Apple Pay certificate | ||
onValidateMerchant: (resolve, reject, validationURL) => { | ||
resolve(); | ||
|
||
// Your server uses the validation URL to request a session from the Apple Pay server. | ||
// Call resolve(MERCHANTSESSION) or reject() to complete merchant validation. | ||
/*validateMerchant(validationURL) | ||
.then(response => { | ||
// Complete merchant validation with resolve(MERCHANTSESSION) after receiving an opaque merchant session object, MerchantSession | ||
resolve(response); | ||
}) | ||
.catch(error => { | ||
// Complete merchant validation with reject() if any error occurs | ||
reject(); | ||
});*/ | ||
} | ||
}; | ||
checkoutPromise.then((checkout) => { | ||
var applePayComponent = checkout.create("applepay", { | ||
amount: { | ||
currency: amount.currency, | ||
value: amount.value | ||
}, | ||
configuration: { | ||
merchantName: applePayMerchantName, | ||
merchantId: applePayMerchantIdentifier | ||
}, | ||
// Button config | ||
buttonType: "plain", | ||
buttonColor: "black", | ||
onChange: function(state, component) { | ||
console.log("Apple pay on change, state: ") | ||
console.log(state) | ||
}, | ||
onSubmit: function(state, component) { | ||
if (!state.isValid) { | ||
return false; | ||
} | ||
//TODO: implement payment call | ||
}, | ||
onShippingContactSelected: function(event){ | ||
var shippingAddress = event.shippingContact; | ||
//TODO: implement call with address | ||
console.log(shippingAddress); | ||
}, | ||
onClick: function(resolve, reject) { | ||
resolve(); | ||
} | ||
}); | ||
applePayComponent.isAvailable() | ||
.then(function () { | ||
applePayComponent.mount(applePayNode); | ||
}) | ||
.catch(function (e) { | ||
// Apple Pay is not available | ||
console.log('Something went wrong trying to mount the Apple Pay component: ' + e); | ||
}); | ||
}) | ||
} | ||
} | ||
})(); |
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
10 changes: 10 additions & 0 deletions
10
adyenv6b2ccheckoutaddon/resources/impex/projectdata-cms-config.impex
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,10 @@ | ||
$contentCatalog=electronicsContentCatalog | ||
$contentCVS=catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalog]),CatalogVersion.version[default=Staged])[default=$contentCatalog:Staged] | ||
$contentCVO=catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalog]),CatalogVersion.version[default=Online])[default=$contentCatalog:Online] | ||
|
||
INSERT_UPDATE JspIncludeComponent;uid[unique=true];page;$contentCVS[unique=true] | ||
;CartComponent;/WEB-INF/views/responsive/pages/cart/cartDisplay.jsp | ||
|
||
|
||
INSERT_UPDATE JspIncludeComponent;uid[unique=true];page;$contentCVO[unique=true] | ||
;CartComponent;/WEB-INF/views/responsive/pages/cart/cartDisplay.jsp |
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