50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Payments;
|
|
|
|
use App\Models\Payments\GcPinOrder;
|
|
use App\Models\Payments\GcPinOrderItem;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Str;
|
|
|
|
final class CheckoutService
|
|
{
|
|
public function createDemoOrder(int $memNo, int $amount): GcPinOrder
|
|
{
|
|
return DB::transaction(function () use ($memNo, $amount) {
|
|
|
|
$oid = 'GC' . now()->format('YmdHis') . Str::upper(Str::random(6));
|
|
|
|
$order = GcPinOrder::create([
|
|
'oid' => $oid,
|
|
'mem_no' => $memNo,
|
|
'products_id' => null,
|
|
'products_name' => '테스트 상품권',
|
|
'stat_pay' => 'ready',
|
|
'stat_tax' => 'taxfree',
|
|
'subtotal_amount' => $amount,
|
|
'fee_amount' => 0,
|
|
'pg_fee_amount' => 0,
|
|
'discount_amount' => 0,
|
|
'pay_money' => $amount,
|
|
'provider' => 'danal',
|
|
'ordered_at' => now(),
|
|
]);
|
|
|
|
GcPinOrderItem::create([
|
|
'order_id' => $order->id,
|
|
'item_name' => '테스트 상품권',
|
|
'item_code' => 'TEST',
|
|
'qty' => 1,
|
|
'unit_price' => $amount,
|
|
'unit_pay_price' => $amount,
|
|
'line_subtotal' => $amount,
|
|
'line_fee' => 0,
|
|
'line_total' => $amount,
|
|
]);
|
|
|
|
return $order;
|
|
});
|
|
}
|
|
}
|