Skip to content

Commit 90a1f91

Browse files
committed
Add show payment by reference endpoint in API routes
This commit introduces a new API route for retrieving payment details by reference, enhancing the payment processing capabilities for sellers. The ShowPaymentByRefController is now included to handle the request, improving the overall functionality of the payment system.
1 parent 4e246c2 commit 90a1f91

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Seller;
4+
5+
use App\Models\Payment;
6+
use Illuminate\Http\Request;
7+
use App\Http\Controllers\Controller;
8+
use Illuminate\Support\Facades\Auth;
9+
use App\Http\Resources\PaymentCoinResource;
10+
11+
class ShowPaymentByRefController extends Controller
12+
{
13+
public function show($ref){
14+
$payment=Payment::where('transaction_ref',$ref)
15+
->where('user_id',Auth::guard('api')->user()->id)
16+
->where('payment_of','coins')->first();
17+
18+
return response()->json(PaymentCoinResource::make($payment));
19+
}
20+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace App\Http\Resources;
4+
5+
use Illuminate\Http\Request;
6+
use Illuminate\Http\Resources\Json\JsonResource;
7+
8+
class PaymentCoinResource extends JsonResource
9+
{
10+
/**
11+
* Transform the resource into an array.
12+
*
13+
* @return array<string, mixed>
14+
*/
15+
public function toArray(Request $request): array
16+
{
17+
return [
18+
'id'=>$this->id,
19+
'price'=>$this->price,
20+
"user"=>$this->user->userName,
21+
"transaction_ref"=>$this->transaction_ref,
22+
"payment_of"=>$this->payment_of,
23+
];
24+
}
25+
}

routes/api.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
use App\Http\Controllers\Delivery\UpdateDeliveryController;
6262
use App\Http\Controllers\Seller\ListNotificationController;
6363
use App\Http\Controllers\Seller\ListSubscriptionController;
64+
use App\Http\Controllers\Seller\ShowPaymentByRefController;
6465
use App\Http\Controllers\Seller\ShowSubscriptionController;
6566
use App\Http\Controllers\User\MakeCommentProductController;
6667
use App\Http\Controllers\Product\PublishedProductController;
@@ -171,7 +172,7 @@
171172
Route::post("init/payment/subscription/product", [SubscribeProductController::class, "initPay"]);
172173
Route::post('init/payment/subscription/product/pending/{membership_id}/{product_id}/{transaction_ref}', [SubscribeProductController::class, 'initPaymentPending']);
173174
Route::post("check/payment/subscription/product/callback", [SubscribeProductController::class, "paymentCallBack"]);
174-
175+
Route::get('/show/payment/coins/{ref}',[ShowPaymentByRefController::class,'show']);
175176
Route::post('validate/payment/coins',[ValidatePaymentCoinController::class,'handle']);
176177
Route::post("init/payment/coins", [InitCoinsPaymentController::class, "payin"]);
177178
Route::post("init/payment/subscription/shop", [SubscribeShopController::class, "initPay"]);

0 commit comments

Comments
 (0)