Code:
Probably Completed, Processed, and Pending I guess. I don't know why you want to log a Pending basket though. It may never get paid depending on what happens.
Our customers sign a contract for their subscription so a Pending basket will get paid but sometimes within a few month timeframe, so we need to issue an invoice.
If the auto action is set to trigger on Completed, Processed and also Pending, will it mean that it will fire twice or maybe three times ? One for the first pending state and the second time for the Completed state for instance ? and if yes how can we avoid this to get only ONE outside invoice ?
I also noted that in the case where the first payment is different of the recurring ones and using the trigger OnCpayAfterPaymentStatusUpdate we only get the recurring payment amount in [var2_mc_gross] at the update time and not the first payment.
For instance setting first payment to 180 € and recurring ones to 144 € and using the OnCpayAfterPaymentStatusUpdate sends only 144 as payment_gross or mc_gross to our API for invoicing with the attached code.
Does it mean that this is not the correct trigger to use ?
Do you have a trigger that we could use just after the basket is stored or payment initiated ? So that we could output an invoice without any basket status interfering.
We use this code for outside API :
Code:
$date = cbFormatDate( $variables['var2']->time_initiated, 1, false );
function extract_basket_item($item)
{
return $item->renderColumn();
}
$payment_basket = array (
'date' => $variables['var2']->date,
'user_id' => $variables['var2']->user_id,
'txn_type' => $variables['var2']->txn_type,
'txn_id' => $variables['var2']->txn_id,
'payment_type' => $variables['var2']->payment_type,
'address_street' => $variables['var2']->address_street,
'address_city' => $variables['var2']->address_city,
'address_state' => $variables['var2']->address_state,
'address_zip' => $variables['var2']->address_zip,
'address_country' => $variables['var2']->address_country,
'payer_business_name' => $variables['var2']->payer_business_name,
'first_name' => $variables['var2']->first_name,
'last_name' => $variables['var2']->last_name,
'payer_email' => $variables['var2']->payer_email,
'contact_phone' => $variables['var2']->contact_phone,
'vat_number' => $variables['var2']->vat_number,
'item_name' => $variables['var2']->item_name,
'item_number' => $variables['var2']->item_number,
'quantity' => $variables['var2']->quantity,
'custom' => $variables['var2']->custom,
'invoice' => $variables['var2']->invoice,
'tax' => $variables['var2']->tax,
'payment_date' => $variables['var2']->payment_date,
'shipping' => $variables['var2']->shipping,
'mc_currency' => $variables['var2']->mc_currency,
'mc_fee' => $variables['var2']->mc_fee,
'mc_gross' => $variables['var2']->mc_gross,
'mc_handling' => $variables['var2']->mc_handling,
'mc_shipping' => $variables['var2']->mc_shipping,
'payment_fee' => $variables['var2']->payment_fee,
'payment_gross' => $variables['var2']->payment_gross,
'basket_items' => $variables['var2']->loadPaymentItems()
);
$context_options = array (
'http' => array (
'method' => 'POST',
'header' => ['Content-type: application/x-www-form-urlencoded',
'Authorization: Bearer xxxxxxxxxx'],
'content' => http_build_query($payment_basket)
)
);
$context = stream_context_create($context_options);
$fp = fopen('https://xxxxxxxxxxx-webhook/xxxx', 'r', false, $context);
fpassthru($fp);
fclose($fp);
Thanks in advance