📅  最后修改于: 2022-03-11 14:54:41.402000             🧑  作者: Mango
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,
]);
}