Eam: Extend order payload (#816)
* Extend the order payload for translated names, attributes and price details * Add changeset
This commit is contained in:
parent
a725720920
commit
54901f8d08
4 changed files with 260 additions and 22 deletions
5
.changeset/stale-pigs-type.md
Normal file
5
.changeset/stale-pigs-type.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"saleor-app-emails-and-messages": patch
|
||||
---
|
||||
|
||||
Added new fields to the order related payload: attributes, price details, translated names
|
|
@ -1,7 +1,11 @@
|
|||
fragment OrderDetails on Order {
|
||||
id
|
||||
number
|
||||
status
|
||||
languageCodeEnum
|
||||
userEmail
|
||||
created
|
||||
redirectUrl
|
||||
channel {
|
||||
slug
|
||||
}
|
||||
|
@ -17,28 +21,103 @@ fragment OrderDetails on Order {
|
|||
email
|
||||
firstName
|
||||
lastName
|
||||
languageCode
|
||||
}
|
||||
billingAddress {
|
||||
firstName
|
||||
lastName
|
||||
companyName
|
||||
streetAddress1
|
||||
streetAddress2
|
||||
city
|
||||
cityArea
|
||||
postalCode
|
||||
country {
|
||||
country
|
||||
}
|
||||
phone
|
||||
}
|
||||
shippingAddress {
|
||||
firstName
|
||||
lastName
|
||||
companyName
|
||||
streetAddress1
|
||||
streetAddress2
|
||||
city
|
||||
cityArea
|
||||
postalCode
|
||||
country {
|
||||
country
|
||||
}
|
||||
phone
|
||||
}
|
||||
lines {
|
||||
id
|
||||
digitalContentUrl {
|
||||
id
|
||||
url
|
||||
}
|
||||
isShippingRequired
|
||||
metadata {
|
||||
key
|
||||
value
|
||||
}
|
||||
privateMetadata {
|
||||
key
|
||||
value
|
||||
}
|
||||
productName
|
||||
translatedProductName
|
||||
variantName
|
||||
translatedVariantName
|
||||
productSku
|
||||
variant {
|
||||
preorder{
|
||||
endDate
|
||||
}
|
||||
weight{
|
||||
unit
|
||||
value
|
||||
}
|
||||
attributes {
|
||||
attribute {
|
||||
id
|
||||
name
|
||||
slug
|
||||
}
|
||||
values {
|
||||
id
|
||||
name
|
||||
slug
|
||||
file {
|
||||
url
|
||||
contentType
|
||||
}
|
||||
}
|
||||
}
|
||||
product {
|
||||
attributes {
|
||||
attribute {
|
||||
id
|
||||
name
|
||||
slug
|
||||
}
|
||||
values {
|
||||
id
|
||||
name
|
||||
slug
|
||||
file{
|
||||
url
|
||||
contentType
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
quantity
|
||||
quantityFulfilled
|
||||
taxRate
|
||||
thumbnail {
|
||||
url
|
||||
alt
|
||||
|
@ -48,12 +127,49 @@ fragment OrderDetails on Order {
|
|||
currency
|
||||
amount
|
||||
}
|
||||
net {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
tax {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
}
|
||||
totalPrice {
|
||||
gross {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
net {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
tax {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
}
|
||||
unitDiscount {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
unitDiscountReason
|
||||
unitDiscountType
|
||||
unitDiscountValue
|
||||
undiscountedUnitPrice{
|
||||
gross {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
net {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
tax {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
}
|
||||
}
|
||||
subtotal {
|
||||
|
@ -61,17 +177,58 @@ fragment OrderDetails on Order {
|
|||
amount
|
||||
currency
|
||||
}
|
||||
net {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
tax {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
}
|
||||
shippingPrice {
|
||||
gross {
|
||||
amount
|
||||
currency
|
||||
}
|
||||
net {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
tax {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
}
|
||||
total {
|
||||
gross {
|
||||
amount
|
||||
currency
|
||||
}
|
||||
net {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
tax {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
}
|
||||
undiscountedTotal {
|
||||
gross {
|
||||
amount
|
||||
currency
|
||||
}
|
||||
net {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
tax {
|
||||
currency
|
||||
amount
|
||||
}
|
||||
}
|
||||
displayGrossPrices
|
||||
isShippingRequired
|
||||
shippingMethodName
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import {
|
|||
InvoiceSentWebhookPayloadFragment,
|
||||
GiftCardSentWebhookPayloadFragment,
|
||||
OrderRefundedWebhookPayloadFragment,
|
||||
LanguageCodeEnum,
|
||||
OrderStatus,
|
||||
} from "../../../generated/graphql";
|
||||
import {
|
||||
NotifyPayloadAccountChangeEmailRequest,
|
||||
|
@ -21,6 +23,11 @@ import {
|
|||
const exampleOrderPayload: OrderDetailsFragment = {
|
||||
id: "T3JkZXI6NTdiNTBhNDAtYzRmYi00YjQzLWIxODgtM2JhZmRlMTc3MGQ5",
|
||||
number: "198",
|
||||
status: OrderStatus.Unfulfilled,
|
||||
languageCodeEnum: LanguageCodeEnum.En,
|
||||
created: "",
|
||||
displayGrossPrices: true,
|
||||
isShippingRequired: true,
|
||||
userEmail: "adrian.king@example.com",
|
||||
metadata: [
|
||||
{
|
||||
|
@ -41,9 +48,15 @@ const exampleOrderPayload: OrderDetailsFragment = {
|
|||
email: "adrian.king@example.com",
|
||||
firstName: "Adrian",
|
||||
lastName: "King",
|
||||
languageCode: LanguageCodeEnum.En,
|
||||
},
|
||||
billingAddress: {
|
||||
firstName: "Adrian",
|
||||
lastName: "King",
|
||||
streetAddress1: "59314 Mary Well Suite 281",
|
||||
streetAddress2: "",
|
||||
companyName: "",
|
||||
cityArea: "",
|
||||
city: "METROPOLIS",
|
||||
postalCode: "71653",
|
||||
country: {
|
||||
|
@ -51,7 +64,12 @@ const exampleOrderPayload: OrderDetailsFragment = {
|
|||
},
|
||||
},
|
||||
shippingAddress: {
|
||||
firstName: "Adrian",
|
||||
lastName: "King",
|
||||
streetAddress1: "59314 Mary Well Suite 281",
|
||||
streetAddress2: "",
|
||||
companyName: "",
|
||||
cityArea: "",
|
||||
city: "METROPOLIS",
|
||||
postalCode: "71653",
|
||||
country: {
|
||||
|
@ -73,27 +91,13 @@ const exampleOrderPayload: OrderDetailsFragment = {
|
|||
currency: "USD",
|
||||
amount: 5,
|
||||
},
|
||||
},
|
||||
totalPrice: {
|
||||
gross: {
|
||||
net: {
|
||||
currency: "USD",
|
||||
amount: 5,
|
||||
amount: 4,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "T3JkZXJMaW5lOjVhYmEzMTBkLTZkMzEtNDNlNy1hZjAyLTdlNGUwM2UzYmI4ZA==",
|
||||
productName: "Code Division T-shirt",
|
||||
variantName: "L",
|
||||
quantity: 1,
|
||||
thumbnail: {
|
||||
url: "https://placehold.jp/150x150.png",
|
||||
alt: "",
|
||||
},
|
||||
unitPrice: {
|
||||
gross: {
|
||||
tax: {
|
||||
currency: "USD",
|
||||
amount: 5,
|
||||
amount: 1,
|
||||
},
|
||||
},
|
||||
totalPrice: {
|
||||
|
@ -101,24 +105,96 @@ const exampleOrderPayload: OrderDetailsFragment = {
|
|||
currency: "USD",
|
||||
amount: 5,
|
||||
},
|
||||
net: {
|
||||
currency: "USD",
|
||||
amount: 4,
|
||||
},
|
||||
tax: {
|
||||
currency: "USD",
|
||||
amount: 1,
|
||||
},
|
||||
},
|
||||
isShippingRequired: true,
|
||||
translatedProductName: "Black Hoodie",
|
||||
translatedVariantName: "XL",
|
||||
quantityFulfilled: 0,
|
||||
taxRate: 10,
|
||||
unitDiscountValue: 0,
|
||||
unitDiscount: {
|
||||
amount: 0,
|
||||
currency: "USD",
|
||||
},
|
||||
undiscountedUnitPrice: {
|
||||
gross: {
|
||||
currency: "USD",
|
||||
amount: 5,
|
||||
},
|
||||
net: {
|
||||
currency: "USD",
|
||||
amount: 4,
|
||||
},
|
||||
tax: {
|
||||
currency: "USD",
|
||||
amount: 1,
|
||||
},
|
||||
},
|
||||
metadata: [],
|
||||
privateMetadata: [],
|
||||
},
|
||||
],
|
||||
subtotal: {
|
||||
gross: {
|
||||
amount: 10,
|
||||
amount: 5,
|
||||
currency: "USD",
|
||||
},
|
||||
net: {
|
||||
amount: 4,
|
||||
currency: "USD",
|
||||
},
|
||||
tax: {
|
||||
amount: 1,
|
||||
currency: "USD",
|
||||
},
|
||||
},
|
||||
shippingPrice: {
|
||||
gross: {
|
||||
amount: 61.62,
|
||||
amount: 10,
|
||||
currency: "USD",
|
||||
},
|
||||
net: {
|
||||
amount: 8,
|
||||
currency: "USD",
|
||||
},
|
||||
tax: {
|
||||
amount: 2,
|
||||
currency: "USD",
|
||||
},
|
||||
},
|
||||
undiscountedTotal: {
|
||||
gross: {
|
||||
amount: 15,
|
||||
currency: "USD",
|
||||
},
|
||||
net: {
|
||||
amount: 12,
|
||||
currency: "USD",
|
||||
},
|
||||
tax: {
|
||||
amount: 3,
|
||||
currency: "USD",
|
||||
},
|
||||
},
|
||||
total: {
|
||||
gross: {
|
||||
amount: 71.62,
|
||||
amount: 15,
|
||||
currency: "USD",
|
||||
},
|
||||
net: {
|
||||
amount: 12,
|
||||
currency: "USD",
|
||||
},
|
||||
tax: {
|
||||
amount: 3,
|
||||
currency: "USD",
|
||||
},
|
||||
},
|
||||
|
|
|
@ -114,7 +114,7 @@ describe("WebhookManagementService", function () {
|
|||
name: invoiceSentWebhook.name,
|
||||
targetUrl: "https://example.com/api/webhooks/invoice-sent",
|
||||
query:
|
||||
"subscription InvoiceSent { event { ...InvoiceSentWebhookPayload }}fragment InvoiceSentWebhookPayload on InvoiceSent { invoice { id metadata { key value } privateMetadata { key value } message externalUrl url order { id } } order { ...OrderDetails }}fragment OrderDetails on Order { id number userEmail channel { slug } metadata { key value } privateMetadata { key value } user { email firstName lastName } billingAddress { streetAddress1 city postalCode country { country } } shippingAddress { streetAddress1 city postalCode country { country } } lines { id productName variantName quantity thumbnail { url alt } unitPrice { gross { currency amount } } totalPrice { gross { currency amount } } } subtotal { gross { amount currency } } shippingPrice { gross { amount currency } } total { gross { amount currency } }}",
|
||||
"subscription InvoiceSent { event { ...InvoiceSentWebhookPayload }}fragment InvoiceSentWebhookPayload on InvoiceSent { invoice { id metadata { key value } privateMetadata { key value } message externalUrl url order { id } } order { ...OrderDetails }}fragment OrderDetails on Order { id number status languageCodeEnum userEmail created redirectUrl channel { slug } metadata { key value } privateMetadata { key value } user { email firstName lastName languageCode } billingAddress { firstName lastName companyName streetAddress1 streetAddress2 city cityArea postalCode country { country } phone } shippingAddress { firstName lastName companyName streetAddress1 streetAddress2 city cityArea postalCode country { country } phone } lines { id digitalContentUrl { id url } isShippingRequired metadata { key value } privateMetadata { key value } productName translatedProductName variantName translatedVariantName productSku variant { preorder { endDate } weight { unit value } attributes { attribute { id name slug } values { id name slug file { url contentType } } } product { attributes { attribute { id name slug } values { id name slug file { url contentType } } } } } quantity quantityFulfilled taxRate thumbnail { url alt } unitPrice { gross { currency amount } net { currency amount } tax { currency amount } } totalPrice { gross { currency amount } net { currency amount } tax { currency amount } } unitDiscount { currency amount } unitDiscountReason unitDiscountType unitDiscountValue undiscountedUnitPrice { gross { currency amount } net { currency amount } tax { currency amount } } } subtotal { gross { amount currency } net { currency amount } tax { currency amount } } shippingPrice { gross { amount currency } net { currency amount } tax { currency amount } } total { gross { amount currency } net { currency amount } tax { currency amount } } undiscountedTotal { gross { amount currency } net { currency amount } tax { currency amount } } displayGrossPrices isShippingRequired shippingMethodName}",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue