So verhindern Sie, dass Benutzer mit Laravel doppelte Karte in Stripe hinzufügen
public function checkBankingDetailsAlert()
{
$user = Auth::user();
$stripe = new \Stripe\StripeClient(env('STRIPE_SECRET'));
$cards = $stripe->paymentMethods->all(['customer' => $user->stripe_customer_id, 'type' => 'card']);
$fingerprints = [];
foreach ($cards as $card) {
$fingerprint = $card['card']['fingerprint'];
if (in_array($fingerprint, $fingerprints, true)) {
$stripe->paymentMethods->detach($card['id']);
} else {
$fingerprints[] = $fingerprint;
}
}
return response()->json([
'status' => 'Success',
'fingerprint' => $fingerprints,
]);
}
Cruel Cottonmouth