@graphcommerce/mollie-magento-payment 9.0.1-canary.0 → 9.0.1-canary.2

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,80 +1,28 @@
1
1
  # Change Log
2
2
 
3
- ## 9.0.1-canary.0
4
-
5
- ## 9.0.0
3
+ ## 9.0.1-canary.2
6
4
 
7
5
  ### Patch Changes
8
6
 
9
- - [#2341](https://github.com/graphcommerce-org/graphcommerce/pull/2341) [`86ecf9a`](https://github.com/graphcommerce-org/graphcommerce/commit/86ecf9a1bb4c48ceabd4944d81483bcd5b990350) - Payment method will now throw an error in `onComplete` to handle obscure errors. ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
10
-
11
- - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`530076e`](https://github.com/graphcommerce-org/graphcommerce/commit/530076e3664703cb8b577b7fcf1998a420819f60) - Moved all usages of `useFormPersist` to the `<FormPersist/>` component to prevent rerenders. ([@FrankHarland](https://github.com/FrankHarland))
12
-
13
- - [#2331](https://github.com/graphcommerce-org/graphcommerce/pull/2331) [`702bfc9`](https://github.com/graphcommerce-org/graphcommerce/commit/702bfc93566c9745546988e57988431d5d4d8cb0) - Moved plugins to new format ([@paales](https://github.com/paales))
14
-
15
- - [#2305](https://github.com/graphcommerce-org/graphcommerce/pull/2305) [`77e8297`](https://github.com/graphcommerce-org/graphcommerce/commit/77e82976816994336c616208a651cb18ce9ea270) - Fix bug with persist not applying saved changes by moving `<FromPersist/>` below the form components. ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
16
-
17
- - [#2438](https://github.com/graphcommerce-org/graphcommerce/pull/2438) [`cb8d2f0`](https://github.com/graphcommerce-org/graphcommerce/commit/cb8d2f0059d64242260e30ce34655868f204ef4c) - Made all component prop types exported ([@bramvanderholst](https://github.com/bramvanderholst))
18
-
19
- ## 9.0.0-canary.118
7
+ - [#2465](https://github.com/graphcommerce-org/graphcommerce/pull/2465) [`32fb7da`](https://github.com/graphcommerce-org/graphcommerce/commit/32fb7dab88273df94061ea28c8e5171f065e6d1d) - Support Magento 2.4.7 placeOrder.errors field when placing a Mollie order ([@paales](https://github.com/paales))
20
8
 
21
- ## 9.0.0-canary.117
9
+ ## 9.0.1-canary.1
22
10
 
23
- ## 9.0.0-canary.116
24
-
25
- ## 9.0.0-canary.115
26
-
27
- ## 9.0.0-canary.114
28
-
29
- ## 9.0.0-canary.113
30
-
31
- ## 9.0.0-canary.112
32
-
33
- ## 9.0.0-canary.111
34
-
35
- ## 9.0.0-canary.110
36
-
37
- ## 9.0.0-canary.109
38
-
39
- ## 9.0.0-canary.108
40
-
41
- ### Patch Changes
42
-
43
- - [#2438](https://github.com/graphcommerce-org/graphcommerce/pull/2438) [`cb8d2f0`](https://github.com/graphcommerce-org/graphcommerce/commit/cb8d2f0059d64242260e30ce34655868f204ef4c) - Made all component prop types exported ([@bramvanderholst](https://github.com/bramvanderholst))
44
-
45
- ## 9.0.0-canary.107
46
-
47
- ## 9.0.0-canary.106
48
-
49
- ## 9.0.0-canary.105
50
-
51
- ## 9.0.0-canary.104
11
+ ## 9.0.0
52
12
 
53
- ## 9.0.0-canary.103
13
+ ### Major Changes
54
14
 
55
- ## 9.0.0-canary.80
15
+ - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`530076e`](https://github.com/graphcommerce-org/graphcommerce/commit/530076e3664703cb8b577b7fcf1998a420819f60) - INP improvements: Moved all usages of `useFormPersist` to the `<FormPersist/>` component to prevent rerenders. ([@FrankHarland](https://github.com/FrankHarland))
56
16
 
57
17
  ### Patch Changes
58
18
 
59
- - [#2341](https://github.com/graphcommerce-org/graphcommerce/pull/2341) [`86ecf9a`](https://github.com/graphcommerce-org/graphcommerce/commit/86ecf9a1bb4c48ceabd4944d81483bcd5b990350) - Payment method will now throw an error in onComplete to handle obscure errors ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
60
-
61
- ## 9.0.0-canary.60
62
-
63
- ### Patch Changes
19
+ - [#2341](https://github.com/graphcommerce-org/graphcommerce/pull/2341) [`86ecf9a`](https://github.com/graphcommerce-org/graphcommerce/commit/86ecf9a1bb4c48ceabd4944d81483bcd5b990350) - Payment method will now throw an error in `onComplete` to handle obscure errors. ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
64
20
 
65
21
  - [#2331](https://github.com/graphcommerce-org/graphcommerce/pull/2331) [`702bfc9`](https://github.com/graphcommerce-org/graphcommerce/commit/702bfc93566c9745546988e57988431d5d4d8cb0) - Moved plugins to new format ([@paales](https://github.com/paales))
66
22
 
67
- ## 8.1.0-canary.38
68
-
69
- ### Patch Changes
70
-
71
- - [#2305](https://github.com/graphcommerce-org/graphcommerce/pull/2305) [`77e8297`](https://github.com/graphcommerce-org/graphcommerce/commit/77e82976816994336c616208a651cb18ce9ea270) - Fix bug with persist not applying saved changes by moving <FromPersist/> below the form components ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
72
-
73
- ## 8.0.6-canary.2
74
-
75
- ### Patch Changes
23
+ - [#2305](https://github.com/graphcommerce-org/graphcommerce/pull/2305) [`77e8297`](https://github.com/graphcommerce-org/graphcommerce/commit/77e82976816994336c616208a651cb18ce9ea270) - Fix bug with persist not applying saved changes by moving `<FromPersist/>` below the form components. ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
76
24
 
77
- - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`530076e`](https://github.com/graphcommerce-org/graphcommerce/commit/530076e3664703cb8b577b7fcf1998a420819f60) - Moved all usages of useFormPersist to the <FormPersist/> component to prevent rerenders. ([@FrankHarland](https://github.com/FrankHarland))
25
+ - [#2438](https://github.com/graphcommerce-org/graphcommerce/pull/2438) [`cb8d2f0`](https://github.com/graphcommerce-org/graphcommerce/commit/cb8d2f0059d64242260e30ce34655868f204ef4c) - Made all component prop types exported ([@bramvanderholst](https://github.com/bramvanderholst))
78
26
 
79
27
  ## 8.0.0
80
28
 
@@ -1,5 +1,10 @@
1
1
  mutation MolliePlaceOrder($cartId: String!, $returnUrl: String!) {
2
2
  placeOrder(input: { cart_id: $cartId, mollie_return_url: $returnUrl }) {
3
+ errors {
4
+ code
5
+ message
6
+ }
7
+
3
8
  order {
4
9
  order_number
5
10
  mollie_redirect_url
@@ -1,9 +1,9 @@
1
1
  import { useFormGqlMutationCart } from '@graphcommerce/magento-cart'
2
- import type { PaymentPlaceOrderProps } from '@graphcommerce/magento-cart-payment-method'
2
+ import { type PaymentPlaceOrderProps } from '@graphcommerce/magento-cart-payment-method'
3
3
  import { useFormCompose } from '@graphcommerce/react-hook-form'
4
- import { t } from '@lingui/macro'
5
4
  import { useRouter } from 'next/router'
6
5
  import { useCartLockWithToken } from '../../hooks/useCartLockWithToken'
6
+ import { assertMollieOrderPlaced } from './assertMollieOrderPlaced'
7
7
  import { MolliePlaceOrderDocument } from './MolliePlaceOrder.gql'
8
8
 
9
9
  export function MolliePlaceOrder(props: PaymentPlaceOrderProps) {
@@ -27,21 +27,15 @@ export function MolliePlaceOrder(props: PaymentPlaceOrderProps) {
27
27
 
28
28
  return { ...variables, returnUrl }
29
29
  },
30
- onComplete: async ({ data, errors }) => {
31
- if (!data?.placeOrder?.order || errors) return
30
+ onComplete: async (result) => {
31
+ assertMollieOrderPlaced(result)
32
32
 
33
- const { mollie_redirect_url, mollie_payment_token, order_number } = data.placeOrder.order
33
+ const { mollie_payment_token, order_number, mollie_redirect_url } =
34
+ result.data.placeOrder.order
34
35
 
35
- // When redirecting to the payment gateway
36
- if (mollie_redirect_url && mollie_payment_token) {
37
- await lock({ mollie_payment_token, method: code, order_number })
38
-
39
- await push(mollie_redirect_url)
40
- } else {
41
- throw Error(
42
- t`An error occurred while processing your payment. Please contact the store owner`,
43
- )
44
- }
36
+ // Redirect to the payment gateway
37
+ await lock({ mollie_payment_token, method: code, order_number })
38
+ await push(mollie_redirect_url)
45
39
  },
46
40
  })
47
41
 
@@ -0,0 +1,33 @@
1
+ import { type FetchResult } from '@graphcommerce/graphql'
2
+ import type { AssertedOrderPlaced, PlacedOrder } from '@graphcommerce/magento-cart-payment-method'
3
+ import {
4
+ assertOrderPlaced,
5
+ throwGenericPlaceOrderError,
6
+ } from '@graphcommerce/magento-cart-payment-method'
7
+ import type { MolliePlaceOrderMutation } from './MolliePlaceOrder.gql'
8
+
9
+ /** Assert that the order was place successfully. */
10
+ export function assertMollieOrderPlaced<T extends FetchResult<MolliePlaceOrderMutation>>(
11
+ result: T,
12
+ ): asserts result is AssertedOrderPlaced<T> & {
13
+ data: {
14
+ placeOrder: {
15
+ order: PlacedOrder<T> & {
16
+ mollie_redirect_url: NonNullable<PlacedOrder<T>['mollie_redirect_url']>
17
+ mollie_payment_token: NonNullable<PlacedOrder<T>['mollie_payment_token']>
18
+ }
19
+ }
20
+ }
21
+ } {
22
+ assertOrderPlaced(result)
23
+
24
+ const { mollie_redirect_url, mollie_payment_token } = result.data.placeOrder.order
25
+
26
+ if (!mollie_redirect_url || !mollie_payment_token) {
27
+ console.error(
28
+ 'Mollie: Order was placed, but no redirect url or payment token was returned, this is an issue on the Magento Mollie side.',
29
+ result,
30
+ )
31
+ throwGenericPlaceOrderError()
32
+ }
33
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/mollie-magento-payment",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "9.0.1-canary.0",
5
+ "version": "9.0.1-canary.2",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,21 +12,21 @@
12
12
  }
13
13
  },
14
14
  "peerDependencies": {
15
- "@graphcommerce/ecommerce-ui": "^9.0.1-canary.0",
16
- "@graphcommerce/eslint-config-pwa": "^9.0.1-canary.0",
17
- "@graphcommerce/graphql": "^9.0.1-canary.0",
18
- "@graphcommerce/graphql-mesh": "^9.0.1-canary.0",
19
- "@graphcommerce/image": "^9.0.1-canary.0",
20
- "@graphcommerce/magento-cart": "^9.0.1-canary.0",
21
- "@graphcommerce/magento-cart-payment-method": "^9.0.1-canary.0",
22
- "@graphcommerce/magento-cart-shipping-address": "^9.0.1-canary.0",
23
- "@graphcommerce/magento-product": "^9.0.1-canary.0",
24
- "@graphcommerce/magento-product-configurable": "^9.0.1-canary.0",
25
- "@graphcommerce/magento-store": "^9.0.1-canary.0",
26
- "@graphcommerce/next-ui": "^9.0.1-canary.0",
27
- "@graphcommerce/prettier-config-pwa": "^9.0.1-canary.0",
28
- "@graphcommerce/react-hook-form": "^9.0.1-canary.0",
29
- "@graphcommerce/typescript-config-pwa": "^9.0.1-canary.0",
15
+ "@graphcommerce/ecommerce-ui": "^9.0.1-canary.2",
16
+ "@graphcommerce/eslint-config-pwa": "^9.0.1-canary.2",
17
+ "@graphcommerce/graphql": "^9.0.1-canary.2",
18
+ "@graphcommerce/graphql-mesh": "^9.0.1-canary.2",
19
+ "@graphcommerce/image": "^9.0.1-canary.2",
20
+ "@graphcommerce/magento-cart": "^9.0.1-canary.2",
21
+ "@graphcommerce/magento-cart-payment-method": "^9.0.1-canary.2",
22
+ "@graphcommerce/magento-cart-shipping-address": "^9.0.1-canary.2",
23
+ "@graphcommerce/magento-product": "^9.0.1-canary.2",
24
+ "@graphcommerce/magento-product-configurable": "^9.0.1-canary.2",
25
+ "@graphcommerce/magento-store": "^9.0.1-canary.2",
26
+ "@graphcommerce/next-ui": "^9.0.1-canary.2",
27
+ "@graphcommerce/prettier-config-pwa": "^9.0.1-canary.2",
28
+ "@graphcommerce/react-hook-form": "^9.0.1-canary.2",
29
+ "@graphcommerce/typescript-config-pwa": "^9.0.1-canary.2",
30
30
  "@lingui/core": "^4.2.1",
31
31
  "@lingui/macro": "^4.2.1",
32
32
  "@lingui/react": "^4.2.1",