restart
This commit is contained in:
53
app/Repositories/Shop/Paybox.php
Normal file
53
app/Repositories/Shop/Paybox.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App;
|
||||
|
||||
use Devpark\PayboxGateway\Requests\AuthorizationWithCapture;
|
||||
use Devpark\PayboxGateway\Responses\Verify;
|
||||
use Devpark\PayboxGateway\Requests\Capture;
|
||||
|
||||
class Paybox
|
||||
{
|
||||
|
||||
public static function makeAuthorizationRequest($amount, $customer_email = 'test@example.com')
|
||||
{
|
||||
$authorizationRequest = App::make(AuthorizationWithCapture::class);
|
||||
|
||||
return $authorizationRequest->setAmount($amount)->setCustomerEmail($customer_email)
|
||||
->setPaymentNumber(1)->send('paybox.send');
|
||||
}
|
||||
|
||||
public static function verifyPayment($invoice_id)
|
||||
{
|
||||
$invoice = Invoices::get($invoice_id);
|
||||
$payboxVerify = App::make(Verify::class);
|
||||
try {
|
||||
$success = $payboxVerify->isSuccess($invoice->total_shipped);
|
||||
if ($success) {
|
||||
// process order here after making sure it was real payment
|
||||
}
|
||||
echo "OK";
|
||||
}
|
||||
catch (InvalidSignature $e) {
|
||||
Log::alert('Invalid payment signature detected');
|
||||
}
|
||||
}
|
||||
|
||||
public static function getPreviousAuthorizedRequest()
|
||||
{
|
||||
$payment = PaymentModel::find($idOfAuthorizedPayment);
|
||||
$captureRequest = App::make(Capture::class);
|
||||
$response = $captureRequest->setAmount($payment->amount)
|
||||
->setPayboxCallNumber($payment->call_number)
|
||||
->setPayboxTransactionNumber($payment->transaction_number)
|
||||
->setDayRequestNumber(2)
|
||||
->send();
|
||||
|
||||
if ($response->isSuccess()) {
|
||||
// process order here
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user