@graphcommerce/docs 4.12.0-canary.0 → 4.12.0-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 +26 -0
- package/framework/plugins.md +56 -32
- package/getting-started/create.md +4 -13
- package/magento/implementing-payment-gateways.md +168 -0
- package/magento/readme.md +17 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.12.0-canary.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1733](https://github.com/graphcommerce-org/graphcommerce/pull/1733) [`b2d73c726`](https://github.com/graphcommerce-org/graphcommerce/commit/b2d73c726fa123435fa6c54b4e0fd0db2df7c4ab) - Move to <Prev/> instead of <Component/> to call the plugin component ([@paales](https://github.com/paales))
|
|
8
|
+
|
|
9
|
+
## 4.12.0-canary.1
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#1729](https://github.com/graphcommerce-org/graphcommerce/pull/1729) [`c37187a51`](https://github.com/graphcommerce-org/graphcommerce/commit/c37187a513670ebcf09e99eb4a762c8bdb5df7e4) - Moved Magento Cart Pickup shipping method to the [GraphCommerce plugin system](https://www.graphcommerce.org/docs/framework/plugins)
|
|
14
|
+
|
|
15
|
+
Upgrade guide:
|
|
16
|
+
|
|
17
|
+
- The upgrade removes `@graphcommerce/magento-cart-pickup` package from your `package.json`, remove them for now.
|
|
18
|
+
- Proceed to upgrade normally
|
|
19
|
+
- Add back `@graphcommerce/magento-cart-pickup`, following the [GraphCommerce Magento docs](https://graphcommerce.org/docs/magento). ([@paales](https://github.com/paales))
|
|
20
|
+
|
|
21
|
+
- [#1729](https://github.com/graphcommerce-org/graphcommerce/pull/1729) [`2e68e0560`](https://github.com/graphcommerce-org/graphcommerce/commit/2e68e0560690bbf9bad6dc2b33d6e2ddb16197ce) - Adyen Payment gateway support ([@paales](https://github.com/paales))
|
|
22
|
+
|
|
23
|
+
- [#1729](https://github.com/graphcommerce-org/graphcommerce/pull/1729) [`366b05a7d`](https://github.com/graphcommerce-org/graphcommerce/commit/366b05a7da174a8a7c665b44e11422d8c873e4ed) - MultiSafePay Payment gateway support ([@paales](https://github.com/paales))
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- [#1729](https://github.com/graphcommerce-org/graphcommerce/pull/1729) [`78980b009`](https://github.com/graphcommerce-org/graphcommerce/commit/78980b009a3055006a50e0f54a4414ccf5570860) - Loosen node version constraint ([@paales](https://github.com/paales))
|
|
28
|
+
|
|
3
29
|
## 4.12.0-canary.0
|
|
4
30
|
|
|
5
31
|
### Minor Changes
|
package/framework/plugins.md
CHANGED
|
@@ -69,17 +69,16 @@ import { purchaseorder } from '../PurchaseOrder'
|
|
|
69
69
|
export const component = 'PaymentMethodContextProvider'
|
|
70
70
|
|
|
71
71
|
// Exported location of the component that you are extending, required
|
|
72
|
-
export const exported =
|
|
73
|
-
'@graphcommerce/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext'
|
|
72
|
+
export const exported = '@graphcommerce/magento-cart-payment-method'
|
|
74
73
|
|
|
75
74
|
function AddPaymentMethodEnhancer(
|
|
76
75
|
props: PluginProps<PaymentMethodContextProviderProps>,
|
|
77
76
|
) {
|
|
78
|
-
const {
|
|
79
|
-
return <
|
|
77
|
+
const { Prev, modules, ...rest } = props
|
|
78
|
+
return <Prev {...rest} modules={{ ...modules, purchaseorder }} />
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
/** The export must be named `Plugin` and must accept a
|
|
81
|
+
/** The export must be named `Plugin` and must accept a Prev component to render */
|
|
83
82
|
export const Plugin = AddIncludedMethods
|
|
84
83
|
```
|
|
85
84
|
|
|
@@ -98,37 +97,59 @@ export const Plugin = AddIncludedMethods
|
|
|
98
97
|
Example of generated interceptor with additional comments:
|
|
99
98
|
|
|
100
99
|
```tsx
|
|
101
|
-
|
|
102
|
-
import { Plugin as AddIncludedMethods } from '@graphcommerce/magento-payment-included/plugins/AddIncludedMethods'
|
|
103
|
-
import { Plugin as AddPaypalMethods } from '@graphcommerce/magento-payment-paypal/plugins/AddPaypalMethods'
|
|
104
|
-
|
|
105
|
-
// This file is placed next to the original component, so it is imported with a relative path, in the Webpack plugin we
|
|
106
|
-
// load the original file if it is loaded from the interceptor.
|
|
107
|
-
import { PaymentMethodContextProvider as PaymentMethodContextProviderBase } from './PaymentMethodContext'
|
|
108
|
-
|
|
109
|
-
// All original exports are exported, if the original file exports more than we're intercepting, it will still work.
|
|
110
|
-
export * from './PaymentMethodContext'
|
|
100
|
+
/* This file is automatically generated for @graphcommerce/magento-cart-payment-method */
|
|
111
101
|
|
|
112
|
-
|
|
102
|
+
export * from '.'
|
|
103
|
+
import { Plugin as GaPaymentMethodButton } from '@graphcommerce/googleanalytics/plugins/GaPaymentMethodButton'
|
|
104
|
+
import { Plugin as GaPaymentMethodContextProvider } from '@graphcommerce/googleanalytics/plugins/GaPaymentMethodContextProvider'
|
|
105
|
+
import { Plugin as AddIncludedMethods } from '@graphcommerce/magento-payment-included/plugins/AddIncludedMethods'
|
|
106
|
+
import { ComponentProps } from 'react'
|
|
107
|
+
import {
|
|
108
|
+
PaymentMethodButton as PaymentMethodButtonBase,
|
|
109
|
+
PaymentMethodContextProvider as PaymentMethodContextProviderBase,
|
|
110
|
+
} from '.'
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Interceptor for `<PaymentMethodButton/>` with these plugins:
|
|
114
|
+
*
|
|
115
|
+
* - `@graphcommerce/googleanalytics/plugins/GaPaymentMethodButton`
|
|
116
|
+
*/
|
|
117
|
+
type PaymentMethodButtonProps = ComponentProps<typeof PaymentMethodButtonBase>
|
|
118
|
+
|
|
119
|
+
function GaPaymentMethodButtonInterceptor(props: PaymentMethodButtonProps) {
|
|
120
|
+
return <GaPaymentMethodButton {...props} Prev={PaymentMethodButtonBase} />
|
|
121
|
+
}
|
|
122
|
+
export const PaymentMethodButton = GaPaymentMethodButtonInterceptor
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Interceptor for `<PaymentMethodContextProvider/>` with these plugins:
|
|
126
|
+
*
|
|
127
|
+
* - `@graphcommerce/magento-payment-included/plugins/AddIncludedMethods`
|
|
128
|
+
* - `@graphcommerce/googleanalytics/plugins/GaPaymentMethodContextProvider`
|
|
129
|
+
*/
|
|
130
|
+
type PaymentMethodContextProviderProps = ComponentProps<
|
|
113
131
|
typeof PaymentMethodContextProviderBase
|
|
114
132
|
>
|
|
115
133
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
props:
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
134
|
+
function AddIncludedMethodsInterceptor(
|
|
135
|
+
props: PaymentMethodContextProviderProps,
|
|
136
|
+
) {
|
|
137
|
+
return (
|
|
138
|
+
<AddIncludedMethods {...props} Prev={PaymentMethodContextProviderBase} />
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
function GaPaymentMethodContextProviderInterceptor(
|
|
142
|
+
props: PaymentMethodContextProviderProps,
|
|
143
|
+
) {
|
|
144
|
+
return (
|
|
145
|
+
<GaPaymentMethodContextProvider
|
|
146
|
+
{...props}
|
|
147
|
+
Prev={AddIncludedMethodsInterceptor}
|
|
148
|
+
/>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
export const PaymentMethodContextProvider =
|
|
152
|
+
GaPaymentMethodContextProviderInterceptor
|
|
132
153
|
```
|
|
133
154
|
|
|
134
155
|
React profile will show that all components are nested:
|
|
@@ -170,3 +191,6 @@ user wants to disable a plugin, this is currently not possible.
|
|
|
170
191
|
|
|
171
192
|
It is currently is only possible to extend React Components. This however sets
|
|
172
193
|
the foundation to allow for a more flexible plugin system in the future.
|
|
194
|
+
|
|
195
|
+
Plugins should be optional for GraphCommerce to function properly. Plugins for
|
|
196
|
+
mandatory packages shouldn't exist.
|
|
@@ -47,9 +47,9 @@ If you want to test a GraphCommerce storefront using a pre-configured Magento
|
|
|
47
47
|
demo store and a pre-configured GraphCMS project with demo content, then you
|
|
48
48
|
need to only install the dependencies. This is the quickest approach.
|
|
49
49
|
|
|
50
|
-
- Install and use node 14/16: `nvm install 16` or `nvm use 16`
|
|
51
|
-
- Install yarn: `corepack enable` (for node 16) or
|
|
52
|
-
(for node 14)
|
|
50
|
+
- Install and use node 14/16/18: `nvm install 16` or `nvm use 16`
|
|
51
|
+
- Install yarn: `corepack enable` (for node 16/18) or
|
|
52
|
+
`npm install --global yarn` (for node 14)
|
|
53
53
|
|
|
54
54
|
## Step 1: Create a new GraphCommerce app
|
|
55
55
|
|
|
@@ -135,16 +135,6 @@ List of routes and store_codes:
|
|
|
135
135
|
> }
|
|
136
136
|
> ```
|
|
137
137
|
|
|
138
|
-
### Remove unused PSP's
|
|
139
|
-
|
|
140
|
-
The example has Payment Service Providers integrated (Mollie, Braintree). Remove
|
|
141
|
-
the ones your Magento backend doesn't support.
|
|
142
|
-
|
|
143
|
-
- Remove Payment Service integrations from package.json:
|
|
144
|
-
`@graphcommerce/mollie-magento-payment` and/or
|
|
145
|
-
`@graphcommerce/magento-payment-braintree`
|
|
146
|
-
- Remove Payment Service references from `pages/checkout/payment.tsx`
|
|
147
|
-
|
|
148
138
|
## Step 3: Start the development environment
|
|
149
139
|
|
|
150
140
|
- `yarn` Install the dependencies
|
|
@@ -166,3 +156,4 @@ Visit the GraphQL Playground running at http://localhost:3000/api/graphql
|
|
|
166
156
|
- [Start building a GraphCommerce custom storefront](../getting-started/start-building.md)
|
|
167
157
|
by customizing text and component styles, fetching data from server
|
|
168
158
|
components, and making changes to GraphQL queries.
|
|
159
|
+
- [Install optional Magento packages](../magento/readme.md)
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Magento payment gateway requirements
|
|
2
|
+
|
|
3
|
+
Payment gateways are the most important part of any e-commerce store. In this
|
|
4
|
+
section, we will discuss the requirements for implementing a payment gateway in
|
|
5
|
+
Magento 2 that is compatible with GraphCommerce.
|
|
6
|
+
|
|
7
|
+
There are multiple flows to handle payments.
|
|
8
|
+
|
|
9
|
+
## Flow 1: Redirecting payment gateway
|
|
10
|
+
|
|
11
|
+
The first step is to call setPaymentMethodOnCart and placeOrder.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
const variables = {
|
|
15
|
+
cartId: 'currentCartId',
|
|
16
|
+
paymentMethod: {
|
|
17
|
+
code: 'my_payment_method',
|
|
18
|
+
my_gateway: {
|
|
19
|
+
return_url: 'https://my-site.com/checkout/billing?token=$TOKEN',
|
|
20
|
+
custom_field: 'blabla',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```graphql
|
|
27
|
+
mutation MyGatewayPaymentOptionsAndPlaceOrder(
|
|
28
|
+
$cartId: String!
|
|
29
|
+
$paymentMethod: PaymentMethodInput!
|
|
30
|
+
) {
|
|
31
|
+
setPaymentMethodOnCart(
|
|
32
|
+
input: { cart_id: $cartId, payment_method: $paymentMethod }
|
|
33
|
+
) {
|
|
34
|
+
cart {
|
|
35
|
+
selected_payment_method {
|
|
36
|
+
...SelectedPaymentMethod
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
placeOrder(input: { cart_id: $cartId }) {
|
|
41
|
+
order {
|
|
42
|
+
order_number
|
|
43
|
+
my_gateway_status {
|
|
44
|
+
token
|
|
45
|
+
status # Will probably be REDIRECT_SHOPPER
|
|
46
|
+
redirect_url
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
When the query succeeds the GraphCommerce payment module will redirect to the
|
|
54
|
+
payment_url. The customer handles it's payment on the payment gateway's website.
|
|
55
|
+
One of the following things can happen:
|
|
56
|
+
|
|
57
|
+
- Result 1: The customer has successfully paid and the customer is redirected
|
|
58
|
+
back to the `return_url` with the $TOKEN injected.
|
|
59
|
+
- Result 2: The customer has failed their pauyment and the customer is
|
|
60
|
+
redirected back to the `return_url` with the $TOKEN injected.
|
|
61
|
+
- Result 3: The customer presses back in their browser and we still get the
|
|
62
|
+
token from the `placeOrder` mutation.
|
|
63
|
+
|
|
64
|
+
GraphCommerce now needs to check if the payment has indeed succeeded by calling
|
|
65
|
+
the payment gateway's custom endpoint:
|
|
66
|
+
|
|
67
|
+
```graphql
|
|
68
|
+
mutation MyGatewayProcessPayment($cartId: String!, $token: String!) {
|
|
69
|
+
myGatewayPaymentStatus(input: { cartId: $cartId, token: $string }) {
|
|
70
|
+
status
|
|
71
|
+
error_message
|
|
72
|
+
cart {
|
|
73
|
+
# it will optionally return the cart if it hasn't succeeded yet and is recovered.
|
|
74
|
+
id
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
After that GraphCommerce van either:
|
|
81
|
+
|
|
82
|
+
- Redirect to the success page
|
|
83
|
+
- Restore the cart, show the error message and let the customer checkout again.
|
|
84
|
+
|
|
85
|
+
### The GraphQL Schema for the above example looks something like this:
|
|
86
|
+
|
|
87
|
+
```graphql
|
|
88
|
+
input PaymentMethodInput {
|
|
89
|
+
my_gateway: MyGatewayPaymentInput
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
input MyGatewayPaymentInput {
|
|
93
|
+
"""
|
|
94
|
+
The URL to redirect the customer to after the payment has been processed.
|
|
95
|
+
|
|
96
|
+
This will should be a fully qualified URL: `https://mydomain.com/checkout/payment?token=$TOKEN`
|
|
97
|
+
$TOKEN will be repaced with the payment gateway token.
|
|
98
|
+
|
|
99
|
+
This information should be stored in the database (encryped if required)
|
|
100
|
+
"""
|
|
101
|
+
return_url: String!
|
|
102
|
+
"""
|
|
103
|
+
Payment gateway can accept any custom field, for example an issuer or any additional information that can be configured in the checkout.
|
|
104
|
+
|
|
105
|
+
This information should be stored in the database (encryped if required)
|
|
106
|
+
"""
|
|
107
|
+
custom_field: String
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
type Order {
|
|
111
|
+
my_gateway_status: MyGatewayStatus
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
type Mutation {
|
|
115
|
+
myGatewayPaymentStatus: MyGatewayStatus
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
type MyGatewayStatus {
|
|
119
|
+
"""
|
|
120
|
+
Returns the secret token that is used to check the payment status and is understood by the external payment gateway.
|
|
121
|
+
"""
|
|
122
|
+
token: String!
|
|
123
|
+
"""
|
|
124
|
+
Status of the current payment.
|
|
125
|
+
"""
|
|
126
|
+
status: MyGatewayStatusEnum!
|
|
127
|
+
"""
|
|
128
|
+
Returned when status ERROR and there is a message to show to the customer from the gateway
|
|
129
|
+
"""
|
|
130
|
+
error_message: String
|
|
131
|
+
"""
|
|
132
|
+
Returned when the status is REDIRECT_SHOPPER
|
|
133
|
+
"""
|
|
134
|
+
redirect_url: String
|
|
135
|
+
"""
|
|
136
|
+
Retuned when when the cart has been restored on status CANCELLED, ERROR, REFUSED
|
|
137
|
+
"""
|
|
138
|
+
cart: Cart
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
"""
|
|
142
|
+
StatusEnum of the payment gateway.
|
|
143
|
+
Should probably look something like the following but can be extended / reduced according payment gateway's requirements.
|
|
144
|
+
"""
|
|
145
|
+
enum MyGatewayStatusEnum {
|
|
146
|
+
"""
|
|
147
|
+
Will be returned when the order is placed.
|
|
148
|
+
"""
|
|
149
|
+
REDIRECT_SHOPPER
|
|
150
|
+
"""
|
|
151
|
+
Will be returned when the customer has cancelled the payment on the external site.
|
|
152
|
+
Will be returned if the customer has pressed back in their browser.
|
|
153
|
+
"""
|
|
154
|
+
CANCELLED
|
|
155
|
+
"""
|
|
156
|
+
Will be returned if the payment hasn't succeeded, to be used in tandem with error_message
|
|
157
|
+
"""
|
|
158
|
+
ERROR
|
|
159
|
+
"""
|
|
160
|
+
Will be returned if the payment was rejected by the payment gateway.
|
|
161
|
+
"""
|
|
162
|
+
REFUSED
|
|
163
|
+
"""
|
|
164
|
+
Payment has succeeded
|
|
165
|
+
"""
|
|
166
|
+
SUCCESS
|
|
167
|
+
}
|
|
168
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Magento
|
|
2
|
+
|
|
3
|
+
To integrate with Magento, most of the functionality should work out-of-the box
|
|
4
|
+
if Magento exposes a working GraphQL API.
|
|
5
|
+
|
|
6
|
+
## Optional packages
|
|
7
|
+
|
|
8
|
+
- [Store Pickup / MSI](https://github.com/graphcommerce-org/graphcommerce/tree/main/packages/magento-cart-pickup)
|
|
9
|
+
|
|
10
|
+
## Payment gateways
|
|
11
|
+
|
|
12
|
+
- [PayPal](https://github.com/graphcommerce-org/graphcommerce/tree/main/packages/magento-payment-paypal)
|
|
13
|
+
- [Mollie](https://github.com/graphcommerce-org/graphcommerce/tree/main/packages/mollie-magento-payment)
|
|
14
|
+
- [Braintree](https://github.com/graphcommerce-org/graphcommerce/tree/main/packages/magento-payment-braintree)
|
|
15
|
+
- [Adyen](https://github.com/graphcommerce-org/graphcommerce/tree/main/packages/magento-payment-adyen)
|
|
16
|
+
- [MultiSafePay](https://github.com/graphcommerce-org/graphcommerce/tree/main/packages/magento-payment-multisafepay)
|
|
17
|
+
- [Klarna](https://github.com/graphcommerce-org/graphcommerce/tree/main/packages/magento-payment-klarna)
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/docs",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/docs",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce/docs",
|
|
5
|
-
"version": "4.12.0-canary.
|
|
5
|
+
"version": "4.12.0-canary.2",
|
|
6
6
|
"sideEffects": true,
|
|
7
7
|
"devDependencies": {
|
|
8
8
|
"@graphcommerce/prettier-config-pwa": "^4.0.7"
|