Creates a customer invoice object.
curl https://api.stripe.com/v1/invoices \
-u STRIPE_SECRET_KEY: \
-d customer=cus_CBbg9PmQ9sLbmo \
-X POST
IncludeFile "CkRest.pb"
IncludeFile "CkJsonObject.pb"
Procedure ChilkatExample()
rest.i = CkRest::ckCreate()
If rest.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
; URL: https://api.stripe.com/v1/invoices
bTls.i = 1
port.i = 443
bAutoReconnect.i = 1
success = CkRest::ckConnect(rest,"api.stripe.com",port,bTls,bAutoReconnect)
If success <> 1
Debug "ConnectFailReason: " + Str(CkRest::ckConnectFailReason(rest))
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
ProcedureReturn
EndIf
CkRest::ckSetAuthBasic(rest,"STRIPE_SECRET_KEY","")
CkRest::ckAddQueryParam(rest,"customer","cus_CBbg9PmQ9sLbmo")
strResponseBody.s = CkRest::ckFullRequestFormUrlEncoded(rest,"POST","/v1/invoices")
If CkRest::ckLastMethodSuccess(rest) <> 1
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
ProcedureReturn
EndIf
jsonResponse.i = CkJsonObject::ckCreate()
If jsonResponse.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoad(jsonResponse,strResponseBody)
id.s
object.s
amount_due.i
application_fee.i
attempt_count.i
attempted.i
billing.s
charge.i
closed.i
currency.s
customer.s
date.i
description.i
discount.i
due_date.i
ending_balance.i
forgiven.i
linesHas_more.i
linesObject.s
linesUrl.s
livemode.i
next_payment_attempt.i
number.s
paid.i
period_end.i
period_start.i
receipt_number.i
starting_balance.i
statement_descriptor.i
subscription.i
subtotal.i
tax.i
tax_percent.i
total.i
webhooks_delivered_at.i
i.i
count_i.i
amount.i
description_str.s
discountable.i
periodStart.i
periodEnd.i
plan.i
proration.i
quantity.i
type.s
id = CkJsonObject::ckStringOf(jsonResponse,"id")
object = CkJsonObject::ckStringOf(jsonResponse,"object")
amount_due = CkJsonObject::ckIntOf(jsonResponse,"amount_due")
application_fee = CkJsonObject::ckIsNullOf(jsonResponse,"application_fee")
attempt_count = CkJsonObject::ckIntOf(jsonResponse,"attempt_count")
attempted = CkJsonObject::ckBoolOf(jsonResponse,"attempted")
billing = CkJsonObject::ckStringOf(jsonResponse,"billing")
charge = CkJsonObject::ckIsNullOf(jsonResponse,"charge")
closed = CkJsonObject::ckBoolOf(jsonResponse,"closed")
currency = CkJsonObject::ckStringOf(jsonResponse,"currency")
customer = CkJsonObject::ckStringOf(jsonResponse,"customer")
date = CkJsonObject::ckIntOf(jsonResponse,"date")
description = CkJsonObject::ckIsNullOf(jsonResponse,"description")
discount = CkJsonObject::ckIsNullOf(jsonResponse,"discount")
due_date = CkJsonObject::ckIsNullOf(jsonResponse,"due_date")
ending_balance = CkJsonObject::ckIsNullOf(jsonResponse,"ending_balance")
forgiven = CkJsonObject::ckBoolOf(jsonResponse,"forgiven")
linesHas_more = CkJsonObject::ckBoolOf(jsonResponse,"lines.has_more")
linesObject = CkJsonObject::ckStringOf(jsonResponse,"lines.object")
linesUrl = CkJsonObject::ckStringOf(jsonResponse,"lines.url")
livemode = CkJsonObject::ckBoolOf(jsonResponse,"livemode")
next_payment_attempt = CkJsonObject::ckIntOf(jsonResponse,"next_payment_attempt")
number = CkJsonObject::ckStringOf(jsonResponse,"number")
paid = CkJsonObject::ckBoolOf(jsonResponse,"paid")
period_end = CkJsonObject::ckIntOf(jsonResponse,"period_end")
period_start = CkJsonObject::ckIntOf(jsonResponse,"period_start")
receipt_number = CkJsonObject::ckIsNullOf(jsonResponse,"receipt_number")
starting_balance = CkJsonObject::ckIntOf(jsonResponse,"starting_balance")
statement_descriptor = CkJsonObject::ckIsNullOf(jsonResponse,"statement_descriptor")
subscription = CkJsonObject::ckIsNullOf(jsonResponse,"subscription")
subtotal = CkJsonObject::ckIntOf(jsonResponse,"subtotal")
tax = CkJsonObject::ckIsNullOf(jsonResponse,"tax")
tax_percent = CkJsonObject::ckIsNullOf(jsonResponse,"tax_percent")
total = CkJsonObject::ckIntOf(jsonResponse,"total")
webhooks_delivered_at = CkJsonObject::ckIsNullOf(jsonResponse,"webhooks_delivered_at")
i = 0
count_i = CkJsonObject::ckSizeOfArray(jsonResponse,"lines.data")
While i < count_i
CkJsonObject::setCkI(jsonResponse, i)
id = CkJsonObject::ckStringOf(jsonResponse,"lines.data[i].id")
object = CkJsonObject::ckStringOf(jsonResponse,"lines.data[i].object")
amount = CkJsonObject::ckIntOf(jsonResponse,"lines.data[i].amount")
currency = CkJsonObject::ckStringOf(jsonResponse,"lines.data[i].currency")
description_str = CkJsonObject::ckStringOf(jsonResponse,"lines.data[i].description")
discountable = CkJsonObject::ckBoolOf(jsonResponse,"lines.data[i].discountable")
livemode = CkJsonObject::ckBoolOf(jsonResponse,"lines.data[i].livemode")
periodStart = CkJsonObject::ckIntOf(jsonResponse,"lines.data[i].period.start")
periodEnd = CkJsonObject::ckIntOf(jsonResponse,"lines.data[i].period.end")
plan = CkJsonObject::ckIsNullOf(jsonResponse,"lines.data[i].plan")
proration = CkJsonObject::ckBoolOf(jsonResponse,"lines.data[i].proration")
quantity = CkJsonObject::ckIsNullOf(jsonResponse,"lines.data[i].quantity")
subscription = CkJsonObject::ckIsNullOf(jsonResponse,"lines.data[i].subscription")
type = CkJsonObject::ckStringOf(jsonResponse,"lines.data[i].type")
i = i + 1
Wend
CkRest::ckDispose(rest)
CkJsonObject::ckDispose(jsonResponse)
ProcedureReturn
EndProcedure
{
"id": "in_1BnETLGswQrCoh0XR7p1RCtV",
"object": "invoice",
"amount_due": 0,
"application_fee": null,
"attempt_count": 0,
"attempted": false,
"billing": "charge_automatically",
"charge": null,
"closed": false,
"currency": "usd",
"customer": "cus_CBbg9PmQ9sLbmo",
"date": 1516662783,
"description": null,
"discount": null,
"due_date": null,
"ending_balance": null,
"forgiven": false,
"lines": {
"data": [
{
"id": "ii_1BnETLGswQrCoh0XsAcSzoLf",
"object": "line_item",
"amount": 0,
"currency": "usd",
"description": "My First Invoice Item (created for API docs)",
"discountable": true,
"livemode": false,
"metadata": {},
"period": {
"start": 1516662783,
"end": 1516662783
},
"plan": null,
"proration": false,
"quantity": null,
"subscription": null,
"type": "invoiceitem"
}
],
"has_more": false,
"object": "list",
"url": "/v1/invoices/in_1BnETLGswQrCoh0XR7p1RCtV/lines"
},
"livemode": false,
"metadata": {},
"next_payment_attempt": 1516666383,
"number": "36eba31eaa-0001",
"paid": false,
"period_end": 1516662783,
"period_start": 1516662783,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": null,
"subscription": null,
"subtotal": 0,
"tax": null,
"tax_percent": null,
"total": 0,
"webhooks_delivered_at": null
}