Global API
Code Examples
Applying Credit to an Invoice
1min
you will need the quickbooks credit note and invoice ids to link the two together need to create the credit memo? see create docid\ jnfpmqvfmuqoyu u6xfh9 need to create the invoice? see create docid\ ovzkxm7mhyipl zsxyelc to achieve this, you need to create a zero dollar payment, which is the link between the credit memo and the invoice the credit memo is linked to the zero dollar payment, which is then linked to the invoice request // create a map to store all the data of a payment map\<string, object> paymentmap = new map\<string, object>(); paymentmap put('displayname','breadwinner inc'); paymentmap put('customerref' , new map\<string, object>{'value' => '71'}); // providing zero as the total payment amount since we only want the credit note amount to be applied to an invoice paymentmap put('totalamt','0 00'); // put the invoice into the proper map map\<string,object> invoicelinemap= new map\<string, object>(); invoicelinemap put('amount','100'); map\<string,object> invoicelinkedtxnmap = new map\<string, object>(); invoicelinkedtxnmap put('txnid','243'); invoicelinkedtxnmap put('txntype','invoice'); list\<object> invoicelinkedtxnlist = new list\<object>(); invoicelinkedtxnlist add(invoicelinkedtxnmap); invoicelinemap put('linkedtxn',invoicelinkedtxnlist ); // put the creditmemo into the proper map map\<string,object> creditnotelinemap = new map\<string, object>(); creditnotelinemap put('amount','100'); map\<string,object> creditnotelinkedtxnmap = new map\<string, object>(); creditnotelinkedtxnmap put('txnid','244'); creditnotelinkedtxnmap put('txntype','creditmemo'); list\<object> creditnotelinkedtxnlist = new list\<object>(); creditnotelinkedtxnlist add(creditnotelinkedtxnmap); creditnotelinemap put('linkedtxn',creditnotelinkedtxnlist ); // link the invoice and credit memo to the payment list\<object> linelist = new list\<object>(); linelist add(invoicelinemap); linelist add(creditnotelinemap); paymentmap put('line' ,linelist); // initializing the requestjson data to be passed map\<string, object> requestjsonmap = new map\<string, object>(); requestjsonmap put('payments', new list\<object>{paymentmap}); string reqjson = json serialize(requestjsonmap); map\<string, object> reqobj = new map\<string, object>(); reqobj put('version', '1 0'); reqobj put('action', 'createpayment'); reqobj put('requestjson', reqjson); //required, if quickbooks multi org is enabled in breadwinner //reqobj put('qborgid', '4620816365285051610'); system debug(reqjson); // placing a request to breadwinner global api map\<string, object> respmap = breadwinner qbo breadwinnerqbapi call(reqobj); system debug(respmap); response { action=createpayment, responsejson={ "statuscode" 200, "payments" \[ { "unappliedamt" 0, "txndate" "2023 12 11", "totalamt" 0, "synctoken" "0", "sparse" false, "metadata" { "lastupdatedtime" "2023 12 11t23 18 57 08 00", "createtime" "2023 12 11t23 18 57 08 00" }, "line" \[ { "linkedtxn" \[ { "txntype" "invoice", "txnid" "243" } ], "amount" 100 }, { "linkedtxn" \[ { "txntype" "creditmemo", "txnid" "244" } ], "amount" 100 } ], "id" "246", "customerref" { "value" "71", "name" "my company" }, "currencyref" { "value" "usd", "name" "united states dollar" } } ] }, timestamp=1702365538143, validrequest=true, version=1 0 } do you want to know list of supported parameters for a payment? see payment docid\ asrn2gzjqlqi 5jexdwaa