Closed 0xShin0221 closed 1 year ago
webhoook data
method: POST
Order payment: {
id: 820982911946154500,
admin_graphql_api_id: 'gid://shopify/Order/820982911946154508',
app_id: null,
browser_ip: null,
buyer_accepts_marketing: true,
cancel_reason: 'customer',
cancelled_at: '2023-05-07T06:57:23-04:00',
cart_token: null,
checkout_id: null,
checkout_token: null,
client_details: null,
closed_at: null,
company: null,
confirmed: false,
contact_email: 'jon@example.com',
created_at: '2023-05-07T06:57:23-04:00',
currency: 'USD',
current_subtotal_price: '1499.90',
current_subtotal_price_set: {
shop_money: { amount: '1499.90', currency_code: 'USD' },
presentment_money: { amount: '1499.90', currency_code: 'USD' }
},
current_total_additional_fees_set: null,
current_total_discounts: '0.00',
current_total_discounts_set: {
shop_money: { amount: '0.00', currency_code: 'USD' },
presentment_money: { amount: '0.00', currency_code: 'USD' }
},
current_total_duties_set: null,
current_total_price: '1499.90',
current_total_price_set: {
shop_money: { amount: '1499.90', currency_code: 'USD' },
presentment_money: { amount: '1499.90', currency_code: 'USD' }
},
current_total_tax: '0.00',
current_total_tax_set: {
shop_money: { amount: '0.00', currency_code: 'USD' },
presentment_money: { amount: '0.00', currency_code: 'USD' }
},
customer_locale: 'en',
device_id: null,
discount_codes: [],
email: 'jon@example.com',
estimated_taxes: false,
financial_status: 'voided',
fulfillment_status: 'pending',
landing_site: null,
landing_site_ref: null,
location_id: null,
merchant_of_record_app_id: null,
name: '#9999',
note: null,
note_attributes: [],
number: 234,
order_number: 1234,
order_status_url: 'https://shopdao-generator-dev-with-test-data.myshopify.com/75323506980/orders/123456abcd/authenticate?key=abcdefg',
original_total_additional_fees_set: null,
original_total_duties_set: null,
payment_gateway_names: [ 'visa', 'bogus' ],
phone: null,
presentment_currency: 'USD',
processed_at: null,
reference: null,
referring_site: null,
source_identifier: null,
source_name: 'web',
source_url: null,
subtotal_price: '1494.90',
subtotal_price_set: {
shop_money: { amount: '1494.90', currency_code: 'USD' },
presentment_money: { amount: '1494.90', currency_code: 'USD' }
},
tags: '',
tax_lines: [],
taxes_included: false,
test: true,
token: '123456abcd',
total_discounts: '5.00',
total_discounts_set: {
shop_money: { amount: '5.00', currency_code: 'USD' },
presentment_money: { amount: '5.00', currency_code: 'USD' }
},
total_line_items_price: '1499.90',
total_line_items_price_set: {
shop_money: { amount: '1499.90', currency_code: 'USD' },
presentment_money: { amount: '1499.90', currency_code: 'USD' }
},
total_outstanding: '1499.90',
total_price: '1504.90',
total_price_set: {
shop_money: { amount: '1504.90', currency_code: 'USD' },
presentment_money: { amount: '1504.90', currency_code: 'USD' }
},
total_shipping_price_set: {
shop_money: { amount: '10.00', currency_code: 'USD' },
presentment_money: { amount: '10.00', currency_code: 'USD' }
},
total_tax: '0.00',
total_tax_set: {
shop_money: { amount: '0.00', currency_code: 'USD' },
presentment_money: { amount: '0.00', currency_code: 'USD' }
},
total_tip_received: '0.00',
total_weight: 0,
updated_at: '2023-05-07T06:57:23-04:00',
user_id: null,
billing_address: {
first_name: 'Steve',
address1: '123 Shipping Street',
phone: '555-555-SHIP',
city: 'Shippington',
zip: '40003',
province: 'Kentucky',
country: 'United States',
last_name: 'Shipper',
address2: null,
company: 'Shipping Company',
latitude: null,
longitude: null,
name: 'Steve Shipper',
country_code: 'US',
province_code: 'KY'
},
customer: {
id: 115310627314723950,
email: 'john@example.com',
accepts_marketing: false,
created_at: null,
updated_at: null,
first_name: 'John',
last_name: 'Smith',
state: 'disabled',
note: null,
verified_email: true,
multipass_identifier: null,
tax_exempt: false,
phone: null,
email_marketing_consent: {
state: 'not_subscribed',
opt_in_level: null,
consent_updated_at: null
},
sms_marketing_consent: null,
tags: '',
currency: 'USD',
accepts_marketing_updated_at: null,
marketing_opt_in_level: null,
tax_exemptions: [],
admin_graphql_api_id: 'gid://shopify/Customer/115310627314723954',
default_address: {
id: 715243470612851200,
customer_id: 115310627314723950,
first_name: null,
last_name: null,
company: null,
address1: '123 Elm St.',
address2: null,
city: 'Ottawa',
province: 'Ontario',
country: 'Canada',
zip: 'K2H7A8',
phone: '123-123-1234',
name: '',
province_code: 'ON',
country_code: 'CA',
country_name: 'Canada',
default: true
}
},
discount_applications: [],
fulfillments: [],
line_items: [
{
id: 866550311766439000,
admin_graphql_api_id: 'gid://shopify/LineItem/866550311766439020',
fulfillable_quantity: 1,
fulfillment_service: 'manual',
fulfillment_status: null,
gift_card: false,
grams: 0,
name: 'The Hidden Snowboard',
price: '749.95',
price_set: [Object],
product_exists: true,
product_id: 8297483632932,
properties: [],
quantity: 1,
requires_shipping: true,
sku: '',
taxable: true,
title: 'The Hidden Snowboard',
total_discount: '0.00',
total_discount_set: [Object],
variant_id: 45156094771492,
variant_inventory_management: 'shopify',
variant_title: null,
vendor: null,
tax_lines: [],
duties: [],
discount_allocations: []
},
{
id: 141249953214522980,
admin_graphql_api_id: 'gid://shopify/LineItem/141249953214522974',
fulfillable_quantity: 1,
fulfillment_service: 'manual',
fulfillment_status: null,
gift_card: false,
grams: 0,
name: 'The Collection Snowboard: Liquid',
price: '749.95',
price_set: [Object],
product_exists: true,
product_id: 8297484157220,
properties: [],
quantity: 1,
requires_shipping: true,
sku: '',
taxable: true,
title: 'The Collection Snowboard: Liquid',
total_discount: '0.00',
total_discount_set: [Object],
variant_id: 45156095557924,
variant_inventory_management: 'shopify',
variant_title: null,
vendor: null,
tax_lines: [],
duties: [],
discount_allocations: []
}
],
payment_terms: null,
refunds: [],
shipping_address: {
first_name: 'Steve',
address1: '123 Shipping Street',
phone: '555-555-SHIP',
city: 'Shippington',
zip: '40003',
province: 'Kentucky',
country: 'United States',
last_name: 'Shipper',
address2: null,
company: 'Shipping Company',
latitude: null,
longitude: null,
name: 'Steve Shipper',
country_code: 'US',
province_code: 'KY'
},
shipping_lines: [
{
id: 271878346596884000,
carrier_identifier: null,
code: null,
delivery_category: null,
discounted_price: '10.00',
discounted_price_set: [Object],
phone: null,
price: '10.00',
price_set: [Object],
requested_fulfillment_service_id: null,
source: 'shopify',
title: 'Generic Shipping',
tax_lines: [],
discount_allocations: []
}
]
}
Chainlink Function
const result = {
nftAddresses: salesDistributionResponse.data.nftAddresses,
hyphenatedOrderIds: salesDistributionResponse.data.hyphenatedOrderIds,
totalSales: salesDistributionResponse.data.totalSales,
totalProfits: salesDistributionResponse.data.totalProfits,
};
❯❯❯ curl https://frontend-shop-dao-generator-chainlink20-git-1c8261-shintaro0221.vercel.app/api/chainlink/salesDistribution | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --: 0 0 0 0 0 0 0 0 --:--:-- --:100 156 100 156 0 0 478 0 --:--:-- --:--:-- --:--:-- 498
{
"data": {
"nftAddresses": [
"0x"
],
"hyphenatedOrderIds": [
"820982911946154500-820982911946154501-820982911946154502"
],
"totalSales": [
"22"
],
"totalProfits": [
"11"
]
}
}
What