Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Objective-C Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Objective-C) Ecwid - Create Order

See more Ecwid Examples

Create a new order in an Ecwid store. This can be useful for storefronts with a custom checkout process or manually creating orders for sales made earlier.

For more information, see https://api-docs.ecwid.com/reference/orders#create-an-order

Chilkat Objective-C Library Downloads

MAC OS X (Cocoa) Libs

iOS Libs

#import <CkoJsonObject.h>
#import <CkoStringBuilder.h>
#import <CkoHttp.h>
#import <CkoHttpResponse.h>
#import <NSString.h>

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

// Create and send the following HTTP request:

// Load the access token previously obtained in Ecwid Get Access Token
CkoJsonObject *jsonToken = [[CkoJsonObject alloc] init];
[jsonToken LoadFile: @"qa_data/tokens/ecwid.json"];

CkoStringBuilder *sbUrl = [[CkoStringBuilder alloc] init];
[sbUrl Append: @"https://app.ecwid.com/api/v3/4870020/orders?token="];
[sbUrl Append: [jsonToken StringOf: @"access_token"]];

// POST /api/v3/4870020/orders?token=1234567890qwqeertt HTTP/1.1
// Host: app.ecwid.com
// Content-Type: application/json;charset=utf-8
// Cache-Control: no-cache
// 
// {
//         "subtotal": 30,
//         "total": 40,
//         "email": "example@example.com",
//         "paymentMethod": "Phone order",
//         "tax": 0,
//         "paymentStatus": "PAID",
//         "customerTaxExempt": false,
//         "customerTaxId": "",
//         "customerTaxIdValid": false,
//         "reversedTaxApplied": false,
//         "fulfillmentStatus": "AWAITING_PROCESSING",
//         "createDate": "2015-09-20 19:59:43 +0000",
//         "items": [
//             {
//                 "price": 15,
//                 "weight": 0.32,
//                 "sku": "00004",
//                 "quantity": 2,
//                 "name": "Cherry"
//             }
//         ],
//         "billingPerson": {
//             "name": "Eugene K",
//             "companyName": "Hedgehog and Bucket",
//             "street": "My Street",
//             "city": "San Diego",
//             "countryCode": "US",
//             "postalCode": "90002",
//             "stateOrProvinceCode": "CA",
//             "phone": "123141321"
//         },
//         "shippingPerson": {
//             "name": "Eugene K",
//             "companyName": "Hedgehog and Bucket",
//             "street": "My Street",
//             "city": "San Diego",
//             "countryCode": "US",
//             "postalCode": "90002",
//             "stateOrProvinceCode": "CA",
//             "phone": "123141321"
//         },
//         "shippingOption": {
//             "shippingMethodName": "Fast Delivery",
//             "shippingRate": 10,
//             "isPickup": false,
//             "fulfilmentType": "DELIVERY"
//         },
//         "hidden": false,
//         "privateAdminNotes": "Must be delivered till Sunday.",
//         "acceptMarketing": false,
//         "disableAllCustomerNotifications": true,
//         "externalFulfillment": true,
//         "externalOrderId": "2",
//         "pricesIncludeTax": false  
//     }

CkoHttp *http = [[CkoHttp alloc] init];
[http SetRequestHeader: @"Cache-Control" value: @"no-cache"];

CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateInt: @"subtotal" value: [NSNumber numberWithInt: 30]];
[json UpdateInt: @"total" value: [NSNumber numberWithInt: 40]];
[json UpdateString: @"email" value: @"example@example.com"];
[json UpdateString: @"paymentMethod" value: @"Phone order"];
[json UpdateInt: @"tax" value: [NSNumber numberWithInt: 0]];
[json UpdateString: @"paymentStatus" value: @"PAID"];
[json UpdateBool: @"customerTaxExempt" value: NO];
[json UpdateString: @"customerTaxId" value: @""];
[json UpdateBool: @"customerTaxIdValid" value: NO];
[json UpdateBool: @"reversedTaxApplied" value: NO];
[json UpdateString: @"fulfillmentStatus" value: @"AWAITING_PROCESSING"];
[json UpdateString: @"createDate" value: @"2015-09-20 19:59:43 +0000"];
[json UpdateInt: @"items[0].price" value: [NSNumber numberWithInt: 15]];
[json UpdateNumber: @"items[0].weight" numericStr: @"0.32"];
[json UpdateString: @"items[0].sku" value: @"00004"];
[json UpdateInt: @"items[0].quantity" value: [NSNumber numberWithInt: 2]];
[json UpdateString: @"items[0].name" value: @"Cherry"];
[json UpdateString: @"billingPerson.name" value: @"Eugene K"];
[json UpdateString: @"billingPerson.companyName" value: @"Hedgehog and Bucket"];
[json UpdateString: @"billingPerson.street" value: @"My Street"];
[json UpdateString: @"billingPerson.city" value: @"San Diego"];
[json UpdateString: @"billingPerson.countryCode" value: @"US"];
[json UpdateString: @"billingPerson.postalCode" value: @"90002"];
[json UpdateString: @"billingPerson.stateOrProvinceCode" value: @"CA"];
[json UpdateString: @"billingPerson.phone" value: @"123141321"];
[json UpdateString: @"shippingPerson.name" value: @"Eugene K"];
[json UpdateString: @"shippingPerson.companyName" value: @"Hedgehog and Bucket"];
[json UpdateString: @"shippingPerson.street" value: @"My Street"];
[json UpdateString: @"shippingPerson.city" value: @"San Diego"];
[json UpdateString: @"shippingPerson.countryCode" value: @"US"];
[json UpdateString: @"shippingPerson.postalCode" value: @"90002"];
[json UpdateString: @"shippingPerson.stateOrProvinceCode" value: @"CA"];
[json UpdateString: @"shippingPerson.phone" value: @"123141321"];
[json UpdateString: @"shippingOption.shippingMethodName" value: @"Fast Delivery"];
[json UpdateInt: @"shippingOption.shippingRate" value: [NSNumber numberWithInt: 10]];
[json UpdateBool: @"shippingOption.isPickup" value: NO];
[json UpdateString: @"shippingOption.fulfilmentType" value: @"DELIVERY"];
[json UpdateBool: @"hidden" value: NO];
[json UpdateString: @"privateAdminNotes" value: @"Must be delivered till Sunday."];
[json UpdateBool: @"acceptMarketing" value: NO];
[json UpdateBool: @"disableAllCustomerNotifications" value: YES];
[json UpdateBool: @"externalFulfillment" value: YES];
[json UpdateString: @"externalOrderId" value: @"2"];
[json UpdateBool: @"pricesIncludeTax" value: NO];

CkoHttpResponse *resp = [http PostJson3: [sbUrl GetAsString] contentType: @"application/json" json: json];
if (http.LastMethodSuccess != YES) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

NSLog(@"%@%d",@"Response status code = ",[resp.StatusCode intValue]);

CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
[resp GetBodySb: sbResponseBody];
CkoJsonObject *jResp = [[CkoJsonObject alloc] init];
[jResp LoadSb: sbResponseBody];
jResp.EmitCompact = NO;

NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[jResp Emit]);

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "id": 20,
//   "orderid": "XJ12H"
// }

// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON

int id = [[jResp IntOf: @"id"] intValue];
NSString *orderid = [jResp StringOf: @"orderid"];
 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.