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

PowerBuilder 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

 

 

 

(PowerBuilder) Quickbooks Create an Invoice

Demonstrates how to create an invoice via the Quickbooks REST API.

For more information, see https://www.developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/invoice#create-an-invoice

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

integer li_rc
oleobject loo_JsonToken
integer li_Success
oleobject loo_Rest
integer li_BTls
integer li_Port
integer li_BAutoReconnect
integer li_Success
oleobject loo_SbAuth
oleobject loo_JsonReq
oleobject loo_SbRequestBody
oleobject loo_SbResponseBody
integer li_RespStatusCode
oleobject loo_JsonResponse
integer li_LineNum
string ls_Amount
string ls_SalesItemLineDetailTaxCodeRefValue
string ls_SalesItemLineDetailItemRefName
string ls_SalesItemLineDetailItemRefValue
string ls_Id
string ls_DetailType
string ls_DefinitionId
string ls_InvType
string ls_Name
string ls_InvoiceDocNumber
string ls_InvoiceSyncToken
string ls_InvoiceDomain
string ls_InvoiceBalance
string ls_InvoiceBillAddrCity
string ls_InvoiceBillAddrLine1
string ls_InvoiceBillAddrPostalCode
string ls_InvoiceBillAddrLat
string ls_InvoiceBillAddrLong
string ls_InvoiceBillAddrCountrySubDivisionCode
string ls_InvoiceBillAddrId
string ls_InvoiceTxnDate
string ls_InvoiceTotalAmt
string ls_InvoiceCustomerRefName
string ls_InvoiceCustomerRefValue
string ls_InvoiceShipAddrCity
string ls_InvoiceShipAddrLine1
string ls_InvoiceShipAddrPostalCode
string ls_InvoiceShipAddrLat
string ls_InvoiceShipAddrLong
string ls_InvoiceShipAddrCountrySubDivisionCode
string ls_InvoiceShipAddrId
string ls_InvoiceDueDate
string ls_InvoicePrintStatus
integer li_InvoiceDeposit
integer li_InvoiceSparse
string ls_InvoiceEmailStatus
integer li_InvoiceApplyTaxAfterDiscount
string ls_InvoiceId
integer li_InvoiceTxnTaxDetailTotalTax
string ls_InvoiceMetaDataCreateTime
string ls_InvoiceMetaDataLastUpdatedTime
string ls_Time
integer i
integer li_Count_i

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

// First get our previously obtained OAuth2 access token.
loo_JsonToken = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JsonToken.ConnectToNewObject("Chilkat.JsonObject")
if li_rc < 0 then
    destroy loo_JsonToken
    MessageBox("Error","Connecting to COM object failed")
    return
end if
li_Success = loo_JsonToken.LoadFile("qa_data/tokens/qb-access-token.json")

loo_Rest = create oleobject
// Use "Chilkat_9_5_0.Rest" for versions of Chilkat < 10.0.0
li_rc = loo_Rest.ConnectToNewObject("Chilkat.Rest")

// Connect to the REST server.
li_BTls = 1
li_Port = 443
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("sandbox-quickbooks.api.intuit.com",li_Port,li_BTls,li_BAutoReconnect)

loo_SbAuth = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbAuth.ConnectToNewObject("Chilkat.StringBuilder")

loo_SbAuth.Append("Bearer ")
loo_SbAuth.Append(loo_JsonToken.StringOf("access_token"))
loo_Rest.Authorization = loo_SbAuth.GetAsString()

// --------------------------------------------------------------------------
// Note: The above code to setup the initial REST connection
// can be done once.  After connecting, any number of REST calls can be made.
// If the connection is lost, the next REST method call will automatically
// reconnect if needed.
// --------------------------------------------------------------------------

// Create the following JSON:

// {
//   "Line": [
//     {
//       "DetailType": "SalesItemLineDetail",
//       "Amount": 100.0,
//       "SalesItemLineDetail": {
//         "ItemRef": {
//           "name": "Services",
//           "value": "1"
//         }
//       }
//     }
//   ],
//   "CustomerRef": {
//     "value": "1"
//   }
// }
// 
// Use the this online tool to generate the code from sample JSON: 
// Generate Code to Create JSON

loo_JsonReq = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JsonReq.ConnectToNewObject("Chilkat.JsonObject")

loo_JsonReq.UpdateString("Line[0].DetailType","SalesItemLineDetail")
loo_JsonReq.UpdateNumber("Line[0].Amount","100.0")
loo_JsonReq.UpdateString("Line[0].SalesItemLineDetail.ItemRef.name","Services")
loo_JsonReq.UpdateString("Line[0].SalesItemLineDetail.ItemRef.value","1")
loo_JsonReq.UpdateString("CustomerRef.value","1")

loo_SbRequestBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat.StringBuilder")

loo_JsonReq.EmitSb(loo_SbRequestBody)

loo_Rest.AddHeader("Content-Type","application/json")
loo_Rest.AddHeader("Accept","application/json")
loo_Rest.AllowHeaderFolding = 0

loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

li_Success = loo_Rest.FullRequestSb("POST","/v3/company/<realmID>/invoice",loo_SbRequestBody,loo_SbResponseBody)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_JsonToken
    destroy loo_Rest
    destroy loo_SbAuth
    destroy loo_JsonReq
    destroy loo_SbRequestBody
    destroy loo_SbResponseBody
    return
end if

li_RespStatusCode = loo_Rest.ResponseStatusCode

// Success is indicated by a 200 response status code.
Write-Debug "response status code = " + string(li_RespStatusCode)

loo_JsonResponse = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JsonResponse.ConnectToNewObject("Chilkat.JsonObject")

loo_JsonResponse.LoadSb(loo_SbResponseBody)
loo_JsonResponse.EmitCompact = 0
Write-Debug loo_JsonResponse.Emit()

if loo_Rest.ResponseStatusCode <> 200 then
    Write-Debug "Failed."
    destroy loo_JsonToken
    destroy loo_Rest
    destroy loo_SbAuth
    destroy loo_JsonReq
    destroy loo_SbRequestBody
    destroy loo_SbResponseBody
    destroy loo_JsonResponse
    return
end if

// Sample output...
// (See the parsing code below..)
// 
// Use the this online tool to generate parsing code from sample JSON: 
// Generate Parsing Code from JSON

// {
//   "Invoice": {
//     "DocNumber": "1069",
//     "SyncToken": "0",
//     "domain": "QBO",
//     "Balance": 100.0,
//     "BillAddr": {
//       "City": "Bayshore",
//       "Line1": "4581 Finch St.",
//       "PostalCode": "94326",
//       "Lat": "INVALID",
//       "Long": "INVALID",
//       "CountrySubDivisionCode": "CA",
//       "Id": "2"
//     },
//     "TxnDate": "2015-07-24",
//     "TotalAmt": 100.0,
//     "CustomerRef": {
//       "name": "Amy's Bird Sanctuary",
//       "value": "1"
//     },
//     "ShipAddr": {
//       "City": "Bayshore",
//       "Line1": "4581 Finch St.",
//       "PostalCode": "94326",
//       "Lat": "INVALID",
//       "Long": "INVALID",
//       "CountrySubDivisionCode": "CA",
//       "Id": "109"
//     },
//     "LinkedTxn": [
//     ],
//     "DueDate": "2015-08-23",
//     "PrintStatus": "NeedToPrint",
//     "Deposit": 0,
//     "sparse": false,
//     "EmailStatus": "NotSet",
//     "Line": [
//       {
//         "LineNum": 1,
//         "Amount": 100.0,
//         "SalesItemLineDetail": {
//           "TaxCodeRef": {
//             "value": "NON"
//           },
//           "ItemRef": {
//             "name": "Services",
//             "value": "1"
//           }
//         },
//         "Id": "1",
//         "DetailType": "SalesItemLineDetail"
//       },
//       {
//         "DetailType": "SubTotalLineDetail",
//         "Amount": 100.0,
//         "SubTotalLineDetail": {}
//       }
//     ],
//     "ApplyTaxAfterDiscount": false,
//     "CustomField": [
//       {
//         "DefinitionId": "1",
//         "Type": "StringType",
//         "Name": "Crew #"
//       }
//     ],
//     "Id": "238",
//     "TxnTaxDetail": {
//       "TotalTax": 0
//     },
//     "MetaData": {
//       "CreateTime": "2015-07-24T10:33:39-07:00",
//       "LastUpdatedTime": "2015-07-24T10:33:39-07:00"
//     }
//   },
//   "time": "2015-07-24T10:33:39.11-07:00"
// }
// 

ls_InvoiceDocNumber = loo_JsonResponse.StringOf("Invoice.DocNumber")
ls_InvoiceSyncToken = loo_JsonResponse.StringOf("Invoice.SyncToken")
ls_InvoiceDomain = loo_JsonResponse.StringOf("Invoice.domain")
ls_InvoiceBalance = loo_JsonResponse.StringOf("Invoice.Balance")
ls_InvoiceBillAddrCity = loo_JsonResponse.StringOf("Invoice.BillAddr.City")
ls_InvoiceBillAddrLine1 = loo_JsonResponse.StringOf("Invoice.BillAddr.Line1")
ls_InvoiceBillAddrPostalCode = loo_JsonResponse.StringOf("Invoice.BillAddr.PostalCode")
ls_InvoiceBillAddrLat = loo_JsonResponse.StringOf("Invoice.BillAddr.Lat")
ls_InvoiceBillAddrLong = loo_JsonResponse.StringOf("Invoice.BillAddr.Long")
ls_InvoiceBillAddrCountrySubDivisionCode = loo_JsonResponse.StringOf("Invoice.BillAddr.CountrySubDivisionCode")
ls_InvoiceBillAddrId = loo_JsonResponse.StringOf("Invoice.BillAddr.Id")
ls_InvoiceTxnDate = loo_JsonResponse.StringOf("Invoice.TxnDate")
ls_InvoiceTotalAmt = loo_JsonResponse.StringOf("Invoice.TotalAmt")
ls_InvoiceCustomerRefName = loo_JsonResponse.StringOf("Invoice.CustomerRef.name")
ls_InvoiceCustomerRefValue = loo_JsonResponse.StringOf("Invoice.CustomerRef.value")
ls_InvoiceShipAddrCity = loo_JsonResponse.StringOf("Invoice.ShipAddr.City")
ls_InvoiceShipAddrLine1 = loo_JsonResponse.StringOf("Invoice.ShipAddr.Line1")
ls_InvoiceShipAddrPostalCode = loo_JsonResponse.StringOf("Invoice.ShipAddr.PostalCode")
ls_InvoiceShipAddrLat = loo_JsonResponse.StringOf("Invoice.ShipAddr.Lat")
ls_InvoiceShipAddrLong = loo_JsonResponse.StringOf("Invoice.ShipAddr.Long")
ls_InvoiceShipAddrCountrySubDivisionCode = loo_JsonResponse.StringOf("Invoice.ShipAddr.CountrySubDivisionCode")
ls_InvoiceShipAddrId = loo_JsonResponse.StringOf("Invoice.ShipAddr.Id")
ls_InvoiceDueDate = loo_JsonResponse.StringOf("Invoice.DueDate")
ls_InvoicePrintStatus = loo_JsonResponse.StringOf("Invoice.PrintStatus")
li_InvoiceDeposit = loo_JsonResponse.IntOf("Invoice.Deposit")
li_InvoiceSparse = loo_JsonResponse.BoolOf("Invoice.sparse")
ls_InvoiceEmailStatus = loo_JsonResponse.StringOf("Invoice.EmailStatus")
li_InvoiceApplyTaxAfterDiscount = loo_JsonResponse.BoolOf("Invoice.ApplyTaxAfterDiscount")
ls_InvoiceId = loo_JsonResponse.StringOf("Invoice.Id")
li_InvoiceTxnTaxDetailTotalTax = loo_JsonResponse.IntOf("Invoice.TxnTaxDetail.TotalTax")
ls_InvoiceMetaDataCreateTime = loo_JsonResponse.StringOf("Invoice.MetaData.CreateTime")
ls_InvoiceMetaDataLastUpdatedTime = loo_JsonResponse.StringOf("Invoice.MetaData.LastUpdatedTime")
ls_Time = loo_JsonResponse.StringOf("time")
i = 0
li_Count_i = loo_JsonResponse.SizeOfArray("Invoice.LinkedTxn")
do while i < li_Count_i
    loo_JsonResponse.I = i
    i = i + 1
loop
i = 0
li_Count_i = loo_JsonResponse.SizeOfArray("Invoice.Line")
do while i < li_Count_i
    loo_JsonResponse.I = i
    li_LineNum = loo_JsonResponse.IntOf("Invoice.Line[i].LineNum")
    ls_Amount = loo_JsonResponse.StringOf("Invoice.Line[i].Amount")
    ls_SalesItemLineDetailTaxCodeRefValue = loo_JsonResponse.StringOf("Invoice.Line[i].SalesItemLineDetail.TaxCodeRef.value")
    ls_SalesItemLineDetailItemRefName = loo_JsonResponse.StringOf("Invoice.Line[i].SalesItemLineDetail.ItemRef.name")
    ls_SalesItemLineDetailItemRefValue = loo_JsonResponse.StringOf("Invoice.Line[i].SalesItemLineDetail.ItemRef.value")
    ls_Id = loo_JsonResponse.StringOf("Invoice.Line[i].Id")
    ls_DetailType = loo_JsonResponse.StringOf("Invoice.Line[i].DetailType")
    i = i + 1
loop
i = 0
li_Count_i = loo_JsonResponse.SizeOfArray("Invoice.CustomField")
do while i < li_Count_i
    loo_JsonResponse.I = i
    ls_DefinitionId = loo_JsonResponse.StringOf("Invoice.CustomField[i].DefinitionId")
    ls_InvType = loo_JsonResponse.StringOf("Invoice.CustomField[i].Type")
    ls_Name = loo_JsonResponse.StringOf("Invoice.CustomField[i].Name")
    i = i + 1
loop


destroy loo_JsonToken
destroy loo_Rest
destroy loo_SbAuth
destroy loo_JsonReq
destroy loo_SbRequestBody
destroy loo_SbResponseBody
destroy loo_JsonResponse

 

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