@graphcommerce/magento-payment-multisafepay 9.1.0-canary.54 → 9.1.0-canary.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @graphcommerce/magento-payment-multisafepay
2
2
 
3
+ ## 9.1.0-canary.55
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2539](https://github.com/graphcommerce-org/graphcommerce/pull/2539) [`21dc35d`](https://github.com/graphcommerce-org/graphcommerce/commit/21dc35d09521f47b7f91dc868ca776603e2da4a2) - Solve issue where the cart would remain locked if a user would return to the website without going through the checkout/payment step. ([@paales](https://github.com/paales))
8
+
9
+ - [#2539](https://github.com/graphcommerce-org/graphcommerce/pull/2539) [`6a55be4`](https://github.com/graphcommerce-org/graphcommerce/commit/6a55be43ab1f53eb689abf8ad742383daf65822e) - Solve issue where the MSPPaymentHandler query would be executed multiple times. ([@paales](https://github.com/paales))
10
+
3
11
  ## 9.1.0-canary.54
4
12
 
5
13
  ## 9.1.0-canary.53
@@ -14,11 +14,12 @@ export function MSPPaymentHandler(props: PaymentHandlerProps) {
14
14
  const assignCurrentCartId = useAssignCurrentCartId()
15
15
  const { onSuccess } = usePaymentMethodContext()
16
16
 
17
- const [restore, { error }] = useMutation(MSPPaymentHandlerDocument)
17
+ const [restore, { error, called }] = useMutation(MSPPaymentHandlerDocument)
18
18
 
19
19
  const { justLocked, success, cart_id: cartId, locked, method, order_number } = lockStatus
20
20
 
21
- const canProceed = !(justLocked || !locked || !cartId || method !== code)
21
+ const canProceed =
22
+ !justLocked && locked && cartId && method === code && !called && success !== '1'
22
23
 
23
24
  // When the payment has failed we restore the current cart
24
25
  const shouldRestore = canProceed && success !== '1'
@@ -0,0 +1,64 @@
1
+ import { ApolloErrorSnackbar } from '@graphcommerce/ecommerce-ui'
2
+ import { useMutation, useQuery } from '@graphcommerce/graphql'
3
+ import { useAssignCurrentCartId, useCartQuery } from '@graphcommerce/magento-cart'
4
+ import { BillingPageDocument } from '@graphcommerce/magento-cart-checkout'
5
+ import { CurrentCartIdDocument } from '@graphcommerce/magento-cart/hooks/CurrentCartId.gql'
6
+ import { Button, FullPageMessage, iconShoppingBag, IconSvg } from '@graphcommerce/next-ui'
7
+ import { Trans } from '@lingui/react'
8
+ import dynamic from 'next/dynamic'
9
+ import { useRouter } from 'next/router'
10
+ import { useMSPCartLock } from '../../hooks/useMSPCartLock'
11
+ import { MSPPaymentHandlerDocument } from '../MSPPaymentHandler/MSPPaymentHandler.gql'
12
+
13
+ const DialogDynamic = dynamic(() => import('@mui/material').then((mod) => mod.Dialog), {
14
+ ssr: false,
15
+ })
16
+
17
+ export function MSPRestoreLocked() {
18
+ const [, , unlock] = useMSPCartLock()
19
+ const assignCurrentCartId = useAssignCurrentCartId()
20
+ const router = useRouter()
21
+
22
+ const [restore, { loading, error }] = useMutation(MSPPaymentHandlerDocument)
23
+ const status = useQuery(CurrentCartIdDocument).data?.currentCartId
24
+ const { locked } = status ?? {}
25
+ const cart = useCartQuery(BillingPageDocument)
26
+ const cartId = cart.data?.cart?.id
27
+ const isMsp = cart.data?.cart?.selected_payment_method?.code.startsWith('multisafepay_')
28
+ const isPaymentPage = router.pathname.startsWith('/checkout/payment')
29
+ const shouldRestore = locked && cartId && isMsp && !isPaymentPage
30
+
31
+ return (
32
+ <>
33
+ <ApolloErrorSnackbar error={error} />
34
+ {isMsp && (
35
+ <DialogDynamic open={Boolean(shouldRestore)} fullWidth>
36
+ <FullPageMessage
37
+ disableMargin
38
+ icon={<IconSvg src={iconShoppingBag} />}
39
+ title={<Trans id='Your cart is locked.' />}
40
+ button={
41
+ <Button
42
+ variant='pill'
43
+ onClick={async () => {
44
+ if (!cartId) return
45
+ const res = await restore({ variables: { cartId } })
46
+ if (!res.data?.getPaymentMeta) return
47
+ assignCurrentCartId(res.data.getPaymentMeta)
48
+ await unlock({ success: null })
49
+ }}
50
+ loading={loading}
51
+ >
52
+ <Trans id='Cancel payment and unlock cart' />
53
+ </Button>
54
+ }
55
+ >
56
+ <Trans id='1. You are still paying in another window: Close this window and continue there.' />
57
+ <br />
58
+ <Trans id="2. You don't have an open payment window: Press the button below." />
59
+ </FullPageMessage>
60
+ </DialogDynamic>
61
+ )}
62
+ </>
63
+ )
64
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-payment-multisafepay",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "9.1.0-canary.54",
5
+ "version": "9.1.0-canary.55",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,22 +12,22 @@
12
12
  }
13
13
  },
14
14
  "peerDependencies": {
15
- "@graphcommerce/ecommerce-ui": "^9.1.0-canary.54",
16
- "@graphcommerce/eslint-config-pwa": "^9.1.0-canary.54",
17
- "@graphcommerce/graphql": "^9.1.0-canary.54",
18
- "@graphcommerce/graphql-mesh": "^9.1.0-canary.54",
19
- "@graphcommerce/image": "^9.1.0-canary.54",
20
- "@graphcommerce/magento-cart": "^9.1.0-canary.54",
21
- "@graphcommerce/magento-cart-checkout": "^9.1.0-canary.54",
22
- "@graphcommerce/magento-cart-payment-method": "^9.1.0-canary.54",
23
- "@graphcommerce/magento-cart-shipping-address": "^9.1.0-canary.54",
24
- "@graphcommerce/magento-product": "^9.1.0-canary.54",
25
- "@graphcommerce/magento-product-configurable": "^9.1.0-canary.54",
26
- "@graphcommerce/magento-store": "^9.1.0-canary.54",
27
- "@graphcommerce/next-ui": "^9.1.0-canary.54",
28
- "@graphcommerce/prettier-config-pwa": "^9.1.0-canary.54",
29
- "@graphcommerce/react-hook-form": "^9.1.0-canary.54",
30
- "@graphcommerce/typescript-config-pwa": "^9.1.0-canary.54",
15
+ "@graphcommerce/ecommerce-ui": "^9.1.0-canary.55",
16
+ "@graphcommerce/eslint-config-pwa": "^9.1.0-canary.55",
17
+ "@graphcommerce/graphql": "^9.1.0-canary.55",
18
+ "@graphcommerce/graphql-mesh": "^9.1.0-canary.55",
19
+ "@graphcommerce/image": "^9.1.0-canary.55",
20
+ "@graphcommerce/magento-cart": "^9.1.0-canary.55",
21
+ "@graphcommerce/magento-cart-checkout": "^9.1.0-canary.55",
22
+ "@graphcommerce/magento-cart-payment-method": "^9.1.0-canary.55",
23
+ "@graphcommerce/magento-cart-shipping-address": "^9.1.0-canary.55",
24
+ "@graphcommerce/magento-product": "^9.1.0-canary.55",
25
+ "@graphcommerce/magento-product-configurable": "^9.1.0-canary.55",
26
+ "@graphcommerce/magento-store": "^9.1.0-canary.55",
27
+ "@graphcommerce/next-ui": "^9.1.0-canary.55",
28
+ "@graphcommerce/prettier-config-pwa": "^9.1.0-canary.55",
29
+ "@graphcommerce/react-hook-form": "^9.1.0-canary.55",
30
+ "@graphcommerce/typescript-config-pwa": "^9.1.0-canary.55",
31
31
  "@lingui/core": "^4.2.1",
32
32
  "@lingui/macro": "^4.2.1",
33
33
  "@lingui/react": "^4.2.1",
@@ -0,0 +1,18 @@
1
+ import type { PagesProps } from '@graphcommerce/framer-next-pages'
2
+ import type { PluginConfig, PluginProps } from '@graphcommerce/next-config'
3
+ import { MSPRestoreLocked } from '../components/MSPRestoreLocked/MSPRestoreLocked'
4
+
5
+ export const config: PluginConfig = {
6
+ module: '@graphcommerce/framer-next-pages',
7
+ type: 'component',
8
+ }
9
+
10
+ export function FramerNextPages(props: PluginProps<PagesProps>) {
11
+ const { Prev, ...rest } = props
12
+ return (
13
+ <>
14
+ <Prev {...rest} />
15
+ <MSPRestoreLocked />
16
+ </>
17
+ )
18
+ }