mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Vouchers\Processors\Voucherify;
|
|
|
|
use App\Classes\Modules\Vouchers\DataTransferObjects\UpdateVoucherifyOrderObject;
|
|
use App\Classes\Modules\Vouchers\Services\Voucherify\UpdatesVoucherifyOrder;
|
|
use App\Models\Transaction;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class TransactionToVoucherifyProcessor
|
|
{
|
|
/** @var UpdatesVoucherifyOrder */
|
|
private $updatesVoucherifyOrder;
|
|
|
|
/**
|
|
* TransactionToVoucherifyProcessor constructor.
|
|
* @param UpdatesVoucherifyOrder $updatesVoucherifyOrder
|
|
*/
|
|
public function __construct(UpdatesVoucherifyOrder $updatesVoucherifyOrder)
|
|
{
|
|
$this->updatesVoucherifyOrder = $updatesVoucherifyOrder;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Transaction $transaction
|
|
* @param string $status
|
|
* @return void
|
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
* @throws \Voucherify\ClientException
|
|
*/
|
|
public function execute(Transaction $transaction, string $status)
|
|
{
|
|
try{
|
|
$voucherify_entity = $transaction->voucherifyEntities()->first();
|
|
if($voucherify_entity){
|
|
$updateVoucherifyOrderObject = new UpdateVoucherifyOrderObject($voucherify_entity->voucherify_entity_id, $status);
|
|
$this->updatesVoucherifyOrder->execute($updateVoucherifyOrderObject);
|
|
}
|
|
} catch (\Exception $e) {
|
|
Log::error($e);
|
|
}
|
|
}
|
|
}
|