@graphcommerce/magento-payment-paypal 9.0.1 → 9.0.2-canary.0
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
|
@@ -2,7 +2,10 @@ import { ApolloErrorSnackbar } from '@graphcommerce/ecommerce-ui'
|
|
|
2
2
|
import { useMutation } from '@graphcommerce/graphql'
|
|
3
3
|
import { useCurrentCartId } from '@graphcommerce/magento-cart'
|
|
4
4
|
import type { PaymentHandlerProps } from '@graphcommerce/magento-cart-payment-method'
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
assertOrderPlaced,
|
|
7
|
+
usePaymentMethodContext,
|
|
8
|
+
} from '@graphcommerce/magento-cart-payment-method'
|
|
6
9
|
import { useRouter } from 'next/router'
|
|
7
10
|
import { useEffect } from 'react'
|
|
8
11
|
import { usePayPalCartLock } from '../../hooks/usePayPalCartLock'
|
|
@@ -41,15 +44,15 @@ export function PayPalPaymentHandler(props: PaymentHandlerProps) {
|
|
|
41
44
|
if (!cartId) return
|
|
42
45
|
|
|
43
46
|
const fetchData = async () => {
|
|
44
|
-
const
|
|
47
|
+
const result = await placeOrder()
|
|
45
48
|
|
|
46
|
-
|
|
49
|
+
try {
|
|
50
|
+
assertOrderPlaced(result)
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
52
|
+
onSuccess(result.data.placeOrder.order.order_number)
|
|
53
|
+
} catch (e) {
|
|
47
54
|
await unlock({ token: null, PayerID: null })
|
|
48
|
-
return
|
|
49
55
|
}
|
|
50
|
-
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
52
|
-
onSuccess(res.data?.placeOrder?.order.order_number)
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { useFormCompose } from '@graphcommerce/ecommerce-ui'
|
|
2
2
|
import { useFormGqlMutationCart } from '@graphcommerce/magento-cart'
|
|
3
|
-
import
|
|
3
|
+
import {
|
|
4
|
+
assertOrderPlaced,
|
|
5
|
+
type PaymentPlaceOrderProps,
|
|
6
|
+
} from '@graphcommerce/magento-cart-payment-method'
|
|
7
|
+
import { ApolloError } from '@apollo/client'
|
|
8
|
+
import { GraphQLError } from 'graphql'
|
|
4
9
|
import { useRouter } from 'next/router'
|
|
5
10
|
import { usePayPalCartLock } from '../../hooks/usePayPalCartLock'
|
|
6
11
|
import { PayPalPaymentPlaceOrderDocument } from './PayPalPaymentPlaceOrder.gql'
|
|
@@ -17,15 +22,16 @@ export function PayPalPaymentPlaceOrder(props: PaymentPlaceOrderProps) {
|
|
|
17
22
|
urls: { cancel_url: 'checkout/payment', return_url: 'checkout/payment' },
|
|
18
23
|
}),
|
|
19
24
|
onComplete: async (result) => {
|
|
20
|
-
if (result.errors) return
|
|
25
|
+
if (result.errors && result.errors.length > 0) return
|
|
21
26
|
|
|
22
27
|
const start = result.data?.createPaypalExpressToken?.paypal_urls?.start
|
|
23
28
|
const token = result.data?.createPaypalExpressToken?.token
|
|
24
29
|
|
|
25
|
-
if (!start)
|
|
26
|
-
|
|
27
|
-
'Error while starting the PayPal payment, please try again with a different payment method'
|
|
28
|
-
)
|
|
30
|
+
if (!start) {
|
|
31
|
+
const message =
|
|
32
|
+
'Error while starting the PayPal payment, please try again with a different payment method'
|
|
33
|
+
throw new ApolloError({ graphQLErrors: [{ message }] })
|
|
34
|
+
}
|
|
29
35
|
|
|
30
36
|
await lock({ token, method: code, PayerID: null })
|
|
31
37
|
// We are going to redirect, but we're not waiting, because we need to complete the submission to release the buttons
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/magento-payment-paypal",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "9.0.
|
|
5
|
+
"version": "9.0.2-canary.0",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,16 +12,16 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/ecommerce-ui": "^9.0.
|
|
16
|
-
"@graphcommerce/eslint-config-pwa": "^9.0.
|
|
17
|
-
"@graphcommerce/graphql": "^9.0.
|
|
18
|
-
"@graphcommerce/image": "^9.0.
|
|
19
|
-
"@graphcommerce/magento-cart": "^9.0.
|
|
20
|
-
"@graphcommerce/magento-cart-payment-method": "^9.0.
|
|
21
|
-
"@graphcommerce/magento-store": "^9.0.
|
|
22
|
-
"@graphcommerce/next-ui": "^9.0.
|
|
23
|
-
"@graphcommerce/prettier-config-pwa": "^9.0.
|
|
24
|
-
"@graphcommerce/typescript-config-pwa": "^9.0.
|
|
15
|
+
"@graphcommerce/ecommerce-ui": "^9.0.2-canary.0",
|
|
16
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.2-canary.0",
|
|
17
|
+
"@graphcommerce/graphql": "^9.0.2-canary.0",
|
|
18
|
+
"@graphcommerce/image": "^9.0.2-canary.0",
|
|
19
|
+
"@graphcommerce/magento-cart": "^9.0.2-canary.0",
|
|
20
|
+
"@graphcommerce/magento-cart-payment-method": "^9.0.2-canary.0",
|
|
21
|
+
"@graphcommerce/magento-store": "^9.0.2-canary.0",
|
|
22
|
+
"@graphcommerce/next-ui": "^9.0.2-canary.0",
|
|
23
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.2-canary.0",
|
|
24
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.2-canary.0",
|
|
25
25
|
"@lingui/core": "^4.2.1",
|
|
26
26
|
"@lingui/macro": "^4.2.1",
|
|
27
27
|
"@lingui/react": "^4.2.1",
|