Browse Source

Change payment section from stripe to payeer

master
Immanuel Onyeka 3 years ago
parent
commit
7f70738eb6
12 changed files with 237 additions and 109 deletions
  1. +33
    -18
      app/Http/Controllers/BillingController.php
  2. +1
    -1
      database/migrations/2014_10_12_000000_create_users_table.php
  3. +0
    -1
      database/migrations/2021_06_08_224029_create_transactions_table.php
  4. +4
    -4
      database/seeders/DatabaseSeeder.php
  5. BIN
      resources/images/payeer.png
  6. +88
    -0
      resources/images/perfect_money.svg
  7. +72
    -75
      resources/js/panel/credits.vue
  8. +1
    -6
      resources/js/panel/settings.vue
  9. +34
    -1
      resources/scss/main.scss
  10. +2
    -1
      resources/views/home.blade.php
  11. +0
    -1
      resources/views/master.blade.php
  12. +2
    -1
      routes/web.php

+ 33
- 18
app/Http/Controllers/BillingController.php View File

@@ -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) {
}
}

+ 1
- 1
database/migrations/2014_10_12_000000_create_users_table.php View File

@@ -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']);


+ 0
- 1
database/migrations/2021_06_08_224029_create_transactions_table.php View File

@@ -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();


+ 4
- 4
database/seeders/DatabaseSeeder.php View File

@@ -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")
]);


BIN
resources/images/payeer.png View File

Before After
Width: 373  |  Height: 135  |  Size: 3.5 KiB

+ 88
- 0
resources/images/perfect_money.svg View File

@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="230px" height="60px" viewBox="0 0 230 60" enable-background="new 0 0 230 60" xml:space="preserve"> <image id="image0" width="230" height="60" x="0" y="0"
xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOYAAAA8CAMAAABFETbAAAAABGdBTUEAALGPC/xhBQAAACBjSFJN
AAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8A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4hDXs118xPJBflbh+d4tkF/J9sTxNqyi1Jt8yYp7kWbL3X/Vblj6cZ6SW2pW2KFYntxpoJ5
prIG1FTWE9uqSSReJi6WK75X2Ooqr1TKlaep3Vcr5GuE4XJlQ31FfEmtLNeeI/W1cmU5qU2rrpUr
fmAtLyk9j0lKfd14u2bdEczv5bPgLPXOt/Kl62dSwPVa+dJVBfOqLH9XL8unqObV8xUVKaBGluXv
41Pq5Yr6b0CdXE+GgcRpvVx5tb6Ktay2dT2hrP3806WGeUq+Rnwjn2EZaL1cZatvkOsp6wVwUr6W
svyqfI5i0lXrMh2WtNpa4/Lrch0dJOWs9p3Wsl2JDfOUgnmxUq6gbqzX5maDfAWAH+RL5JfJdYLJ
JmUVvVxUCi+A6+SXySWHWd1upF4+rXizimIC3ZVauvTWy+qW2EDASCzXg2/ka+Wnz5VfdMC8LNeW
nz5dXgXOy9+pmM1upj+5lFT9UKFMrAs19cybNSRuG2hBnVHFrKypuUZc3qOCrDDDSak9JiA1OnCZ
HK6Jn09W6WnQXj/Z1ljO0sACDrCArKVmX5Ar5ArCfV5Wt/4GUkJWIRLI5fSmNo1g1iqY9HKWLLhy
xUUArtDgPceu19oay1nONlSX227qMsvJbc31q9cv04Jz1edVzLrz1afZLams+0EH9OdZmxTlcvJK
dUM5PcJW1V1lfjxd/e0tWtEehM3NH03+BzrVKYOopxK7AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE5
LTA1LTI3VDA1OjA3OjMxKzAzOjAwBuPz1AAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxOS0wNS0yN1Qw
NTowNzozMSswMzowMHe+S2gAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAA
AElFTkSuQmCC" />
</svg>

+ 72
- 75
resources/js/panel/credits.vue View File

@@ -23,25 +23,26 @@
<h4>Select a payment method</h4>

<div class="sliding-menu">
<a @click="selectSaved = true" :class="{selected: selectSaved}">Saved Card</a>
<a @click="selectSaved = false" :class="{selected: !selectSaved}">New Card</a>
<div :class="{right: !selectSaved}" class="menu-slider"><div></div></div>
<a @click="method = 'payeer'" :class="{selected: method == 'payeer'}">Payeer</a>
<a @click="method = 'pm'" :class="{selected: method == 'pm'}">Perfect Money</a>
<div :class="{right: (method == 'pm')}" class="menu-slider"><div></div></div>
</div>

<saved-cards :preferred="preferred" v-model:picked-card="picked" :cards="cards"
:token="token" v-if="selectSaved"></saved-cards>

<payment-card @set-card="(c) => {card = c}" @card-valid="(val) => {cardValid = val}"
@update-billing-name="billingName = $event.target.value" :stripe="stripe"
v-if="!selectSaved">
</payment-card>
<div>
<input type="checkbox"><label>I have read and agree to the<a
href="/terms-and-policy">Terms and Policy</a></label>
<div class="info-grey">
<span>A chargeback will result in a ban. Contact <a
href="#contact">support</a>if you have any problems of concerns.</span>
<div v-if="method == 'payeer'" class="payment-window">
<img src="../../images/payeer.png" alt="">
<p>Payeer allows you to pay securely by transfering your choice of cryptocurrency
to a temporary address.
</p>
</div>

<div v-if="method == 'pm'" class="payment-window">
<img src="../../images/perfect_money.svg" alt="">
<p>Pay by transfering USD from your Perfect Money wallet.</p>
</div>

<div id="agreement-check">
<input v-model="agreed" type="checkbox"><label>I have read and agree to the <a
href="/terms-and-policy">Terms and Policy</a> and will not pursue a fraudulent dispute or chargeback.</label>
<div id="payment-error"></div>
</div>
</section>
@@ -51,14 +52,10 @@
class="brand-btn">Buy<loading v-if="loading"></loading></button>
</section>

<PurchaseCompleted v-if="complete"></PurchaseCompleted>
</template>

<script>
import Loading from '../icons/loading.vue'
import PaymentCard from './payment-card.vue'
import SavedCards from './saved-cards.vue'
import PurchaseCompleted from './purchase-completed.vue'

function total() {
return this.packs.credits10*10.99 + this.packs.credits50*54.99
@@ -88,78 +85,78 @@ function getSecret() {
})
}

//Gets key from the server then sends it with stripe
//Maybe it should asl attach the user's receipt email
function pay() {
this.getSecret().then(secret => {
if (!secret) {return}
this.loading = true
if (!this.selectSaved) {
return this.stripe.confirmCardPayment(secret, {
payment_method: {
card: this.card,
billing_details: {name:
document.getElementById('billing-name').value},
},
setup_future_usage: document.querySelector(
"#save-card input").value == 'on' ? 'off_session' : null
})
} else {
return this.stripe.confirmCardPayment(secret, {
payment_method: this.picked
})
}
}).then(result => {
if (result.error) {
document.getElementById('payment-error').textContent =
result.error.message
} else if (result.paymentIntent.status === 'succeeded') {
setTimeout(() => {this.$emit('purchaseComplete')}, 4000)
setTimeout(() => {this.$emit('purchaseComplete')}, 10000)
this.complete = true
} else {
document.getElementById('payment-error').textContent =
'An unknown error occured'
}
this.loading = false
})
if (this.method == 'payeer') {
this.payPayeer();
} else if (this.method == 'pm') {
this.payPm();
}
}

function makeInput(name, value) {
let input = document.createElement('input')
input.type = 'hidden'
input.name = name
input.value = value
return input
}

function getCards() {
fetch('/panel/cards', {
method: 'GET',
function payPayeer() {
fetch('/panel/payeer', {
method: 'POST',
headers: {'Content-Type': 'application/json',
'Accept': 'application/json',
'X-XSRF-TOKEN': this.token}
}).then((response) => {response.json().then(data => {
this.cards = data.data
if (this.cards && this.cards.length > 0) {
this.picked = this.cards[0].id
}
})})
'X-XSRF-TOKEN': this.token},
body: JSON.stringify({'packs': this.packs})
}).then(response => {return response.json()}).then(data => {
let form = document.createElement('form')
document.body.appendChild(form)
form.method = 'post'
form.action = 'https://payeer.com/merchant/'
form.appendChild(this.makeInput('m_shop', data.shop))
form.appendChild(this.makeInput('m_orderid', data.transaction))
form.appendChild(this.makeInput('m_amount', data.amount))
form.appendChild(this.makeInput('m_curr', 'USD'))
form.appendChild(this.makeInput('m_desc', data.description))
form.appendChild(this.makeInput('m_sign', data.signature))
form.appendChild(this.makeInput('m_params', data.params))
form.appendChild(this.makeInput('m_cipher_method', 'AES-256-CBC'))
form.submit()
/* console.log(data.description) */
/* console.log(data.signature) */
})

}

function payPm() {

}

function ready() {
return this.total != 0 && !this.loading && ((this.cardValid &&
this.billingName) || this.picked)
if (this.packs.credis10 < 0) {
return false
} else if (this.packs.credis50 < 0) {
return false
} else if (this.packs.credis100 < 0) {
return false
} else if (this.packs.credis1000 < 0) {
return false
}

return this.total > 0 && !this.loading && this.agreed
}

export default {
components:{Loading, PaymentCard, SavedCards, PurchaseCompleted},
components:{Loading},
data() {
return {packs: {credits10: 0, credits50: 0,
credits100: 0, credits1000: 0}, loading: false, stripe:
window.Stripe(process.env.VUE_APP_STRIPE_KEY), card:
null, billingName: null, selectSaved: true, cardValid: false, cards:
null, picked: null, complete: false
credits100: 0, credits1000: 0}, loading: false, method: 'payeer',
complete: false, agreed: false
}
},
computed: {total, ready},
methods: {getSecret, pay, getCards},
methods: {getSecret, pay, payPm, payPayeer, makeInput},
props: ['preferred', 'token'],
emits: ['purchaseComplete'],
created() {
this.getCards()
}
}
</script>

+ 1
- 6
resources/js/panel/settings.vue View File

@@ -1,10 +1,6 @@
<template>
<div>
<h3>Settings</h3>
<section class="billing-pane">
<h4>Billing</h4>
<edit-cards :preferred="user.payment_method" :token="token"></edit-cards>
</section>
<section class="change-name-pane">
<h4>Name</h4>
<input :value="user.name" name="name" id="changed_name" type="text">
@@ -30,7 +26,6 @@

<script>
import Loading from '../icons/loading.vue'
import EditCards from './edit-cards.vue'

function changeName() {
let name = document.getElementById('changed_name').value
@@ -115,7 +110,7 @@ function changePassword() {
}

export default {
components: {Loading, EditCards},
components: {Loading,},
methods: {
changePassword, changeName, changeEmail
},


+ 34
- 1
resources/scss/main.scss View File

@@ -567,7 +567,8 @@ section.features-info {
}

div.register-area.active {
min-height: 35em;
height: fit-content;
min-height: 20em;
opacity: 1;
}

@@ -1336,3 +1337,35 @@ main.terms {
color: grey;
}
}

.payment-window {
min-height: 5em;
margin-top: 1em;
text-align: center;
color: grey;
img {
width: 250px;
max-width: 80%;
margin: auto;
margin-bottom: 1em;
display: block;
height: 90px;
}
}

#agreement-check {
margin: auto;
max-width: 30em;
display: flex;
align-items: center;

label {
display: inline-block;
// width: 85%;
margin: 1em;
}

input {
display: inline-block;
}
}

+ 2
- 1
resources/views/home.blade.php View File

@@ -193,7 +193,8 @@
</p></div></div>
<div class="collapsible"><button>How can I pay?</button>
<div class="content"><p>
We accept credit and debit through Mastercard and Visa.
We accept Bitcoin, Litecoin, and other cryptocurrencies through our
Payeer and Perfect Money payment providers.
</p></div></div>

</div>


+ 0
- 1
resources/views/master.blade.php View File

@@ -35,7 +35,6 @@
@show

@section('scripts')
<script src="https://js.stripe.com/v3/"></script>
@show

</body>

+ 2
- 1
routes/web.php View File

@@ -112,6 +112,7 @@ Route::post('/panel/orders', [OrderController::class,
Route::post('/panel/secret', [BillingController::class,
'stripeSecret'])->middleware([ 'auth', 'verified' ]);

//Initiate a payeer payment
Route::post('/panel/payeer', [BillingController::class,
'payeer'])->middleware([ 'auth', 'verified' ]);

@@ -124,4 +125,4 @@ Route::post('/hooks/charge',

//Payeer handler function
Route::post('/hooks/payeer-transaction',
[BillingController::class, 'payeer']);
[BillingController::class, 'processPayeer']);

Loading…
Cancel
Save