#tobin_code

1 messages ยท Page 1 of 1 (latest)

blissful monolithBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1343519103712755742

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

light walrus
#

hi there!

#

can you share a PaymentInent ID (pi_xxx) with this issue?

peak kiln
#

ok wait

#

am a wordpress plugin developer this issue reported by our client.

#

i can't do the live test how can replicate the issue using test mode

light walrus
#

I don't understand. you mendionned failed payments. can you share an example PaymentIntent ID so I can look into it?

peak kiln
#

my client experience the issue who is stripe plugin by webtoffee he is experiencing issue in checkout page as in screenshot

#

when will this error raise? how to fix it?

light walrus
#

the error you shared is pretty clear, and contains a link to learn more about this. have you read that doc?

peak kiln
#

ys already done the changes as per documentation still issue exists

light walrus
#

I would need a specific PaymentIntent ID (pi_xxx) with this issue to look into it

peak kiln
#

this issue is experienced by my client he won't share it

#

this is my code
public function save_cards_for_later($payment_details, $my_account_page = false) {
if ($payment_details) {

        if (!$my_account_page) {
            $response = $payment_details->payment_method_details;
            $token = $payment_details->payment_method;
        } else {
            $response = $payment_details;
            $token = $payment_details->id;
        }

        // Get the logged-in user's Stripe customer ID
        $user_id = get_current_user_id();
        $customer = get_user_meta($user_id, '_stripe_customer_id', true);

        // If no customer ID is found, create a new Stripe customer
        if (!$customer) {
            $user = get_userdata($user_id);
            $customer_data = [
                "email" => $user->user_email,
                "name"  => $user->first_name . " " . $user->last_name,
            ];

            // Search for existing Stripe customer
            $existing_customers = \Stripe\Customer::all([
                'email' => $customer_data['email'],
                'limit' => 1,
            ]);

            if (!empty($existing_customers->data)) {
                $stripe_customer = $existing_customers->data[0];
            } else {
                // Create a new Stripe customer if none exists
                $stripe_customer = \Stripe\Customer::create($customer_data);
            }

            if (!$stripe_customer || empty($stripe_customer->id)) {
                throw new Exception(__('Failed to create or retrieve Stripe customer.', 'eh-stripe-gateway'));
            }
            $customer = $stripe_customer->id;
            update_user_meta($user_id, '_stripe_customer_id', $customer);
        }

        // Check if the card is issued in India
        $is_indian_card = ($response->card->country === 'IN');
#

// Create a SetupIntent for Indian cards
if ($is_indian_card) {
$intent_args = [
'payment_method' => $token,
'customer' => $customer,
'confirm' => true,
'payment_method_types' => ['card'],
'usage' => 'off_session', // Required for saving cards in India
];

            $setup_intent = \Stripe\SetupIntent::create($intent_args);

            if ($setup_intent->status !== 'succeeded') {
                throw new Exception(__('3DS authentication required for Indian cards.', 'eh-stripe-gateway'));
            }

            $wc_token = new WC_Payment_Token_CC( );
            $wc_token->set_token( $token );
            $wc_token->set_gateway_id( $this->id );
            $wc_token->set_card_type( strtolower( $response->card->brand ) );
            $wc_token->set_last4( $response->card->last4 );
            $wc_token->set_expiry_month( $response->card->exp_month );
            $wc_token->set_expiry_year( $response->card->exp_year );

            $wc_token->set_user_id( get_current_user_id() );
            $wc_token->save();

        }
    }

    return true;
}
#

this is my code

blissful monolithBOT
peak kiln
#

hi can u check my code fix the issue

hollow dock
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

peak kiln
#

this is happening in normal payment not sure about recuring

hollow dock
#

would you mind sharing a PaymentIntent ID then?

peak kiln
#

i don't have it

#

is there any chance to replicate it test mode?

hollow dock
peak kiln
#

this issue is reported by client they don't shate PaymentIntent ID

hollow dock
#

you can search for the PaymentIntent ID on the dashboard

peak kiln
#

do u have any other suggestion to fix the issue without knowing PaymentIntent ID

hollow dock
#

I can't know what the issue is without the PaymentIntent ID or the request ID or the Charge ID

#

anything that references that particular payment

peak kiln
#

i will share this with my client let me know what all things need for u to debug the issue?

hollow dock
#

PaymentIntent ID or the request ID or the Charge ID
just that would be enough

peak kiln
#

ok

#

one more thing

#

can i replicate this issue in test mode?

hollow dock
#

I'm not sure what the issue is to be able to know whether you can replicate it or not

peak kiln
#

this is the error message in checkout

hollow dock
#

I think you need to update the way you're integrating with Stripe

#

it seems you're using tokens and PaymentMethods