namespace App\Listeners; use App\Events\PaymentCompleted; use App\Models\DeliveredGiftCard; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Mail; use App\Mail\GiftCardDelivered; use Illuminate\Support\Facades\Log; class ProcessApiGiftCard { public function handle(PaymentCompleted $event) { $order = $event->order; foreach ($order->products as $product) { // Check karein if product requires API fetch (digital gift card) if ($product->is_digital) { try { // 1. Vendor API ko Request Bhejein (e.g., PSN, Steam card supplier) $response = Http::withHeaders([ 'Authorization' => 'Bearer ' . env('VENDOR_API_KEY'), 'Accept' => 'application/json', ])->post('https://vendor-api.com/api/v1/purchase', [ 'vendor_product_id' => $product->sku, // Martfury me product k SKU me vendor ka ID rakh sakte hain 'quantity' => 1 ]); if ($response->successful()) { $apiData = $response->json(); $giftCardCode = $apiData['secret_code']; // Vendor ki API ka response field // 2. Database me log store karein (Dashboard me dikhane ke liye) DeliveredGiftCard::create([ 'order_id' => $order->id, 'product_id' => $product->id, 'vendor_transaction_id' => $apiData['transaction_id'] ?? null, 'delivered_code' => $giftCardCode, 'customer_email' => $order->user->email, 'status' => 'success' ]); // 3. Customer ko automatically email send karein Mail::to($order->user->email)->queue(new GiftCardDelivered($giftCardCode, $order)); } else { // Agar vendor API balance khatam ho ya error de $this->logFailedDelivery($order, $product, 'Vendor API Error: ' . $response->body()); } } catch (\Exception $e) { // Network issue ya koi aur system error $this->logFailedDelivery($order, $product, $e->getMessage()); } } } } private function logFailedDelivery($order, $product, $errorMsg) { DeliveredGiftCard::create([ 'order_id' => $order->id, 'product_id' => $product->id, 'delivered_code' => 'FAILED', 'customer_email' => $order->user->email, 'status' => 'failed' ]); Log::error("Gift Card API Failed for Order {$order->id}: " . $errorMsg); // Yahan aap apne Admin ko bhi alert email bhej sakte hain } } Buy Razer Gold Global AR - 10 USD | Pak Gift Card Supply - MartFury - Achats en ligne
00
0
Aucun produit dans le panier.

Panier d'achat

Razer Gold Global AR - 10 USD

Marque: Razer Gold

Rs.2,999.00 Rs.3,300.00

Enhance your gaming experience with a Razer Gold Global AR - 10 USD code. Enjoy fast delivery, secure transactions, and instant access to top-tier games.
(Disponible)
Quantité

Level up your gaming journey with the Razer Gold Global AR - 10 USD, available now at Pak Gift Card Supply. Designed for passionate gamers worldwide, this digital currency allows you to purchase in-game items, expansion packs, and exclusive content across thousands of your favorite games and entertainment apps.

When you choose to top up with razer gold, you gain access to a seamless, secure, and rewarding digital ecosystem. Whether you are unlocking battle passes, purchasing virtual currency, or exploring new gaming titles, this 10 USD global gift card provides the flexibility and convenience you need to stay ahead of the competition.

Why purchase from Pak Gift Card Supply?

  • Instant Digital Delivery: Receive your code securely within minutes of purchase.
  • 100% Secure Transactions: Shop with confidence using our trusted payment gateways.
  • 24/7 Customer Support: Our dedicated team is always ready to assist you with any inquiries.

Redeem your code effortlessly on your account and start spending on over 2,500 games and entertainment content platforms today. Fast, reliable, and secure—Pak Gift Card Supply is your ultimate destination for all gaming currency needs.


Ajouter votre avis

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont marqués *

Veuillez vous connecter pour écrire un avis !

Télécharger des photos

Il semble qu'il n'y ait pas encore d'avis.

Produits connexes

Votre expérience sur ce site sera améliorée en autorisant les cookies. Politique des cookies