Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which ID should I save in the DB so I can compare and write it off later? #1685

Closed
tiagocaus opened this issue Apr 23, 2024 · 5 comments
Closed
Assignees
Labels
support Question better suited for support team

Comments

@tiagocaus
Copy link

Is your feature request related to a problem? Please describe.

I'm creating a microsaas, and I would really like to use stripe, as it is
accepted in all countries.

My problem is understanding which ID to save in the DB so that after it is paid, the webhook receives the IDs and thus compares them with the DB and thus cancels them.

This is because I intend to use a card and "Brazil Boleto" which is a payment method where the webhook will only receive data within 24 to 48 hours.

Could I have your help?

Describe the solution you'd like

Unique ID so we can save it in the DB

Describe alternatives you've considered

Frustrated, no solution!

Additional context

No response

@remi-stripe
Copy link
Contributor

@tiagocaus This looks like an integration support better directed at our support team for 1:1 help instead. You can contact them here: https://support.stripe.com/contact
To unblock you, what you want is the pi_123 which is the PaymentIntent id and then later listen to the payment_intent.succeeded Event which indicates when the payment did succeed.

@tiagocaus
Copy link
Author

@remi-stripe

When a charge is created, there is no such thing as pi_***. Only one appears: Stripe\Checkout\Session JSON: {"id": "cs_test_a19YeWg0JtjVE8z.... but this ID is not the same when the payment is completed.

$checkout_session = $stripe->checkout->sessions->create([
    'customer_email' => 'customer@example.com',
    'metadata'       => [
        'pedido_id' => "ABC123",
    ],
    'line_items'     => [
        [
            'price_data' => [
                'currency'     => 'brl',
                'product_data' => [
                    'name' => 'T-shirt',
                ],
                'unit_amount'  => 2007,
            ],
            'quantity'   => 1,
        ]
    ],
    'mode'           => 'payment',
    'success_url'    => SISTEMA['painel'] . '/app/Modules/pagamentos/stripe/sucesso.php',
    'cancel_url'     => SISTEMA['painel'] . '/app/Modules/pagamentos/stripe/cancelado.php',
]);


$rs = $mysqli->prepare("INSERT INTO financeiro_logs (IDx, retorno_webhook) VALUES (?,?) ");
$rs->bind_param('ss', $IDx, $checkout_session);
$rs->execute();


header("HTTP/1.1 303 See Other");
header("Location: " . $checkout_session->url);

@remi-stripe
Copy link
Contributor

@tiagocaus Sorry you had never mentioned using Checkout in your original question. The docs https://docs.stripe.com/payments/checkout/fulfill-orders cover this in a lot of details and tell you how to handle fulfillment exactly.
Please work with our support team for 1:1 help instead of here: https://support.stripe.com/contact

@tiagocaus
Copy link
Author

@remi-stripe I've already tried talking to support. They can't help. This would be easily resolved if stripe adopted the standard of creating a unique ID, from the beginning to the end of the process! Why don't they do that?

@remi-stripe
Copy link
Contributor

@tiagocaus I'm sorry but this is exactly what the doc I linked you to explains in a lot of details. Please work with our support team for 1:1 help as you are asking for integration support.

@stripe stripe locked and limited conversation to collaborators Apr 23, 2024
@ramya-stripe ramya-stripe added support Question better suited for support team and removed feature-request labels Jul 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
support Question better suited for support team
Projects
None yet
Development

No branches or pull requests

3 participants