From f39790d0f41fd90d5562dcbf0d91350bd69a58c1 Mon Sep 17 00:00:00 2001 From: Hassan Goodarzi Date: Thu, 12 Sep 2024 14:14:45 +0330 Subject: [PATCH 1/9] Completed Klarna payment method integration --- .../KlarnaPaymentMethod.graphql | 12 -- packages/magento-payment-klarna/README.md | 2 - .../KlarnaPaymentActionCard.tsx | 26 ++++ .../KlarnaPaymentOptions.graphql} | 2 +- .../KlarnaPaymentOptions.tsx | 50 ++++++++ .../KlarnaPaymentPlaceOrder.graphql | 12 ++ .../KlarnaPaymentPlaceOrder.tsx | 116 ++++++++++++++++++ .../hooks/useKlarnaCartLock.ts | 15 +++ .../magento-payment-klarna/icons/klarna.png | Bin 0 -> 47934 bytes .../plugins/AddKlarnaMethods.tsx | 21 ++++ 10 files changed, 241 insertions(+), 15 deletions(-) delete mode 100644 packages/magento-payment-klarna/KlarnaPaymentMethod.graphql create mode 100644 packages/magento-payment-klarna/components/KlarnaPaymentActionCard/KlarnaPaymentActionCard.tsx rename packages/magento-payment-klarna/{KlarnaPaymentSession.graphql => components/KlarnaPaymentOptions/KlarnaPaymentOptions.graphql} (81%) create mode 100644 packages/magento-payment-klarna/components/KlarnaPaymentOptions/KlarnaPaymentOptions.tsx create mode 100644 packages/magento-payment-klarna/components/KlarnaPaymentPlaceOrder/KlarnaPaymentPlaceOrder.graphql create mode 100644 packages/magento-payment-klarna/components/KlarnaPaymentPlaceOrder/KlarnaPaymentPlaceOrder.tsx create mode 100644 packages/magento-payment-klarna/hooks/useKlarnaCartLock.ts create mode 100644 packages/magento-payment-klarna/icons/klarna.png create mode 100644 packages/magento-payment-klarna/plugins/AddKlarnaMethods.tsx diff --git a/packages/magento-payment-klarna/KlarnaPaymentMethod.graphql b/packages/magento-payment-klarna/KlarnaPaymentMethod.graphql deleted file mode 100644 index 52c24adf6f..0000000000 --- a/packages/magento-payment-klarna/KlarnaPaymentMethod.graphql +++ /dev/null @@ -1,12 +0,0 @@ -mutation KlarnaPaymentMethod($cartId: String!, $authorizationToken: String!) { - setPaymentMethodOnCart( - input: { - cart_id: $cartId - payment_method: { code: "klarna", klarna: { authorization_token: $authorizationToken } } - } - ) { - cart { - ...PaymentMethodUpdated - } - } -} diff --git a/packages/magento-payment-klarna/README.md b/packages/magento-payment-klarna/README.md index 2d8280606f..e04694a295 100644 --- a/packages/magento-payment-klarna/README.md +++ b/packages/magento-payment-klarna/README.md @@ -2,8 +2,6 @@ Integrates GraphCommerce with the Magento Klarna module. -Note: Not yet working - ## Installation 1. Find current version of your `@graphcommerce/magento-cart-payment-method` in diff --git a/packages/magento-payment-klarna/components/KlarnaPaymentActionCard/KlarnaPaymentActionCard.tsx b/packages/magento-payment-klarna/components/KlarnaPaymentActionCard/KlarnaPaymentActionCard.tsx new file mode 100644 index 0000000000..ae55b55e9c --- /dev/null +++ b/packages/magento-payment-klarna/components/KlarnaPaymentActionCard/KlarnaPaymentActionCard.tsx @@ -0,0 +1,26 @@ +import Script from 'next/script' +import { Image } from '@graphcommerce/image' +import { PaymentMethodActionCardProps } from '@graphcommerce/magento-cart-payment-method' +import { ActionCard, useIconSvgSize } from '@graphcommerce/next-ui' +import klarnaMark from '../../icons/klarna.png' + +export function KlarnaPaymentActionCard(props: PaymentMethodActionCardProps) { + const iconSize = useIconSvgSize('large') + + return ( + <> +