How to add Promo code to invoice

Hello, im trying to add promo code to an invoice, im using PHP iSDK

following is methos to add item to blank order:

$app->addOrderItem()

i tries this method: xml-rpc - Keap Developer Portal but this gives error that method not available?

Thanks

First, you must create the blank order with ->placeOrder. This is where you would assign the promo code. Then, where you wish to add order items using ->addOrderItem, you must find and use the invoice id that is also created with the blank order (not the order id). While they ‘usually’ are the same the first time you create it, the can be different so it is best practice to query the invoice table by the JobId field (which is the order id)

1 Like

this never works for me gives error that this call method is not available

That would indicate the wrong number of parameters or the parameter types don’t match…the method does work.

im using the method as below

$carray = array(
$appkey,
$contactId,
$creditCardId,
array($productId),
array($promoCode));

$app->placeOrder($carray);

where $appkey is my IS secret key.

Is this correct method?

Are you using legacy (isdk) or current api (oauth)

Im using legacy iSDK

so you don’t put the api key in your self. you have to setup credentials with the ->cfgCon method

Your fields for the isdk will be contact id, order description, order date, lead affiliate id and sales affiliate id…if you want to assign the promo code you will have to either update the newly created order on the Job table or just directly create a row on the Job table with the field data you need.

also tried that method but same error :frowning:

because your params are wrong

you’re using the isdk but going off of current api documentation

So the correct code will be?

$carray = array(
$appkey,
$contactId,
$creditCardId,
array($productId),
array($promoCode));
$leadAffiliateID;
$saleAffiliateID;
$app->placeOrder($carray);

Once again, if you’re using the isdk then cfgCon is where you would register your credentials. You do NOT use the api key in the call yourself. Nor do you use the CC id or product id etc etc…again, as i already said, you’re using the wrong documentation for the isdk…you’re looking at the current api not the legacy documentation (which is no longer available). You will be best off using an ide that has code complete to show you the correct parameters for any isdk api calls.

sorry for this, if im wrong, im not expert in IS API, i found this public function in isdk.php

public function placeOrder($contactId, $creditCardId, $payPlanId, $productIds, $subscriptionIds, $processSpecials, $promoCodes, $leadAff = 0, $saleAff = 0)
{
    $carray = array(
        php_xmlrpc_encode((int)$contactId),
        php_xmlrpc_encode((int)$creditCardId),
        php_xmlrpc_encode((int)$payPlanId),
        php_xmlrpc_encode($productIds),
        php_xmlrpc_encode($subscriptionIds),
        php_xmlrpc_encode($processSpecials),
        php_xmlrpc_encode($promoCodes),
        php_xmlrpc_encode((int)$leadAff),
        php_xmlrpc_encode((int)$saleAff));
    return $this->methodCaller("OrderService.placeOrder", $carray);
}

and im using the example code to call this function explained here xml-rpc - Keap Developer Portal :

$app = new iSDK();
// perform authorization tasks

$carray = array(
$app->key,
$contactId,
$creditCardId,
$payPlanId,
array($productId1, $productId2),
array($subscriptionPlanId1, $subscriptionPlanId2),
$processSpecials,
array($promoCode1, $promoCode2)) // array of strings
);

$app->placeOrder($carray);

i always get this error:

ERROR: -1 - No method matching arguments: java.lang.String, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer, java.lang.Integer

also can you guide me how to add new CC to IS contact and return ID of that card?

thanks for your replies and great help i appreciate alot.

@pagedesigner,

You don’t put the api key into the call yourself. no method match… message is a java message telling you that the parameters are not matching up.

1 Like

i’ve also removed the key variable, same error occurs, im not sure where im going wrong. thanks

i assume the example code written xml-rpc - Keap Developer Portal is wrong

https://developer.infusionsoft.com/docs/xml-rpc/#invoice-create-an-invoice

yes i’ve used this method and im successfull with that, but i was testing $app->placeOrder() method to add promocode, with xml-rpc - Keap Developer Portal we can not add promocodes, right? can you tell me how to add new credit card to a contact via API?

I know that you mentioned that you are on a Legacy version of the SDK however can you try doing this what is described there: GitHub - infusionsoft/infusionsoft-php: PHP client library for the Infusionsoft API.
Also if you could get the request body that is sent to Infusionsoft we could see what Infusionsoft is actually receiving since we are receiving it in XML. This will help identify the issue a lot quicker.