1$stripe = new StripeClient('STRIPE_SECRET_KEY');
2
3$cards = $stripe->paymentMethods->all(['customer' => 'CUSTOMER_ID', 'type' => 'card']);
4
5$fingerprints = [];
6
7foreach ($cards as $card) {
8 $fingerprint = $card['card']['fingerprint'];
9
10 if (in_array($fingerprint, $fingerprints, true)) {
11 $stripe->paymentMethods->detach($card['id']);
12 } else {
13 $fingerprints[] = $fingerprint;
14 }
15}
1public function checkBankingDetailsAlert()
2 {
3 $user = Auth::user();
4 $stripe = new \Stripe\StripeClient(env('STRIPE_SECRET'));
5 $cards = $stripe->paymentMethods->all(['customer' => $user->stripe_customer_id, 'type' => 'card']);
6 $fingerprints = [];
7 foreach ($cards as $card) {
8 $fingerprint = $card['card']['fingerprint'];
9 if (in_array($fingerprint, $fingerprints, true)) {
10 $stripe->paymentMethods->detach($card['id']);
11 } else {
12 $fingerprints[] = $fingerprint;
13 }
14 }
15 return response()->json([
16 'status' => 'Success',
17 'fingerprint' => $fingerprints,
18 ]);
19 }
20