@isTest public with sharing class UpdateDraftOrderFromShopify_Test { static testmethod void TestRestPost(){ //CustomSettingRecordInsert.InsertingFieldMapping(); CustomSettingRecordInsert.InsertingConfiguration(); CustomSettingRecordInsert.InsertingWebhook(); Account acc = new Account(); acc.Name = 'test'; insert acc; Opportunity opp = new Opportunity(); opp.Name = 'test'; opp.CloseDate = system.today(); opp.StageName = 'Prospecting'; opp.HIC_ShopifySync__Shopify_Id__c = '618960158774'; insert opp; Order ord = new Order(); ord.Name = 'test'; ord.EffectiveDate = system.today(); ord.Status = 'Draft'; ord.HIC_ShopifySync__Shopify_Id__c = '618960158794'; ord.AccountId = acc.Id; insert ord; List fieldMappingList = new List(); HIC_ShopifySync__HIC_Field_Mapping__c fm = new HIC_ShopifySync__HIC_Field_Mapping__c(); fm.Name = 'Testing123'; fm.HIC_ShopifySync__SF_Field__c = 'EffectiveDate'; fm.HIC_ShopifySync__Default_Value__c = false; fm.HIC_ShopifySync__Object_Name__c = 'DraftOrder'; fm.HIC_ShopifySync__Shopify_Fields__c = 'created_at'; //fm.HIC_ShopifySync__Nested__c = 'String'; fm.HIC_ShopifySync__IsSFID__c = false; fm.HIC_ShopifySync__Store__c = '123'; fieldMappingList.add(fm); insert fieldMappingList; List configuration = New List(); HIC_ShopifySync__HIC_Configuration__c shopifyConfiguration = New HIC_ShopifySync__HIC_Configuration__c(); shopifyConfiguration.Name = 'Default'; shopifyConfiguration.HIC_ShopifySync__Account_Contact__c = true; shopifyConfiguration.HIC_ShopifySync__Opportunity_Sync__c = true; shopifyConfiguration.HIC_ShopifySync__Order_Sync__c = false; shopifyConfiguration.HIC_ShopifySync__Person_Account__c = false; shopifyConfiguration.HIC_ShopifySync__Default_Account__c = false; shopifyConfiguration.HIC_ShopifySync__Shopify_URL__c = '123@gmail.com'; shopifyConfiguration.HIC_ShopifySync__API_Key__c = 'test'; shopifyConfiguration.HIC_ShopifySync__Private_Key_Password__c = 'Test'; shopifyConfiguration.HIC_ShopifySync__Opportunity__c = true; shopifyConfiguration.HIC_ShopifySync__Order__c = true; shopifyConfiguration.HIC_ShopifySync__Opportunity_Line_Item__c = true; shopifyConfiguration.HIC_ShopifySync__Order_Line_Item__c = true; shopifyConfiguration.HIC_ShopifySync__Account_Record_Type__c = acc.Id; shopifyConfiguration.HIC_ShopifySync__Store__c = '123'; configuration.add(shopifyConfiguration); insert configuration; UpdateDraftOrderFromShopify reqst = new UpdateDraftOrderFromShopify(); system.debug('**reqst' + reqst); String JsonMsg='{"id":994189803566,"email":"discount@gmail.com","closed_at":null,"created_at":"2019-05-02T20:38:53+05:30","updated_at":"2019-05-02T20:38:53+05:30","number":25,"note":"","token":"972ee3aa1b4f62f9e58d42dd6e59f240","gateway":"manual","test":false,"total_price":"345.00","subtotal_price":"345.00","total_weight":0,"total_tax":"0.00","taxes_included":false,"currency":"INR","financial_status":"paid","confirmed":true,"total_discounts":"0.00","total_line_items_price":"345.00","cart_token":null,"buyer_accepts_marketing":false,"name":"#1025","referring_site":null,"landing_site":null,"cancelled_at":null,"cancel_reason":null,"total_price_usd":"4.95","checkout_token":null,"reference":null,"user_id":27797225518,"location_id":null,"source_identifier":null,"source_url":null,"processed_at":"2019-05-02T20:38:53+05:30","device_id":null,"phone":null,"customer_locale":null,"app_id":1354745,"browser_ip":null,"landing_site_ref":null,"DraftOrder_number":1025,"discount_applications":[],"discount_codes":[],"note_attributes":[],"payment_gateway_names":["manual"],"processing_method":"manual","checkout_id":null,"source_name":"shopify_draft_DraftOrder","fulfillment_status":null,"tax_lines":[],"tags":"","contact_email":"discount@gmail.com","DraftOrder_status_url":"https:checkout.shopify.com3153821742DraftOrders972ee3aa1b4f62f9e58d42dd6e59f240authenticate?key=133dd04da5844a64225155d4d7658fd7","presentment_currency":"INR","total_line_items_price_set":{"shop_money":{"amount":"345.00","currency_code":"INR"},"presentment_money":{"amount":"345.00","currency_code":"INR"}},"total_discounts_set":{"shop_money":{"amount":"0.00","currency_code":"INR"},"presentment_money":{"amount":"0.00","currency_code":"INR"}},"total_shipping_price_set":{"shop_money":{"amount":"0.00","currency_code":"INR"},"presentment_money":{"amount":"0.00","currency_code":"INR"}},"subtotal_price_set":{"shop_money":{"amount":"345.00","currency_code":"INR"},"presentment_money":{"amount":"345.00","currency_code":"INR"}},"total_price_set":{"shop_money":{"amount":"345.00","currency_code":"INR"},"presentment_money":{"amount":"345.00","currency_code":"INR"}},"total_tax_set":{"shop_money":{"amount":"0.00","currency_code":"INR"},"presentment_money":{"amount":"0.00","currency_code":"INR"}},"total_tip_received":"0.0","line_items":[{"id":1934525661230,"variant_id":16344594186286,"title":"abc","quantity":1,"sku":"","variant_title":null,"vendor":"SyncMyStore8","fulfillment_service":"manual","product_id":1771653529646,"requires_shipping":true,"taxable":true,"gift_card":false,"name":"abc","variant_inventory_management":"shopify","properties":[],"product_exists":true,"fulfillable_quantity":1,"grams":0,"price":"345.00","total_discount":"0.00","fulfillment_status":null,"price_set":{"shop_money":{"amount":"345.00","currency_code":"INR"},"presentment_money":{"amount":"345.00","currency_code":"INR"}},"total_discount_set":{"shop_money":{"amount":"0.00","currency_code":"INR"},"presentment_money":{"amount":"0.00","currency_code":"INR"}},"discount_allocations":[],"tax_lines":[]}],"shipping_lines":[],"billing_address":{"first_name":"online1","address1":"add","phone":"+912322222222","city":"Adda Saran ( Kandhala Jattan )","zip":"76567","province":"Punjab","country":"India","last_name":"online2","address2":"lajpatnagar","company":"shopifihic@gmail.com","latitude":null,"longitude":null,"name":"online1 online2","country_code":"IN","province_code":"PB"},"shipping_address":{"first_name":"online1","address1":"add","phone":"+912322222222","city":"Adda Saran ( Kandhala Jattan )","zip":"76567","province":"Punjab","country":"India","last_name":"online2","address2":"lajpatnagar","company":"shopifihic@gmail.com","latitude":null,"longitude":null,"name":"online1 online2","country_code":"IN","province_code":"PB"},"fulfillments":[],"refunds":[],"customer":{"id":1314583674926,"email":"discount@gmail.com","accepts_marketing":false,"created_at":"2019-05-02T18:25:02+05:30","updated_at":"2019-05-02T20:38:53+05:30","first_name":"online1","last_name":"online2","DraftOrders_count":1,"state":"disabled","total_spent":"345.00","last_DraftOrder_id":994189803566,"note":"bottlessssssssssss","verified_email":true,"multipass_identifier":null,"tax_exempt":true,"phone":"+919990755793","tags":"channellllllllll","last_DraftOrder_name":"#1025","currency":"INR","accepts_marketing_updated_at":"2019-05-02T18:25:03+05:30","marketing_opt_in_level":null,"default_address":{"id":1385885630510,"customer_id":1314583674926,"first_name":"online1","last_name":"online2","company":"shopifihic@gmail.com","address1":"add","address2":"lajpatnagar","city":"Adda Saran ( Kandhala Jattan )","province":"Punjab","country":"India","zip":"76567","phone":"+912322222222","name":"online1 online2","province_code":"PB","country_code":"IN","country_name":"India","default":true}}}'; //Test.startTest(); RestRequest req = new RestRequest(); RestResponse res = new RestResponse(); req.requestURI = '/services/apexrest/DemoUrl'; //Request URL req.httpMethod = 'POST';//HTTP Request Type req.requestBody = Blob.valueof(JsonMsg); RestContext.request = req; RestContext.response= res; UpdateDraftOrderFromShopify.updateOrder(); UpdateDraftOrderFromShopify.CreateDraftOrder(JsonMsg); UpdateDraftOrderFromShopify.CreateDraftOrder(JsonMsg,'123'); UpdateDraftOrderFromShopify.processOrder(JsonMsg, fieldMappingList, configuration,'123'); //Test.stopTest(); Restrequest req1 = new Restrequest(); req.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "DraftOrder_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_DraftOrder", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "DraftOrder_status_url": "https://checkout.shopify.com/10269687872/DraftOrders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/DraftOrder/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "DraftOrders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_DraftOrder_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_DraftOrder_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }'); Restresponse res1 = new Restresponse(); req.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateDraftOrderFromShopify'; req.httpMethod = 'POST'; RestContext.request = req; RestContext.response= res; res.statusCode = 200; Restrequest authenticationReq = new Restrequest(); authenticationReq.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "DraftOrder_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_DraftOrder", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "DraftOrder_status_url": "https://checkout.shopify.com/10269687872/DraftOrders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/DraftOrder/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "DraftOrders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_DraftOrder_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_DraftOrder_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }'); Restresponse authenticationRes = new Restresponse(); authenticationReq.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateDraftOrderFromShopifyAuthentication'; authenticationReq.httpMethod = 'POST'; RestContext.request = authenticationReq; RestContext.response= authenticationRes ; authenticationRes.statusCode = 200; Test.startTest(); UpdateDraftOrderFromShopify.updateOrder() ; system.assertequals(200, res.statuscode); UpdateDraftOrderFromShopifyAuth.UpdateDraftOrderFromShopifyAuth(); system.assertequals(200, authenticationRes.statuscode); Test.stopTest(); } @isTest static void TestRestPost1(){ Opportunity opp = new Opportunity(); opp.Name = 'test'; opp.CloseDate = system.today(); opp.StageName = 'Prospecting'; opp.HIC_ShopifySync__Shopify_Id__c = '618960158794'; insert opp; List ConList = new List(); HIC_ShopifySync__HIC_Configuration__c con = new HIC_ShopifySync__HIC_Configuration__c(); con.name = 'Default'; con.Opportunity__c = True; con.HIC_ShopifySync__Order__c = false; con.HIC_ShopifySync__Opportunity_Line_Item__c = True; con.HIC_ShopifySync__Order_Line_Item__c = True; con.HIC_ShopifySync__Person_Account__c = true; con.HIC_ShopifySync__Order_Fulfillment__c = true; con.HIC_ShopifySync__Store__c = '123'; ConList.add(con); insert ConList; Restrequest req = new Restrequest(); req.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "DraftOrder_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_DraftOrder", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "DraftOrder_status_url": "https://checkout.shopify.com/10269687872/DraftOrders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/DraftOrder/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "DraftOrders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_DraftOrder_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_DraftOrder_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }'); req.params.put('store', '123'); Restresponse res = new Restresponse(); req.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateDraftOrderFromShopify'; req.httpMethod = 'POST'; RestContext.request = req; RestContext.response= res; res.statusCode = 200; Restrequest authenticationReq = new Restrequest(); authenticationReq.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "DraftOrder_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_DraftOrder", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "DraftOrder_status_url": "https://checkout.shopify.com/10269687872/DraftOrders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/DraftOrder/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "DraftOrders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_DraftOrder_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_DraftOrder_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }'); authenticationReq.params.put('store', '123'); Restresponse authenticationRes = new Restresponse(); authenticationReq.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateDraftOrderFromShopifyAuthentication'; authenticationReq.httpMethod = 'POST'; RestContext.request = authenticationReq; RestContext.response= authenticationRes ; authenticationRes.statusCode = 200; Test.startTest(); UpdateDraftOrderFromShopify.updateOrder() ; system.assertequals(200, res.statuscode); UpdateDraftOrderFromShopifyAuth.UpdateDraftOrderFromShopifyAuth(); system.assertequals(200, authenticationRes.statuscode); Test.stopTest(); } @isTest static void TestRestPost2(){ Account acc = new Account(); acc.Name = 'test'; insert acc; Order ord = new Order(); ord.Name = 'test'; ord.EffectiveDate = system.today(); ord.Status = 'Draft'; ord.HIC_ShopifySync__Shopify_Id__c = '618960158794'; ord.AccountId = acc.Id; insert ord; List ConList = new List(); HIC_ShopifySync__HIC_Configuration__c con = new HIC_ShopifySync__HIC_Configuration__c(); con.name = 'Default'; con.HIC_ShopifySync__Opportunity__c = false; con.HIC_ShopifySync__Order__c = true; con.Opportunity_Line_Item__c = True; con.HIC_ShopifySync__Order_Line_Item__c = True; con.HIC_ShopifySync__Person_Account__c = true; con.HIC_ShopifySync__Order_Fulfillment__c = true; con.HIC_ShopifySync__Store__c = '123'; con.HIC_ShopifySync__Enable_Opportunity_for_SDO__c = false; con.HIC_ShopifySync__Enable_Draft_Order__c = true; ConList.add(con); insert ConList; Restrequest req = new Restrequest(); req.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "DraftOrder_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_DraftOrder", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "DraftOrder_status_url": "https://checkout.shopify.com/10269687872/DraftOrders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/DraftOrder/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "DraftOrders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_DraftOrder_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_DraftOrder_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }'); req.params.put('store', '123'); Restresponse res = new Restresponse(); req.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateDraftOrderFromShopify'; req.httpMethod = 'POST'; RestContext.request = req; RestContext.response= res; res.statusCode = 200; Restrequest authenticationReq = new Restrequest(); authenticationReq.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "DraftOrder_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_DraftOrder", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "DraftOrder_status_url": "https://checkout.shopify.com/10269687872/DraftOrders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/DraftOrder/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "DraftOrders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_DraftOrder_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_DraftOrder_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }'); authenticationReq.params.put('store', '123'); Restresponse authenticationRes = new Restresponse(); authenticationReq.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateDraftOrderFromShopifyAuthentication'; authenticationReq.httpMethod = 'POST'; RestContext.request = authenticationReq; RestContext.response= authenticationRes ; authenticationRes.statusCode = 200; string body = '{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "DraftOrder_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_DraftOrder", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "DraftOrder_status_url": "https://checkout.shopify.com/10269687872/DraftOrders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/DraftOrder/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "DraftOrders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_DraftOrder_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_DraftOrder_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } } '; List fieldMapList = new List(); // FOR FIELDMAPPING DML //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','Accountid','id','customer','REFERENCE','String'));// NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','HIC_ShopifySync__Billing_Customer_Name__c','name','billing_address','STRING','string')); //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutFields('DraftOrder','HIC_ShopifySync__Total_Tax__c','total_tax','NUMBER','number'));//new************ 29 April //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingCity','city','billing_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingCountry','country','billing_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingLatitude','latitude','billing_address','DOUBLE','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingLongitude','longitude','billing_address','DOUBLE','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingPostalCode','zip','billing_address','STRING','Number'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingState','province','billing_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingStreet','address1,address2','billing_address','TEXTAREA','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingCity','city','shipping_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingCountry','country','shipping_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingLatitude','latitude','shipping_address','DOUBLE','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingLongitude','longitude','shipping_address','DOUBLE','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingPostalCode','zip','shipping_address','STRING','Number'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingState','province','shipping_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingStreet','address1,address2','shipping_address','TEXTAREA','string'));//NEW //insert fieldMapList; Test.startTest(); UpdateDraftOrderFromShopify.updateOrder() ; UpdateDraftOrderFromShopify.processOrder(body,fieldMapList,ConList,'123'); system.assertequals(200, res.statuscode); UpdateDraftOrderFromShopifyAuth.UpdateDraftOrderFromShopifyAuth(); system.assertequals(200, authenticationRes.statuscode); Test.stopTest(); } @isTest static void TestRestPost3(){ Account acc = new Account(); acc.Name = 'test'; insert acc; Order ord = new Order(); ord.Name = 'test'; ord.EffectiveDate = system.today(); ord.Status = 'Draft'; ord.HIC_ShopifySync__Shopify_Id__c = '618960158784'; ord.AccountId = acc.Id; insert ord; List ConList = new List(); HIC_ShopifySync__HIC_Configuration__c con = new HIC_ShopifySync__HIC_Configuration__c(); con.name = 'Default'; con.HIC_ShopifySync__Opportunity__c = false; con.HIC_ShopifySync__Order__c = true; con.Opportunity_Line_Item__c = True; con.HIC_ShopifySync__Order_Line_Item__c = True; con.HIC_ShopifySync__Person_Account__c = true; con.HIC_ShopifySync__Order_Fulfillment__c = true; con.HIC_ShopifySync__Store__c = '123'; con.HIC_ShopifySync__Enable_Opportunity_for_SDO__c = true; con.HIC_ShopifySync__Enable_Draft_Order__c = true; ConList.add(con); insert ConList; Restrequest req = new Restrequest(); req.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "DraftOrder_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_DraftOrder", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "DraftOrder_status_url": "https://checkout.shopify.com/10269687872/DraftOrders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/DraftOrder/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "DraftOrders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_DraftOrder_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_DraftOrder_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }'); req.params.put('store', '123'); Restresponse res = new Restresponse(); req.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateDraftOrderFromShopify'; req.httpMethod = 'POST'; RestContext.request = req; RestContext.response= res; res.statusCode = 200; Restrequest authenticationReq = new Restrequest(); authenticationReq.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "DraftOrder_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_DraftOrder", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "DraftOrder_status_url": "https://checkout.shopify.com/10269687872/DraftOrders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/DraftOrder/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "DraftOrders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_DraftOrder_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_DraftOrder_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }'); authenticationReq.params.put('store', '123'); Restresponse authenticationRes = new Restresponse(); authenticationReq.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateDraftOrderFromShopifyAuthentication'; authenticationReq.httpMethod = 'POST'; RestContext.request = authenticationReq; RestContext.response= authenticationRes ; authenticationRes.statusCode = 200; string body = '{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "DraftOrder_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_DraftOrder", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "DraftOrder_status_url": "https://checkout.shopify.com/10269687872/DraftOrders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/DraftOrder/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "DraftOrders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_DraftOrder_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_DraftOrder_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } } '; List fieldMapList = new List(); // FOR FIELDMAPPING DML //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','Accountid','id','customer','REFERENCE','String'));// NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','HIC_ShopifySync__Billing_Customer_Name__c','name','billing_address','STRING','string')); //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutFields('DraftOrder','HIC_ShopifySync__Total_Tax__c','total_tax','NUMBER','number'));//new************ 29 April //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingCity','city','billing_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingCountry','country','billing_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingLatitude','latitude','billing_address','DOUBLE','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingLongitude','longitude','billing_address','DOUBLE','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingPostalCode','zip','billing_address','STRING','Number'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingState','province','billing_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingStreet','address1,address2','billing_address','TEXTAREA','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingCity','city','shipping_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingCountry','country','shipping_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingLatitude','latitude','shipping_address','DOUBLE','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingLongitude','longitude','shipping_address','DOUBLE','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingPostalCode','zip','shipping_address','STRING','Number'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingState','province','shipping_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingStreet','address1,address2','shipping_address','TEXTAREA','string'));//NEW //insert fieldMapList; Test.startTest(); UpdateDraftOrderFromShopify.updateOrder() ; UpdateDraftOrderFromShopify.processOrder(body,fieldMapList,ConList,'123'); system.assertequals(200, res.statuscode); UpdateDraftOrderFromShopifyAuth.UpdateDraftOrderFromShopifyAuth(); system.assertequals(200, authenticationRes.statuscode); Test.stopTest(); } @isTest static void TestRestPost4(){ Account acc = new Account(); acc.Name = 'test'; insert acc; system.debug('acc---->'+acc); List pdList= new List(); Product2 prod = new Product2(Name = 'Test product', Description = 'This is test product', Family = 'None', isActive = true); pdList.add(prod); insert pdList; system.debug('pdList----->'+pdList); Id pricebookId = Test.getStandardPricebookId(); system.debug('pricebookId---->'+pricebookId); //Create your pricebook entry PricebookEntry pbEntry = new PricebookEntry( Pricebook2Id = pricebookId, Product2Id = pdList[0].Id, UnitPrice = 100.00, IsActive = true ); insert pbEntry; system.debug('pbEntry---->'+pbEntry); Order ord = new Order(); ord.Name = 'test'; ord.EffectiveDate = system.today(); ord.Status = 'Draft'; ord.HIC_ShopifySync__Shopify_Id__c = '618960158784'; ord.AccountId = acc.Id; ord.Pricebook2Id = pricebookId; insert ord; system.debug('ord---->'+ord); List odItemList = new List(); OrderItem odItem = new OrderItem(); odItem.quantity = 10; odItem.PriceBookEntryId = pbEntry.Id; odItem.OrderId = ord.id; odItem.UnitPrice = 100; odItemList.add(odItem); insert odItemList; system.debug('odItemList test---->'+odItemList); List ConList = new List(); HIC_ShopifySync__HIC_Configuration__c con = new HIC_ShopifySync__HIC_Configuration__c(); con.name = 'Default'; con.HIC_ShopifySync__Opportunity__c = false; con.HIC_ShopifySync__Order__c = true; con.Opportunity_Line_Item__c = True; con.HIC_ShopifySync__Order_Line_Item__c = True; con.HIC_ShopifySync__Person_Account__c = true; con.HIC_ShopifySync__Order_Fulfillment__c = true; con.HIC_ShopifySync__Store__c = '123'; ConList.add(con); insert ConList; Restrequest req = new Restrequest(); req.requestBody = Blob.valueOf('{ "id":'+ ord.id +', "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "DraftOrder_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_DraftOrder", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "DraftOrder_status_url": "https://checkout.shopify.com/10269687872/DraftOrders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/DraftOrder/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "DraftOrders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_DraftOrder_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_DraftOrder_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }'); req.params.put('store', '123'); Restresponse res = new Restresponse(); req.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateDraftOrderFromShopify'; req.httpMethod = 'POST'; RestContext.request = req; RestContext.response= res; res.statusCode = 200; Restrequest authenticationReq = new Restrequest(); authenticationReq.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "DraftOrder_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_DraftOrder", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "DraftOrder_status_url": "https://checkout.shopify.com/10269687872/DraftOrders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/DraftOrder/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "DraftOrders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_DraftOrder_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_DraftOrder_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }'); authenticationReq.params.put('store', '123'); Restresponse authenticationRes = new Restresponse(); authenticationReq.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateDraftOrderFromShopifyAuthentication'; authenticationReq.httpMethod = 'POST'; RestContext.request = authenticationReq; RestContext.response= authenticationRes ; authenticationRes.statusCode = 200; string body = '{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "DraftOrder_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_DraftOrder", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "DraftOrder_status_url": "https://checkout.shopify.com/10269687872/DraftOrders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/DraftOrder/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "DraftOrders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_DraftOrder_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_DraftOrder_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } } '; List fieldMapList = new List(); // FOR FIELDMAPPING DML //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','Accountid','id','customer','REFERENCE','String'));// NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','HIC_ShopifySync__Billing_Customer_Name__c','name','billing_address','STRING','string')); //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutFields('DraftOrder','HIC_ShopifySync__Total_Tax__c','total_tax','NUMBER','number'));//new************ 29 April //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingCity','city','billing_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingCountry','country','billing_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingLatitude','latitude','billing_address','DOUBLE','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingLongitude','longitude','billing_address','DOUBLE','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingPostalCode','zip','billing_address','STRING','Number'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingState','province','billing_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','BillingStreet','address1,address2','billing_address','TEXTAREA','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingCity','city','shipping_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingCountry','country','shipping_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingLatitude','latitude','shipping_address','DOUBLE','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingLongitude','longitude','shipping_address','DOUBLE','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingPostalCode','zip','shipping_address','STRING','Number'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingState','province','shipping_address','STRING','string'));//NEW //fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('DraftOrder','ShippingStreet','address1,address2','shipping_address','TEXTAREA','string'));//NEW //insert fieldMapList; Test.startTest(); UpdateDraftOrderFromShopify.updateOrder() ; UpdateDraftOrderFromShopify.processOrder(body,fieldMapList,ConList,'123'); system.assertequals(200, res.statuscode); UpdateDraftOrderFromShopifyAuth.UpdateDraftOrderFromShopifyAuth(); system.assertequals(200, authenticationRes.statuscode); Test.stopTest(); } @isTest static void testOpportunityLineItemProcessingAndCleanup() { // === INLINE TEST DATA SETUP (No @testSetup) === // Configuration enabling Opportunity processing and cleanup HIC_ShopifySync__HIC_Configuration__c testConfig = new HIC_ShopifySync__HIC_Configuration__c( Name = 'Test Store', HIC_ShopifySync__Store__c = 'TestStore', HIC_ShopifySync__Enable_Opportunity_for_SDO__c = true, HIC_ShopifySync__Enable_Draft_Order__c = false, HIC_ShopifySync__Do_Clean_Up_Draft_Order_Once_Paid__c = true, HIC_ShopifySync__Salesforce_Pricebook__c = Test.getStandardPricebookId() ); insert testConfig; // Field mappings for Opportunity and Line Items HIC_ShopifySync__HIC_Field_Mapping__c oppMapping = new HIC_ShopifySync__HIC_Field_Mapping__c( HIC_ShopifySync__Object_Name__c = 'Opportunity', HIC_ShopifySync__SF_Field__c = 'HIC_ShopifySync__Shopify_Id__c', HIC_ShopifySync__Shopify_Fields__c = 'id', HIC_ShopifySync__Store__c = 'TestStore' ); insert oppMapping; HIC_ShopifySync__HIC_Field_Mapping__c oppLineMapping = new HIC_ShopifySync__HIC_Field_Mapping__c( HIC_ShopifySync__Object_Name__c = 'OpportunityLineItem', HIC_ShopifySync__SF_Field__c = 'HIC_ShopifySync__Shopify_Id__c', HIC_ShopifySync__Shopify_Fields__c = 'id', HIC_ShopifySync__Store__c = 'TestStore' ); insert oppLineMapping; // Product and PricebookEntry setup Product2 testProduct = new Product2(Name = 'Test Product', IsActive = true); insert testProduct; PricebookEntry testPbe = new PricebookEntry( Pricebook2Id = Test.getStandardPricebookId(), Product2Id = testProduct.Id, UnitPrice = 100.00, IsActive = true ); insert testPbe; // Existing Opportunity/LineItem for cleanup verification Opportunity existingOpp = new Opportunity( Name = 'Existing Opp', StageName = 'Prospecting', CloseDate = Date.today(), HIC_ShopifySync__Shopify_Id__c = '12345', Pricebook2Id = Test.getStandardPricebookId() ); insert existingOpp; OpportunityLineItem existingOli = new OpportunityLineItem( OpportunityId = existingOpp.Id, PricebookEntryId = testPbe.Id, Quantity = 1, TotalPrice = 100.00, HIC_ShopifySync__Shopify_Id__c = '12345-' + testProduct.Id ); insert existingOli; // === TEST EXECUTION === Test.startTest(); // Scenario 1: Open order - triggers OpportunityLineItem processing block String openOrderPayload = '{"id":"67890","order_number":"1001","status":"open",' + '"customer":{"id":"cust123","email":"test@example.com","first_name":"John","last_name":"Doe"},' + '"line_items":[{"product_id":"' + testProduct.Id + '","price":"100.00","quantity":1}]}'; RestRequest req1 = new RestRequest(); req1.requestUri = '/services/apexrest/UpdateDraftOrderFromShopify?store=TestStore'; req1.addParameter('store', 'TestStore'); req1.httpMethod = 'POST'; req1.requestBody = Blob.valueOf(openOrderPayload); RestContext.request = req1; RestContext.response = new RestResponse(); UpdateDraftOrderFromShopify.updateOrder(); // Scenario 2: Completed order - triggers cleanup block String completedOrderPayload = '{"id":"12345","order_number":"1002","status":"completed",' + '"customer":{"id":"cust456","email":"test2@example.com","first_name":"Jane","last_name":"Smith"}}'; RestRequest req2 = new RestRequest(); req2.requestUri = '/services/apexrest/UpdateDraftOrderFromShopify?store=TestStore'; req2.addParameter('store', 'TestStore'); req2.httpMethod = 'POST'; req2.requestBody = Blob.valueOf(completedOrderPayload); RestContext.request = req2; UpdateDraftOrderFromShopify.updateOrder(); Test.stopTest(); // === VERIFICATION === List remainingOpps = [SELECT Id FROM Opportunity WHERE Id = :existingOpp.Id]; System.assertEquals(0, remainingOpps.size(), 'Opportunity should be deleted on completed status'); List remainingOlis = [SELECT Id FROM OpportunityLineItem WHERE OpportunityId = :existingOpp.Id]; System.assertEquals(0, remainingOlis.size(), 'Line items should be deleted on completed status'); } @isTest static void testExceptionCreatesMissingOrderRecord() { // === INLINE TEST DATA SETUP (No @testSetup) === // Create configuration that enables Opportunity processing HIC_ShopifySync__HIC_Configuration__c testConfig = new HIC_ShopifySync__HIC_Configuration__c( Name = 'Test Store', HIC_ShopifySync__Store__c = 'TestStore', HIC_ShopifySync__Enable_Opportunity_for_SDO__c = true, HIC_ShopifySync__Enable_Draft_Order__c = false ); insert testConfig; // Create required field mappings for Opportunity and Line Items HIC_ShopifySync__HIC_Field_Mapping__c oppMapping = new HIC_ShopifySync__HIC_Field_Mapping__c( HIC_ShopifySync__Object_Name__c = 'Opportunity', HIC_ShopifySync__SF_Field__c = 'HIC_ShopifySync__Shopify_Id__c', HIC_ShopifySync__Shopify_Fields__c = 'id', HIC_ShopifySync__Store__c = 'TestStore' ); insert oppMapping; HIC_ShopifySync__HIC_Field_Mapping__c oppLineMapping = new HIC_ShopifySync__HIC_Field_Mapping__c( HIC_ShopifySync__Object_Name__c = 'OpportunityLineItem', HIC_ShopifySync__SF_Field__c = 'HIC_ShopifySync__Shopify_Id__c', HIC_ShopifySync__Shopify_Fields__c = 'id', HIC_ShopifySync__Store__c = 'TestStore' ); insert oppLineMapping; // === TEST EXECUTION === Test.startTest(); // Malformed payload: line_items is a string (not array) - triggers TypeException during casting String malformedPayload = '{"id":"12345","order_number":"1001","status":"open",' + '"customer":{"id":"cust123","email":"test@example.com"},' + '"line_items":"not_a_list"}'; RestRequest request = new RestRequest(); request.requestUri = '/services/apexrest/UpdateDraftOrderFromShopify?store=TestStore'; request.addParameter('store', 'TestStore'); request.httpMethod = 'POST'; request.requestBody = Blob.valueOf(malformedPayload); RestContext.request = request; RestContext.response = new RestResponse(); // Execute - this should catch exception and create Missing_Order__c record UpdateDraftOrderFromShopify.updateOrder(); Test.stopTest(); // === VERIFICATION === List missingOrders = [ SELECT Name, HIC_ShopifySync__Missing_Order_Info__c, HIC_ShopifySync__Missing_Order_Second_Info__c, HIC_ShopifySync__Missing_Order_Third_Info__c, HIC_ShopifySync__Shopify_id__c FROM HIC_ShopifySync__Missing_Order__c WHERE HIC_ShopifySync__Shopify_id__c = '12345' ]; System.assertEquals(1, missingOrders.size(), 'Missing Order record should be created when exception occurs'); System.assertEquals('1001', missingOrders[0].Name, 'Order number should be captured'); System.assertEquals('12345', missingOrders[0].HIC_ShopifySync__Shopify_id__c, 'Shopify ID should be captured'); System.assertEquals(malformedPayload, missingOrders[0].HIC_ShopifySync__Missing_Order_Info__c, 'Full JSON payload should be stored in first field'); System.assertEquals(null, missingOrders[0].HIC_ShopifySync__Missing_Order_Second_Info__c, 'Second info field should be null for small payloads'); } @isTest static void testOrderCleanupWhenOrderCompleted() { // === INLINE TEST DATA SETUP === // Configuration: Enable Draft Order, disable Opportunity, enable cleanup HIC_ShopifySync__HIC_Configuration__c testConfig = new HIC_ShopifySync__HIC_Configuration__c( Name = 'Test Store', HIC_ShopifySync__Store__c = 'TestStore', HIC_ShopifySync__Enable_Draft_Order__c = true, HIC_ShopifySync__Enable_Opportunity_for_SDO__c = false, HIC_ShopifySync__Do_Clean_Up_Draft_Order_Once_Paid__c = true, HIC_ShopifySync__Salesforce_Pricebook__c = Test.getStandardPricebookId() ); insert testConfig; // Field mappings for Order (DraftOrder) and OrderItem (DraftOrderItem) HIC_ShopifySync__HIC_Field_Mapping__c orderMapping = new HIC_ShopifySync__HIC_Field_Mapping__c( HIC_ShopifySync__Object_Name__c = 'DraftOrder', HIC_ShopifySync__SF_Field__c = 'HIC_ShopifySync__Shopify_Id__c', HIC_ShopifySync__Shopify_Fields__c = 'id', HIC_ShopifySync__Store__c = 'TestStore' ); insert orderMapping; HIC_ShopifySync__HIC_Field_Mapping__c orderItemMapping = new HIC_ShopifySync__HIC_Field_Mapping__c( HIC_ShopifySync__Object_Name__c = 'DraftOrderItem', HIC_ShopifySync__SF_Field__c = 'HIC_ShopifySync__Shopify_Id__c', HIC_ShopifySync__Shopify_Fields__c = 'id', HIC_ShopifySync__Store__c = 'TestStore' ); insert orderItemMapping; // Test Account required for Order Account testAccount = new Account(Name = 'Test Account'); insert testAccount; // Test Product and PricebookEntry required for OrderItem Product2 testProduct = new Product2(Name = 'Test Product', IsActive = true); insert testProduct; PricebookEntry testPbe = new PricebookEntry( Pricebook2Id = Test.getStandardPricebookId(), Product2Id = testProduct.Id, UnitPrice = 75.00, IsActive = true ); insert testPbe; // Create Order that will be deleted during test Order testOrder = new Order( AccountId = testAccount.Id, Pricebook2Id = Test.getStandardPricebookId(), Status = 'Draft', HIC_ShopifySync__Shopify_Id__c = '67890', // Must match payload EffectiveDate = Date.today() ); insert testOrder; // Create OrderItem that will be deleted with Order OrderItem testOrderItem = new OrderItem( OrderId = testOrder.Id, PricebookEntryId = testPbe.Id, Quantity = 3, UnitPrice = 75.00, HIC_ShopifySync__Shopify_Id__c = '67890-' + testProduct.Id ); insert testOrderItem; // === TEST EXECUTION === Test.startTest(); // JSON payload with completed status matching test Order's Shopify ID String completedOrderPayload = '{"id":"67890","order_number":"1002","status":"completed",' + '"customer":{"id":"cust123","email":"test@example.com","first_name":"John","last_name":"Doe"}}'; RestRequest request = new RestRequest(); request.requestUri = '/services/apexrest/UpdateDraftOrderFromShopify?store=TestStore'; request.addParameter('store', 'TestStore'); request.httpMethod = 'POST'; request.requestBody = Blob.valueOf(completedOrderPayload); RestContext.request = request; RestContext.response = new RestResponse(); // Execute webhook - should trigger Order cleanup block UpdateDraftOrderFromShopify.updateOrder(); Test.stopTest(); // === VERIFICATION === List remainingOrders = [ SELECT Id FROM Order WHERE Id = :testOrder.Id ]; System.assertEquals(0, remainingOrders.size(), 'Order should be deleted when status is completed and cleanup enabled'); List remainingOrderItems = [ SELECT Id FROM OrderItem WHERE OrderId = :testOrder.Id ]; System.assertEquals(0, remainingOrderItems.size(), 'OrderItems should be deleted when parent Order is completed and cleanup enabled'); } }