From 7f70738eb628003d5e645e7f0849cf37f2854e57 Mon Sep 17 00:00:00 2001 From: Immanuel Onyeka Date: Sat, 19 Jun 2021 18:13:40 -0400 Subject: [PATCH] Change payment section from stripe to payeer --- app/Http/Controllers/BillingController.php | 51 +++--- .../2014_10_12_000000_create_users_table.php | 2 +- ...06_08_224029_create_transactions_table.php | 1 - database/seeders/DatabaseSeeder.php | 8 +- resources/images/payeer.png | Bin 0 -> 3610 bytes resources/images/perfect_money.svg | 88 +++++++++++ resources/js/panel/credits.vue | 147 +++++++++--------- resources/js/panel/settings.vue | 7 +- resources/scss/main.scss | 35 ++++- resources/views/home.blade.php | 3 +- resources/views/master.blade.php | 1 - routes/web.php | 3 +- 12 files changed, 237 insertions(+), 109 deletions(-) create mode 100644 resources/images/payeer.png create mode 100644 resources/images/perfect_money.svg diff --git a/app/Http/Controllers/BillingController.php b/app/Http/Controllers/BillingController.php index 56c2c55..2b5f1ef 100644 --- a/app/Http/Controllers/BillingController.php +++ b/app/Http/Controllers/BillingController.php @@ -23,21 +23,28 @@ class BillingController extends Controller $this->user = Auth::user(); } - protected function attempt(Request $request) { + protected function attempt($packs) { $user = Auth::user(); - $amount = $request->packs[ 'credits10' ]*1099 + - $request->packs[ 'credits50' ]*5499 + $request->packs[ 'credits100' ]*10999 - + $request->packs[ 'credits1000' ]*101000; + + foreach($packs as $value) { + if ($value < 0) { + abort(422); + } + } + + $amount = $packs[ 'credits10' ]*1099 + + $packs[ 'credits50' ]*5499 + $packs[ 'credits100' ]*10999 + + $packs[ 'credits1000' ]*101000; $transaction = new Transaction; - $transaction->credits = $request->packs['credits10']*1000 + - $request->packs['credits50']*5000 + - $request->packs['credits100']*10000 + - $request->packs['credits1000']*100000; + $transaction->credits = $packs['credits10']*1000 + + $packs['credits50']*5000 + + $packs['credits100']*10000 + + $packs['credits1000']*100000; $transaction->credits_extra = - $request->packs['credits50']*500 + - $request->packs['credits100']*1000 + - $request->packs['credits1000']*15000; + $packs['credits50']*500 + + $packs['credits100']*1000 + + $packs['credits1000']*15000; $transaction->user_id = $user->id; $transaction->charge = $amount; @@ -51,7 +58,7 @@ class BillingController extends Controller //Should validate that all amounts are positive integers in a reasonable range public function stripeSecret(Request $request) { $user = Auth::user(); - $transaction = $this->attempt($request); + $transaction = $this->attempt($request->packs); $intent = PaymentIntent::create([ 'amount' => $amount, @@ -125,25 +132,33 @@ class BillingController extends Controller //Receives a request with a packs. It is an array of each type of credit //amount to be bought public function payeer(Request $request) { - $transaction = $this->attempt($request); + $user = Auth::user(); + $transaction = $this->attempt($request->packs); $shopid = config('services.payeer.id'); $secret = config('services.payeer.secret'); $param_key = config('services.payeer.param_key'); - $total = $transaction->credits + $transaction->credits_extra; + $total = $transaction->credits/100 + $transaction->credits_extra/100; + $description = base64_encode("You will receive $total credits."); - $arHash = [$shopid, $transaction->id, $transaction->charge, 'USD', "You - will receive $total credits."]; + $arHash = [$shopid, $transaction->id, $transaction->charge/100, 'USD', + $description]; $params = ['reference' => ['transaction_id' => $transaction->id]]; $key = md5($param_key.$transaction->id); - $encodedParams = urlencode(base64_encode(openssl_encrypt( + $encodedParams = @urlencode(base64_encode(openssl_encrypt( json_encode($params), 'AES-256-CBC', $key, OPENSSL_RAW_DATA ))); $arHash[] = $encodedParams; $arHash[] = $secret; $signature = strtoupper(hash('sha256', implode(':', $arHash))); + $user->paying = true; $user->save(); + return [ 'signature' => $signature, 'params' => $encodedParams, 'shop' - => $shopid, 'transaction' => $transaction->id ]; + => $shopid, 'transaction' => $transaction->id, 'amount' => + $transaction->charge/100, 'description' => $description ]; + } + + public function processPayeer(Request $request) { } } diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 1dac20a..702dc14 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -17,7 +17,7 @@ class CreateUsersTable extends Migration $table->id(); $table->string('name'); $table->string('email')->unique(); - $table->string('customer_id')->unique(); + $table->string('customer_id')->unique()->nullable(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->enum('role', ['client', 'guest', 'admin']); diff --git a/database/migrations/2021_06_08_224029_create_transactions_table.php b/database/migrations/2021_06_08_224029_create_transactions_table.php index 1240a26..647e4d4 100644 --- a/database/migrations/2021_06_08_224029_create_transactions_table.php +++ b/database/migrations/2021_06_08_224029_create_transactions_table.php @@ -20,7 +20,6 @@ class CreateTransactionsTable extends Migration $table->integer('credits')->unsigned(); $table->integer('credits_extra')->unsigned()->default(0); $table->string('status'); - $table->string('intent_id')->unique(); $table->boolean('completed'); $table->string('note')->nullable(); $table->timestamps(); diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index fb04301..5bac2c7 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -20,11 +20,12 @@ class DatabaseSeeder extends Seeder public function run() { Stripe::setApiKey(config('services.stripe.secret')); + User::create([ 'name' => 'test_user_unverified', 'email' => 'unverified@example.com', 'role' => 'client', - 'customer_id' => Customer::create(['email' => 'unverified@example.com'])->id, + 'credits' => 55000, 'active' => true, 'password' => Hash::make("test123") ]); @@ -32,8 +33,7 @@ class DatabaseSeeder extends Seeder 'name' => 'test_user_verified', 'email' => 'verified@example.com', 'email_verified_at' => now(), - 'credits' => 250, - 'customer_id' => Customer::create(['email' => 'verified@example.com'])->id, + 'credits' => 25000, 'role' => 'client', 'active' => true, 'password' => Hash::make("test123") @@ -42,8 +42,8 @@ class DatabaseSeeder extends Seeder 'name' => 'test_admin_verified', 'email' => 'admin_verified@example.com', 'email_verified_at' => now(), - 'customer_id' => Customer::create(['email' => 'admin_verified@example.com'])->id, 'role' => 'admin', + 'credits' => 55000, 'active' => true, 'password' => Hash::make("test123") ]); diff --git a/resources/images/payeer.png b/resources/images/payeer.png new file mode 100644 index 0000000000000000000000000000000000000000..257c0170264dec4231428f8e0346e2328472532e GIT binary patch literal 3610 zcma)<_dgVl1ICStj8w|ZD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$RuO3IT8dd3x8+8zUH<7ctXx`Bs!$wCyYdUkl7ya+GgKz@gKHLEef`6s z*#44jpE(lYI_FmPaMYHM#nT_xR!wQ~HRF|Pkc2L1#RdBVDl~sqUV%@j8kSxnb3c-w z%oTs0XqtjESTFgYpbuTNPZci}fTqt1qKcUihs*LI8B7rh_fDj`%v2H(6zwB_o2c%` z$dNEpVl8!_-81@=rv_CK8L@3SF~igi$i}I-baJi+TCr>*#WL;YD+d2qT&vtVc$9@S zdUYI6cg*DR=xuwL@Zoo)5Xy_F^i}Pk$te|b#5J^UZ9SLTo-|^na*_AC2{VhH3Uw_e#tu3{I~=?278%{Fi6YdfWy7@j-= z%ps)$$gFt1k3K2C=3*CA0^Q&RM~?=@vyGpg4#g zq0@z@8Mcj8kQDK5l8X%%N)kw{Q6v7{mw{9L8z@2sCubR@L_YaRccB-vrp_AvOk(X6 zlZ0^O)Z&jLW8@Udclh+g^IUd~@i-vVRSKVaaP5Mj-ApwTs--!sk)x+johvS8_lX&BtJ}VKKx{SHTvLtmcoS|E@eap9vD@QFJ5aEjpWD#h<{(S@?O9(E zuHW;XWPDn+ZJ92kBWy|*82YHOxhAiMw8>x$mI{}m$SiwsxvSn_8HaQpz8ygR?P$fq zM_jOFfggkN6g$=}(K1-8RJs`R|EVvDpdLCSV`>1a;!LdEKf_}H7?|nT={m>$58K&9 A+5i9m literal 0 HcmV?d00001 diff --git a/resources/images/perfect_money.svg b/resources/images/perfect_money.svg new file mode 100644 index 0000000..9630019 --- /dev/null +++ b/resources/images/perfect_money.svg @@ -0,0 +1,88 @@ + + + + diff --git a/resources/js/panel/credits.vue b/resources/js/panel/credits.vue index 00ef39b..ac4a3e7 100644 --- a/resources/js/panel/credits.vue +++ b/resources/js/panel/credits.vue @@ -23,25 +23,26 @@

Select a payment method

- - - - -
- -
- A chargeback will result in a ban. Contact supportif you have any problems of concerns. +
+ +

Payeer allows you to pay securely by transfering your choice of cryptocurrency + to a temporary address. +

+ +
+ +

Pay by transfering USD from your Perfect Money wallet.

+
+ +
+
@@ -51,14 +52,10 @@ class="brand-btn">Buy - diff --git a/resources/js/panel/settings.vue b/resources/js/panel/settings.vue index 9f7e376..d0bfbc0 100644 --- a/resources/js/panel/settings.vue +++ b/resources/js/panel/settings.vue @@ -1,10 +1,6 @@