Skip to content

Commit

Permalink
feat: handle amazon session id to make a payment
Browse files Browse the repository at this point in the history
  • Loading branch information
amihajlovski committed Nov 7, 2023
1 parent d4c4b74 commit eb597fe
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions adyen/components/AdyenCheckout.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const AdyenCheckoutComponent = (props) => {
useEffect(() => {
const urlParams = new URLSearchParams(location.search)
const redirectResult = urlParams.get('redirectResult')
const amazonCheckoutSessionId = urlParams.get('amazonCheckoutSessionId')
console.log(amazonCheckoutSessionId)

const createCheckout = async () => {
const paymentMethodsConfiguration = await getPaymentMethodsConfiguration(props)
const checkout = await AdyenCheckout({
Expand All @@ -19,6 +22,7 @@ const AdyenCheckoutComponent = (props) => {
paymentMethodsResponse: adyenPaymentMethods,
paymentMethodsConfiguration: paymentMethodsConfiguration,
onSubmit(state, element) {
console.log('onsubmit', state)
paymentMethodsConfiguration.card.onSubmit(state, element)
},
onAdditionalDetails(state, element) {
Expand All @@ -33,6 +37,14 @@ const AdyenCheckoutComponent = (props) => {

if (redirectResult) {
checkout.submitDetails({data: {details: {redirectResult}}})
} else if (amazonCheckoutSessionId) {
const amazonPay = checkout
.create('amazonpay', {
amazonCheckoutSessionId,
showOrderButton: false
})
.mount('body')
amazonPay.submit()
} else {
checkout.create('dropin').mount(paymentContainer.current)
}
Expand Down

0 comments on commit eb597fe

Please sign in to comment.