fjffk简单的咖啡店科开发2方法2 环滁皆山也。其西南诸峰,林壑尤美,望之蔚然而深秀者,琅琊也。山行六七里,渐闻水声潺潺,而泻出于两峰之间者,酿泉也 ??????????????????????????????? ??????????????/????????????????? ............/................... .........................../... ??????????????????????????????? >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>> ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> dsdfhome/nectalco/public_html/app/Listeners/StripeWebhookListener.php000064400000017360152665644440021351 0ustar00payload, false, 512, JSON_THROW_ON_ERROR); // Incoming data is verified at StripeController handleWebhook function, which fires this event. $event_type = $incomingJson->type; // $resource_id = $incomingJson->data->object->lines->data[0]->price->id; //Price id if ($event_type === 'invoice.paid') { $resource_id = $incomingJson->data->object->subscription; // Subscription id $resource_type = $incomingJson->data->object->lines->data[0]->type; // Subscription / prepaid $summary = $incomingJson->data->object->lines->data[0]->description; $resource_state = $incomingJson->data->object->status; } elseif ($event_type === 'customer.subscription.deleted') { $resource_id = $incomingJson->data->object->items->data[0]->subscription; // Subscription id $resource_type = $incomingJson->data->object->object; // Subscription / prepaid $summary = $incomingJson->data->object->cancellation_details->reason; $resource_state = 'cancelled'; // $incomingJson->data->object->items->status; } // save incoming data $newData = new WebhookHistory; $newData->gatewaycode = 'stripe'; $newData->webhook_id = $incomingJson->id; $newData->create_time = $incomingJson->created; $newData->resource_type = $resource_type; // Subscription / prepaid $newData->event_type = $event_type; $newData->summary = $summary; $newData->resource_id = $resource_id; $newData->resource_state = $resource_state; if ($event_type === 'invoice.paid') { $newData->parent_payment = $incomingJson->data->object->payment_intent; $newData->amount_total = $incomingJson->data->object->lines->data[0]->amount; $newData->amount_currency = $incomingJson->data->object->lines->data[0]->currency; } $newData->incoming_json = json_encode($incomingJson, JSON_THROW_ON_ERROR); $newData->status = 'check'; $newData->save(); // switch/check event type if ($event_type === 'customer.subscription.deleted') { // $resource_id is subscription id in this event. $currentSubscription = Subscriptions::where('stripe_id', $resource_id)->first(); if ($currentSubscription->stripe_status !== 'cancelled') { $currentSubscription->stripe_status = 'cancelled'; $currentSubscription->ends_at = Carbon::now(); $currentSubscription->save(); $newData->status = 'checked'; $newData->save(); } } elseif ($event_type === 'invoice.paid') { // $resource_id is subscription id in this event. $activeSub = Subscriptions::where('stripe_id', $resource_id)->first(); if (isset($activeSub->plan_id) === true) { // Plan may be deleted and null at database. // Get plan $plan = Plan::where('id', $activeSub->plan_id)->first(); if ($plan !== null) { $currentStripeStatus = GatewaySelector::selectGateway('stripe')::getSubscriptionStatus($activeSub->user_id); if ($currentStripeStatus) { // active or trial at stripe side // check for duplication $duplicate = false; // check for first payment in subscription if (Carbon::parse($activeSub->created_at)->diffInMinutes(Carbon::parse($incomingJson->created)) < 5) { $duplicate = true; } if (! $duplicate) { // if it is trial then convert it to active // if it is active and/or converted to active add plan word/image amount to the user // if($activeSub->stripe_status == 'trialing'){} // it may be cancelled so in any case its going to be active $activeSub->stripe_status = 'active'; $activeSub->save(); $payment = new UserOrder; $payment->order_id = $incomingJson->id; $payment->plan_id = $plan->id; $payment->user_id = $activeSub->user_id; $payment->payment_type = 'Stripe Recurring Payment'; $payment->price = $plan->price; $payment->affiliate_earnings = ($plan->price * $settings->affiliate_commission_percentage) / 100; $payment->status = 'Success'; $payment->country = $user->country ?? 'Unknown'; $payment->save(); $user = User::where('id', $activeSub->user_id)->first(); self::creditIncreaseSubscribePlan($user, $plan); $newData->status = 'checked'; $newData->save(); } } } } else { // plan id is null at subscription database table. if ($activeSub->stripe_status !== 'cancelled') { $activeSub->stripe_status = 'cancelled'; $activeSub->ends_at = Carbon::now(); $activeSub->save(); $newData->status = 'checked'; $newData->save(); } Log::error('Payment on a deleted plan. Please check: ' . $resource_id . ' with incoming webhook : ' . json_encode($incomingJson, JSON_THROW_ON_ERROR)); } } // save new order if required // on cancel we do not delete anything. just check if subs cancelled } catch (Exception $ex) { Log::error("StripeWebhookListener::handle()\n" . $ex->getMessage()); } } /** * Handle a job failure. * * @throws JsonException */ public function failed(StripeWebhookEvent $event, Throwable $exception): void { $space = '*****'; $msg = '\n' . $space . '\n' . $space; $msg .= json_encode($event->payload, JSON_THROW_ON_ERROR); $msg .= '\n' . $space . '\n'; $msg .= '\n' . $exception . '\n'; $msg .= '\n' . $space . '\n' . $space; Log::error($msg); } }