Added order confirmation after checkout completion. Note: This requires MANAGE_ORDERS permission which currently has the same bug as HANDLE_PAYMENTS. The try-catch ensures checkout won't fail if confirmation fails. Orders will be UNCONFIRMED until manually confirmed in dashboard.
243 lines
4.9 KiB
TypeScript
243 lines
4.9 KiB
TypeScript
import { gql } from "@apollo/client";
|
|
import { CHECKOUT_FRAGMENT } from "../fragments/Checkout";
|
|
|
|
export const CHECKOUT_CREATE = gql`
|
|
mutation CheckoutCreate($input: CheckoutCreateInput!) {
|
|
checkoutCreate(input: $input) {
|
|
checkout {
|
|
...CheckoutFragment
|
|
}
|
|
errors {
|
|
field
|
|
message
|
|
code
|
|
}
|
|
}
|
|
}
|
|
${CHECKOUT_FRAGMENT}
|
|
`;
|
|
|
|
export const CHECKOUT_LINES_ADD = gql`
|
|
mutation CheckoutLinesAdd($checkoutId: ID!, $lines: [CheckoutLineInput!]!) {
|
|
checkoutLinesAdd(checkoutId: $checkoutId, lines: $lines) {
|
|
checkout {
|
|
...CheckoutFragment
|
|
}
|
|
errors {
|
|
field
|
|
message
|
|
code
|
|
}
|
|
}
|
|
}
|
|
${CHECKOUT_FRAGMENT}
|
|
`;
|
|
|
|
export const CHECKOUT_LINES_UPDATE = gql`
|
|
mutation CheckoutLinesUpdate($checkoutId: ID!, $lines: [CheckoutLineUpdateInput!]!) {
|
|
checkoutLinesUpdate(checkoutId: $checkoutId, lines: $lines) {
|
|
checkout {
|
|
...CheckoutFragment
|
|
}
|
|
errors {
|
|
field
|
|
message
|
|
code
|
|
}
|
|
}
|
|
}
|
|
${CHECKOUT_FRAGMENT}
|
|
`;
|
|
|
|
export const CHECKOUT_LINES_DELETE = gql`
|
|
mutation CheckoutLinesDelete($id: ID!, $linesIds: [ID!]!) {
|
|
checkoutLinesDelete(id: $id, linesIds: $linesIds) {
|
|
checkout {
|
|
...CheckoutFragment
|
|
}
|
|
errors {
|
|
field
|
|
message
|
|
code
|
|
}
|
|
}
|
|
}
|
|
${CHECKOUT_FRAGMENT}
|
|
`;
|
|
|
|
export const CHECKOUT_SHIPPING_ADDRESS_UPDATE = gql`
|
|
mutation CheckoutShippingAddressUpdate($checkoutId: ID!, $shippingAddress: AddressInput!) {
|
|
checkoutShippingAddressUpdate(checkoutId: $checkoutId, shippingAddress: $shippingAddress) {
|
|
checkout {
|
|
...CheckoutFragment
|
|
}
|
|
errors {
|
|
field
|
|
message
|
|
code
|
|
}
|
|
}
|
|
}
|
|
${CHECKOUT_FRAGMENT}
|
|
`;
|
|
|
|
export const CHECKOUT_BILLING_ADDRESS_UPDATE = gql`
|
|
mutation CheckoutBillingAddressUpdate($checkoutId: ID!, $billingAddress: AddressInput!) {
|
|
checkoutBillingAddressUpdate(checkoutId: $checkoutId, billingAddress: $billingAddress) {
|
|
checkout {
|
|
...CheckoutFragment
|
|
}
|
|
errors {
|
|
field
|
|
message
|
|
code
|
|
}
|
|
}
|
|
}
|
|
${CHECKOUT_FRAGMENT}
|
|
`;
|
|
|
|
export const CHECKOUT_SHIPPING_METHOD_UPDATE = gql`
|
|
mutation CheckoutShippingMethodUpdate($checkoutId: ID!, $shippingMethodId: ID!) {
|
|
checkoutShippingMethodUpdate(checkoutId: $checkoutId, shippingMethodId: $shippingMethodId) {
|
|
checkout {
|
|
...CheckoutFragment
|
|
}
|
|
errors {
|
|
field
|
|
message
|
|
code
|
|
}
|
|
}
|
|
}
|
|
${CHECKOUT_FRAGMENT}
|
|
`;
|
|
|
|
export const CHECKOUT_COMPLETE = gql`
|
|
mutation CheckoutComplete($checkoutId: ID!) {
|
|
checkoutComplete(checkoutId: $checkoutId) {
|
|
order {
|
|
id
|
|
number
|
|
status
|
|
created
|
|
total {
|
|
gross {
|
|
amount
|
|
currency
|
|
}
|
|
}
|
|
}
|
|
errors {
|
|
field
|
|
message
|
|
code
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
|
|
export const CHECKOUT_EMAIL_UPDATE = gql`
|
|
mutation CheckoutEmailUpdate($checkoutId: ID!, $email: String!) {
|
|
checkoutEmailUpdate(checkoutId: $checkoutId, email: $email) {
|
|
checkout {
|
|
...CheckoutFragment
|
|
}
|
|
errors {
|
|
field
|
|
message
|
|
code
|
|
}
|
|
}
|
|
}
|
|
${CHECKOUT_FRAGMENT}
|
|
`;
|
|
|
|
export const CHECKOUT_METADATA_UPDATE = gql`
|
|
mutation CheckoutMetadataUpdate($checkoutId: ID!, $metadata: [MetadataInput!]!) {
|
|
updateMetadata(id: $checkoutId, input: $metadata) {
|
|
item {
|
|
... on Checkout {
|
|
id
|
|
metadata {
|
|
key
|
|
value
|
|
}
|
|
}
|
|
}
|
|
errors {
|
|
field
|
|
message
|
|
code
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
|
|
export const ORDER_METADATA_UPDATE = gql`
|
|
mutation OrderMetadataUpdate($orderId: ID!, $metadata: [MetadataInput!]!) {
|
|
updateMetadata(id: $orderId, input: $metadata) {
|
|
item {
|
|
... on Order {
|
|
id
|
|
metadata {
|
|
key
|
|
value
|
|
}
|
|
}
|
|
}
|
|
errors {
|
|
field
|
|
message
|
|
code
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
|
|
export const CHECKOUT_LANGUAGE_CODE_UPDATE = gql`
|
|
mutation CheckoutLanguageCodeUpdate($checkoutId: ID!, $languageCode: LanguageCodeEnum!) {
|
|
checkoutLanguageCodeUpdate(checkoutId: $checkoutId, languageCode: $languageCode) {
|
|
checkout {
|
|
id
|
|
languageCode
|
|
}
|
|
errors {
|
|
field
|
|
message
|
|
code
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
|
|
export const TRANSACTION_CREATE = gql`
|
|
mutation CreateTransaction($orderId: ID!, $transaction: TransactionCreateInput!) {
|
|
transactionCreate(id: $orderId, transaction: $transaction) {
|
|
transaction {
|
|
id
|
|
}
|
|
errors {
|
|
field
|
|
message
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
|
|
export const ORDER_CONFIRM = gql`
|
|
mutation OrderConfirm($orderId: ID!) {
|
|
orderConfirm(id: $orderId) {
|
|
order {
|
|
id
|
|
number
|
|
status
|
|
}
|
|
errors {
|
|
field
|
|
message
|
|
}
|
|
}
|
|
}
|
|
`;
|