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 Card AU $50 | Pak Gift Card Supply - MartFury - Belanja online
00
0
No products in the cart.

Keranjang Belanja

Razer Gold Global AU 50 USD

Brand: Razer Gold

Rs.15,500.00 Rs.16,500.00

Level up your gaming experience with a Razer Gold Card AU 50 USD. Enjoy instant digital delivery and secure payments at Pak Gift Card Supply.
(Tersedia)
Kuantitas

Unlock a world of entertainment and in-game currency with the razer gold card. Designed for avid gamers, this $50 AUD digital voucher allows you to purchase games, DLCs, and exclusive items across thousands of your favorite titles and entertainment platforms seamlessly.

At Pak Gift Card Supply, we ensure that your digital shopping experience is safe, fast, and reliable. Once your transaction is successfully completed, your unique code is delivered directly to you, enabling you to top up your account within seconds and dive straight back into the action without any unnecessary delays.

Why choose our platform for your gaming needs?

  • Instant digital delivery to your inbox
  • 100% secure and encrypted payment gateways
  • Dedicated customer support ready to assist you

Enhance your gameplay today by redeeming your credits on leading platforms. Invest in your virtual adventures with confidence and enjoy uninterrupted gaming sessions like never before.


Tambahkan ulasan Anda

Alamat email Anda tidak akan dipublikasikan. Bidang wajib ditandai dengan *

Silakan masuk untuk menulis ulasan!

Unggah foto

Sepertinya belum ada ulasan.

Produk terkait

Pengalaman Anda di situs ini akan ditingkatkan dengan mengizinkan cookie. Kebijakan cookie