Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Payment Plugins

    (@mrclayton)

    Hi @awoodworthcbw

    The following code snippet will save the customer’s payment method during the checkout process.

    add_filter('wc_stripe_force_save_payment_method', function($bool, $order, $payment_method){
    if(is_checkout()){
    $bool = true;
    }
    return $bool;
    }, 10, 3);

    Make sure you are requiring the user to create an account on the checkout page. That will ensure a Stripe customer ID is generated for the user so the saved payment method can be associated with their account.

    Kind Regards

    Thread Starter awoodworthcbw

    (@awoodworthcbw)

    Hi @mrclayton

    I was thinking about this and In the past I made a change to the plugin (GNU GPL) where we pass the payment_intent id to our CRM software when the payment completes. I was thinking that instead of passing that (PI token) we can somehow create a setup_intent on the transaction based on that $charge object I had changed previously in the plugin code and send it off to our CRM to process at a later time.

    This is where I have updated that code: path: /woo-stripe-payment/includes/abstract/abstract-wc-stripe-payment.php on the payment_complete method in the WC_Stripe_Payment PHP class between lines: 110 – 185 in this method’s $charge parameter. I know we have access to the payment intent but, we think the setup intent will align a lot better with our business needs.

    here’s the change I made previously where I access that Payment Intent


    public function payment_complete($order, $charge)
    {
    /* CUSTOM CHANGE HERE! */
    WC_Stripe_Utils::add_balance_transaction_to_order($charge, $order);
    $this->payment_method->save_order_meta($order, $charge);
    // Retrieve the Payment Intent ID from the charge object
    $payment_intent_id = isset($charge->payment_intent) ? $charge->payment_intent : '';
    //adds the payment_intent id to our meta data for celigo/netsuite
    if($payment_intent_id) {
    $order->update_meta_data('_stripe_pi_id', $payment_intent_id);
    $order->save();

    $order_meta = $order->get_meta('_stripe_pi_id', true);
    //error_log('Payment Intent ID saved to order meta: ' . $order_meta);
    }
    /*REST of payment_complete method CODE */
    }

    I was wondering do we have access to create this Setup Intent record instead of the Payment Intent record?

    Thanks!

    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @awoodworthcbw

    I don’t think it needs to be that complicated. The simple line of code I provided ensures the customer’s payment method gets saved during the checkout process. If you set the plugin to just authorize the payment, then there will be no charge. It doesn’t matter if you let the authorization expire because you will have the customer’s payment method saved which means you can charge it later on for the correct amount.

    You can just send the customer’s payment method ID to your CRM and use that to charge the customer.

    Kind Regards

    Thread Starter awoodworthcbw

    (@awoodworthcbw)

    Hi @mrclayton

    Thank you for the clarification and the code snippet. I understand your point about keeping it simple and just saving the payment method ID for future charges.

    However, in our specific use case, we need to manage the payment process more dynamically and can’t rely on the user to always have a WooCommerce Account. We have scenarios where we might need to validate the card without an immediate authorization or charge, hence our interest in creating a Setup Intent instead of a Payment Intent to send to our CRM.

    Given that, do you think there’s a straightforward way to integrate the creation of a Setup Intent within the checkout process, potentially replacing or supplementing the existing Payment Intent workflow? We’re trying to ensure the saved payment method aligns seamlessly with our CRM’s processing at a later stage.

    Is there a way for us to create a setup intent just like we’re doing with the payment intent here?

    Thanks again for your ongoing support!

    Best regards,
    Anthony

    Thread Starter awoodworthcbw

    (@awoodworthcbw)

    Hi @mrclayton

    I’ve been doing some reflecting and we still need the payment intent to process cards from our CRM because the CRM’s Stripe Plugin/Extension needs that specific record/token from the site on the CRM side to capture. Since we only really just need to be able to capture the funds after the authorization has expired your original solution may be exactly what we need, my bad for the ongoing confusion on my part.

    I guess some of my questions are: Does the code you provided still update that customer record in Stripe with a payment method that we can use later regardless if the user is logged in to our WooCommerce site or not? How could I access this payment method ID? (before I asked I didn’t notice the $payment_method argument my bad) “You can just send the customer’s payment method ID to your CRM and use that to charge the customer.” I think the CRM grabs this from the Customer Record in Stripe anyway and is accessible there or, do I need to add some code to get this value? We don’t really care about our stripe data getting messy just WooCommerce’s and our CRM’s needs to be organized. We definitely just need it to still be able to capture post card pre-auth expiration.

    Thanks for the ongoing support!

    best regards,

    Anthony

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.