Skip to content

Commit 84db591

Browse files
committed
Add checkStatusCoins method to InitPaymentController and update API route
This commit introduces the checkStatusCoins method in InitPaymentController, which retrieves the transaction status from the Coolpay API using the provided transaction reference. Additionally, it updates the API routes to include a new endpoint for checking the status of coin payments, enhancing the payment processing capabilities.
1 parent 30db8d8 commit 84db591

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

app/Http/Controllers/Coins/InitPaymentController.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,14 @@ public function payin(Request $request){
5151
}
5252
}
5353

54-
public function checkStatusCoins()
54+
public function checkStatusCoins(Request $request){
55+
56+
$url = "https://my-coolpay.com/api/".env("PUBLIC_KEY_COOLPAY_COINS")."/checkStatus/".$request->transaction_ref;
57+
58+
$response=Http::get($url);
59+
$responseData=json_decode($response);
60+
61+
62+
return response()->json(['status' => $responseData->transaction_status]);
63+
}
5564
}

routes/api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121

122122
//Status for coolpay
123123
Route::post('/status/payin',[CheckPayinController::class,'checkStatus']);
124-
124+
Route::post('/status/payin/coins',[InitCoinsPaymentController::class,'checkStatusCoins']);
125125

126126
Route::post('/notchpay/coins/webhook', [HandleWebhookController::class, 'handleWebhook']);
127127
Route::post('/notchpay/product/webhook', [HandleWebhookProductPaymentController::class, 'handleWebhook']);

0 commit comments

Comments
 (0)