@graphcommerce/docs 4.12.0-canary.0 → 4.12.0-canary.1

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,25 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.12.0-canary.1
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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)
8
+
9
+ Upgrade guide:
10
+
11
+ - The upgrade removes `@graphcommerce/magento-cart-pickup` package from your `package.json`, remove them for now.
12
+ - Proceed to upgrade normally
13
+ - Add back `@graphcommerce/magento-cart-pickup`, following the [GraphCommerce Magento docs](https://graphcommerce.org/docs/magento). ([@paales](https://github.com/paales))
14
+
15
+ - [#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))
16
+
17
+ - [#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))
18
+
19
+ ### Patch Changes
20
+
21
+ - [#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))
22
+
3
23
  ## 4.12.0-canary.0
4
24
 
5
25
  ### Minor Changes
@@ -69,8 +69,7 @@ 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>,
@@ -170,3 +169,6 @@ user wants to disable a plugin, this is currently not possible.
170
169
 
171
170
  It is currently is only possible to extend React Components. This however sets
172
171
  the foundation to allow for a more flexible plugin system in the future.
172
+
173
+ Plugins should be optional for GraphCommerce to function properly. Plugins for
174
+ 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 `npm install --global yarn`
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.0",
5
+ "version": "4.12.0-canary.1",
6
6
  "sideEffects": true,
7
7
  "devDependencies": {
8
8
  "@graphcommerce/prettier-config-pwa": "^4.0.7"