Я пытаюсь интегрировать платежную систему в свой проект Laravel 6.
Но я понятия не имею, как получить ClientSecret со стороны моего сервера
У меня есть это в моем CheckOutController
public function charge(Request $request)
{
Stripe::setApiKey('sk_test_GEQCwhRyT9PcK1vju3YcsIEN00gXSsjo1P');
$intent = PaymentIntent::create([
'amount' => round(Cart::total()),
'currency' => 'eur',
]);
echo json_encode($intent);
}
И я должен получить информацию и работать с этим (из документации Stripe)
submitButton.addEventListener('click', function(ev) {
stripe.confirmCardPayment(clientSecret, {
payment_method: {
card: card,
billing_details: {
name: 'Jenny Rosen'
}
}
}).then(function(result) {
if (result.error) {
// Show error to your customer (e.g., insufficient funds)
console.log(result.error.message);
} else {
// The payment has been processed!
if (result.paymentIntent.status === 'succeeded') {
// Show a success message to your customer
// There's a risk of the customer closing the window before callback
// execution. Set up a webhook or plugin to listen for the
// payment_intent.succeeded event that handles any business critical
// post-payment actions.
}
}
});
});
Спасибо, что прочитали меня:)