I’m using the latest version of the stripe API. I have a shopping cart where people can pay instantly with a credit card or generate a bill and pay later. What type of ID should I save in the database so that if the customer makes the payment by bank slip and the bill is paid, upon receiving the command via the webhook I can identify who made the payment.
This is because when the order is made, some ID needs to be registered in the DB, in this example I am calling it IDx:
$checkout_session = $stripe->checkout->sessions->create([
'customer_email' => '[email protected]',
'metadata' => [
'pedido_id' => "ABC123", //Id do pedido
],
'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);
Links de referencia para seu aprendizado:
- https://docs.stripe.com/payments/boleto,
- https://docs.stripe.com/payments/boleto/accept-a-payment,
- https://docs.stripe.com/payments/checkout/fulfill-orders