2021-03-12 12:14:18 +00:00
|
|
|
export function createCheckout(
|
|
|
|
channelSlug,
|
|
|
|
email,
|
|
|
|
productQuantity,
|
|
|
|
variantsList
|
|
|
|
) {
|
|
|
|
const lines = variantsList.map(
|
|
|
|
variant => `{quantity:${productQuantity}
|
2021-02-16 14:19:46 +00:00
|
|
|
variantId:"${variant.id}"}`
|
2021-03-12 12:14:18 +00:00
|
|
|
);
|
|
|
|
const mutation = `mutation{
|
2021-02-02 11:34:10 +00:00
|
|
|
checkoutCreate(input:{
|
|
|
|
channel:"${channelSlug}"
|
|
|
|
email:"${email}"
|
|
|
|
lines: [${lines.join()}]
|
|
|
|
}){
|
|
|
|
checkoutErrors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
created
|
|
|
|
checkout{
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-03-12 12:14:18 +00:00
|
|
|
return cy.sendRequestWithQuery(mutation);
|
|
|
|
}
|
|
|
|
export function addShippingMethod(checkoutId, shippingMethodId) {
|
|
|
|
const mutation = `mutation{
|
2021-02-02 11:34:10 +00:00
|
|
|
checkoutShippingMethodUpdate(checkoutId:"${checkoutId}",
|
|
|
|
shippingMethodId:"${shippingMethodId}"){
|
|
|
|
checkoutErrors{
|
|
|
|
message
|
|
|
|
field
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-03-12 12:14:18 +00:00
|
|
|
return cy.sendRequestWithQuery(mutation);
|
|
|
|
}
|
|
|
|
export function addPayment(checkoutId, gateway, token) {
|
|
|
|
const mutation = `mutation{
|
2021-02-02 11:34:10 +00:00
|
|
|
checkoutPaymentCreate(checkoutId:"${checkoutId}",
|
|
|
|
input:{
|
|
|
|
gateway: "${gateway}"
|
|
|
|
token:"${token}"
|
|
|
|
}){
|
|
|
|
paymentErrors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-03-12 12:14:18 +00:00
|
|
|
return cy.sendRequestWithQuery(mutation);
|
|
|
|
}
|
|
|
|
export function completeCheckout(checkoutId) {
|
|
|
|
const mutation = `mutation{
|
2021-02-02 11:34:10 +00:00
|
|
|
checkoutComplete(checkoutId:"${checkoutId}"){
|
|
|
|
order{
|
|
|
|
id
|
|
|
|
}
|
|
|
|
confirmationNeeded
|
|
|
|
confirmationData
|
|
|
|
checkoutErrors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-03-12 12:14:18 +00:00
|
|
|
return cy.sendRequestWithQuery(mutation);
|
2021-02-02 11:34:10 +00:00
|
|
|
}
|