@graphcommerce/magento-cart-payment-method 10.0.0-canary.68 → 10.0.0-canary.72
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/Api/PaymentMethod.ts
CHANGED
|
@@ -22,7 +22,7 @@ export type PaymentOptionsProps = PaymentMethod & PaymentMethodOptionsProps
|
|
|
22
22
|
export type PaymentHandlerProps = { code: string }
|
|
23
23
|
|
|
24
24
|
export type ExpandPaymentMethodsContext = Partial<PaymentMethodContextFragment> & {
|
|
25
|
-
client: ApolloClient
|
|
25
|
+
client: ApolloClient
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export type ExpandPaymentMethods = (
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 10.0.0-canary.72
|
|
4
|
+
|
|
5
|
+
## 10.0.0-canary.71
|
|
6
|
+
|
|
7
|
+
## 10.0.0-canary.70
|
|
8
|
+
|
|
9
|
+
### Major Changes
|
|
10
|
+
|
|
11
|
+
- [#2565](https://github.com/graphcommerce-org/graphcommerce/pull/2565) [`c96dfcd`](https://github.com/graphcommerce-org/graphcommerce/commit/c96dfcdca981baca387c270ad9e2b9515cdd00cc) - Updated to Apollo Client 4 ([@paales](https://github.com/paales))
|
|
12
|
+
|
|
13
|
+
## 10.0.0-canary.69
|
|
14
|
+
|
|
3
15
|
## 10.0.0-canary.68
|
|
4
16
|
|
|
5
17
|
## 10.0.0-canary.67
|
|
@@ -12,7 +12,10 @@ export function PaymentMethodPlaceOrderNoop(props: PaymentPlaceOrderProps) {
|
|
|
12
12
|
const form = useFormGqlMutationCart(PaymentMethodPlaceOrderNoopDocument, {
|
|
13
13
|
onComplete: async (result) => {
|
|
14
14
|
assertOrderPlaced(result)
|
|
15
|
-
|
|
15
|
+
// After assertOrderPlaced, result.data.placeOrder.order.order_number is guaranteed
|
|
16
|
+
const orderNumber = (result.data as { placeOrder: { order: { order_number: string } } })
|
|
17
|
+
.placeOrder.order.order_number
|
|
18
|
+
await onSuccess(orderNumber)
|
|
16
19
|
},
|
|
17
20
|
submitWhileLocked: true,
|
|
18
21
|
})
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { ApolloLink } from '@graphcommerce/graphql'
|
|
2
|
+
import { CombinedGraphQLErrors } from '@apollo/client/errors'
|
|
3
3
|
import { t } from '@lingui/core/macro'
|
|
4
4
|
import type { PaymentMethodPlaceOrderNoopMutation } from './PaymentMethodPlaceOrderNoop.gql'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
NonNullable<NonNullable<T['data']>['placeOrder']>['order']
|
|
8
|
-
>
|
|
6
|
+
type PlaceOrderResult = ApolloLink.Result<PaymentMethodPlaceOrderNoopMutation>
|
|
9
7
|
|
|
10
|
-
export type
|
|
8
|
+
export type PlacedOrder = {
|
|
9
|
+
order_number: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type AssertedOrderPlaced = PlaceOrderResult & {
|
|
11
13
|
data: {
|
|
12
|
-
placeOrder: { order: PlacedOrder
|
|
14
|
+
placeOrder: { order: PlacedOrder }
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
export function throwGenericPlaceOrderError() {
|
|
17
|
-
throw new
|
|
18
|
-
|
|
18
|
+
export function throwGenericPlaceOrderError(): never {
|
|
19
|
+
throw new CombinedGraphQLErrors({
|
|
20
|
+
errors: [
|
|
19
21
|
{
|
|
20
22
|
message: t`An error occurred while processing your payment. Please contact the store owner`,
|
|
21
23
|
},
|
|
@@ -24,20 +26,26 @@ export function throwGenericPlaceOrderError() {
|
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
/** Assert that the order was place successfully. */
|
|
27
|
-
export function assertOrderPlaced
|
|
28
|
-
result
|
|
29
|
-
): asserts result is AssertedOrderPlaced<T> {
|
|
29
|
+
export function assertOrderPlaced(result: PlaceOrderResult): asserts result is AssertedOrderPlaced {
|
|
30
|
+
// Check for GraphQL errors in the result
|
|
30
31
|
if (result.errors && result.errors.length > 0) {
|
|
31
|
-
|
|
32
|
-
throw new ApolloError({ graphQLErrors })
|
|
32
|
+
throw new CombinedGraphQLErrors(result)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
// Check for place order specific errors
|
|
36
|
+
const placeOrderData = result.data?.placeOrder as
|
|
37
|
+
| { errors?: { message: string }[] | null; order?: { order_number?: string } | null }
|
|
38
|
+
| null
|
|
39
|
+
| undefined
|
|
40
|
+
|
|
41
|
+
if (placeOrderData?.errors && placeOrderData.errors.length > 0) {
|
|
42
|
+
throw new CombinedGraphQLErrors({
|
|
43
|
+
errors: placeOrderData.errors.filter((e) => e !== null),
|
|
44
|
+
})
|
|
38
45
|
}
|
|
39
46
|
|
|
40
|
-
|
|
47
|
+
const orderNumber = placeOrderData?.order?.order_number
|
|
48
|
+
if (!orderNumber) {
|
|
41
49
|
console.info('Error while placing order', result)
|
|
42
50
|
throwGenericPlaceOrderError()
|
|
43
51
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/magento-cart-payment-method",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "10.0.0-canary.
|
|
5
|
+
"version": "10.0.0-canary.72",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"./PaymentMethodPlaceOrderNoop/PaymentMethodPlaceOrderNoop": "./PaymentMethodPlaceOrderNoop/PaymentMethodPlaceOrderNoop.tsx"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@graphcommerce/ecommerce-ui": "^10.0.0-canary.
|
|
22
|
-
"@graphcommerce/eslint-config-pwa": "^10.0.0-canary.
|
|
23
|
-
"@graphcommerce/framer-scroller": "^10.0.0-canary.
|
|
24
|
-
"@graphcommerce/graphql": "^10.0.0-canary.
|
|
25
|
-
"@graphcommerce/image": "^10.0.0-canary.
|
|
26
|
-
"@graphcommerce/magento-cart": "^10.0.0-canary.
|
|
27
|
-
"@graphcommerce/magento-cart-shipping-address": "^10.0.0-canary.
|
|
28
|
-
"@graphcommerce/magento-store": "^10.0.0-canary.
|
|
29
|
-
"@graphcommerce/next-ui": "^10.0.0-canary.
|
|
30
|
-
"@graphcommerce/prettier-config-pwa": "^10.0.0-canary.
|
|
31
|
-
"@graphcommerce/react-hook-form": "^10.0.0-canary.
|
|
32
|
-
"@graphcommerce/typescript-config-pwa": "^10.0.0-canary.
|
|
21
|
+
"@graphcommerce/ecommerce-ui": "^10.0.0-canary.72",
|
|
22
|
+
"@graphcommerce/eslint-config-pwa": "^10.0.0-canary.72",
|
|
23
|
+
"@graphcommerce/framer-scroller": "^10.0.0-canary.72",
|
|
24
|
+
"@graphcommerce/graphql": "^10.0.0-canary.72",
|
|
25
|
+
"@graphcommerce/image": "^10.0.0-canary.72",
|
|
26
|
+
"@graphcommerce/magento-cart": "^10.0.0-canary.72",
|
|
27
|
+
"@graphcommerce/magento-cart-shipping-address": "^10.0.0-canary.72",
|
|
28
|
+
"@graphcommerce/magento-store": "^10.0.0-canary.72",
|
|
29
|
+
"@graphcommerce/next-ui": "^10.0.0-canary.72",
|
|
30
|
+
"@graphcommerce/prettier-config-pwa": "^10.0.0-canary.72",
|
|
31
|
+
"@graphcommerce/react-hook-form": "^10.0.0-canary.72",
|
|
32
|
+
"@graphcommerce/typescript-config-pwa": "^10.0.0-canary.72",
|
|
33
33
|
"@lingui/core": "^5",
|
|
34
34
|
"@lingui/macro": "^5",
|
|
35
35
|
"@lingui/react": "^5",
|
package/test/goToPayment.ts
CHANGED
|
@@ -4,10 +4,7 @@ import { fillShippingAddressForm } from '@graphcommerce/magento-cart-shipping-ad
|
|
|
4
4
|
import { fillCartAgreementsForm } from '@graphcommerce/magento-cart/test/fillCartAgreementsForm'
|
|
5
5
|
import type { Page } from '@playwright/test'
|
|
6
6
|
|
|
7
|
-
export const goToPayment = async (
|
|
8
|
-
page: Page,
|
|
9
|
-
apolloClient: ApolloClient<NormalizedCacheObject>,
|
|
10
|
-
) => {
|
|
7
|
+
export const goToPayment = async (page: Page, apolloClient: ApolloClient) => {
|
|
11
8
|
await page.locator('#view-shopping-cart-button').click()
|
|
12
9
|
await page.locator('#cart-start-checkout').click()
|
|
13
10
|
|