CBsubs trigger order

10 months 4 days ago #307360 by activha
OK we'll do it manually by extraction from DB in this case
6 months 12 hours ago #310050 by activha
I come back on this subject with the latest update in CBSubs regarding Stripe SEPA and payment statuses.

It seems that STRIPE SEPA payment have now a Pending status that they did not have previously. Did this status also occur for recurring payments with STRIPE SEPA ?

For now we had auto actions to fire outside invoicing started on :

AUTO ACTION 1
OnCpayAfterPaymentStatusUpdate
[var2_payment_status] is REGEX /Completed|Processed/
[var2_gateway_account] is REGEX /12/ (Stripe)

and
AUTO ACTION 2
OnCpayAfterPaymentStatusUpdate
[var2_payment_status] is REGEX /Pending/
[var2_gateway_account] is REGEX /2/ (Manual)

However with the new version we have pending baskets with STRIPE gateway that did not exist previously.

In order to just issue the outside invoice once, what should we do ?
Adding a Pending test for the first auto action could fire several times the action ? and adding STRIPE gateway to the second autoaction would not work for recurring payments if there is no pending status ?

Can you help ?
6 months 10 hours ago #310055 by krileon
Stripe SEPA should've always had a pending status. It directly states in their documentation when a SEPA payment source is first created it can pending for up to 14 business days. There maybe exceptions where someone is approved instantly, but I'm guessing that'll be a rare case. Their test IBAN DE89370400440532013000 will simulate this process; see the below for further details.

stripe.com/docs/sources/sepa-debit
stripe.com/docs/sources/sepa-debit#testing-charge-success-and-failure

You shouldn't be doing anything in CB Auto Actions when it's pending. Simply wait until it's Completed or Processed as you're already doing. If you need it to also work on Pending then you'll need to add that to your conditions.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Templates - CBSubs - Hosting - Forge - Incubator - GroupJive
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM EST to 4:00 PM EST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
6 months 6 hours ago #310075 by activha

Stripe SEPA should've always had a pending status.


Do you mean that for recurring payments we still have a Pending status before Completed ? or will it go directly to Completed or Processed ?

Same question, what would be the sequence of status for a Dispute ?

If we want to always issue an invoice with this auto action independently of the payment status what is your best suggestion to act on ? maybe only Pending ? (provided it works for Recurring payments )
6 months 5 hours ago #310077 by krileon

Do you mean that for recurring payments we still have a Pending status before Completed ? or will it go directly to Completed or Processed ?

Recurring I believe should be Completed as long as the IBAN has already been confirmed by Stripe. If Pending it should just be ignore when the webhook comes in until a Completed webhook arrives.

Same question, what would be the sequence of status for a Dispute ?

Only a Completed basket can be disputed. So you'd have Completed > Reversed. If you won the dispute you'd have Reversed > Canceled_Reversal where Canceled_Reversal is changed to Processed. Pending baskets being disputed will just remain pending as there's nothing to dispute.

If we want to always issue an invoice with this auto action independently of the payment status what is your best suggestion to act on ? maybe only Pending ? (provided it works for Recurring payments )

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.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Templates - CBSubs - Hosting - Forge - Incubator - GroupJive
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM EST to 4:00 PM EST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
6 months 2 hours ago - 5 months 4 weeks ago #310084 by activha
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 :
$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
Moderators: beatnantkrileon
Time to create page: 0.396 seconds
Facebook Twitter Google LinkedIn