Open edenahoussou opened 11 months ago
Thanks @edenahoussou
Field expires_at
is cast to date.
Can you share the steps to reproduce the issue? Plus, the version of this package that you're using
Config of my environment : PHP : 8.1 SERVEUR APACHE LARAVEL 10.10 "bmatovu/laravel-mtn-momo": "^4.3", "guzzlehttp/guzzle": "^7.2",
Process to get the error: Nothing special, I just defined a route in my api.php file that calls the getPaymentStatus() in my controller.
Here's my controller below
<?php
namespace App\Http\Controllers;
use Bmatovu\MtnMomo\Products\Collection;
class MtnMobileMoneyController extends Controller
{
protected $mtnMobileMoneyService;
protected $collection;
public function __construct()
{
$this->collection = new Collection();
}
/**
* Initiates a payment.
*
* @param mixed $amount The amount of the payment.
* @param mixed $payerMobileNumber The mobile number of the payer.
* @param mixed $reason The reason for the payment.
*
* @return JsonResponse The JSON response containing the reference ID.
*/
public function initiatePayment($amount, $payerMobileNumber, $reason)
{
// Request the payment from the payment collection service
$referenceId = $this->collection->requestToPay($reason, $payerMobileNumber, $amount);
// Return a JSON response with the reference ID
return response()->json(['reference_id' => $referenceId]);
}
/**
* Retrieves the payment status for a given reference ID.
*
* @param int $referenceId The reference ID of the transaction.
* @return \Illuminate\Http\JsonResponse The JSON response containing the status of the transaction.
*/
public function getPaymentStatus($referenceId)
{
$status = $this->collection->getTransactionStatus($referenceId);
return response()->json(['status' => $status]);
}
}
Routes :
Route::get('/initiate-payment/{amount}/{payerMobileNumber}/{reason}', [MtnMobileMoneyController::class, 'initiatePayment']);
Route::get('/get-payment-status/{referenceId}', [MtnMobileMoneyController::class, 'getPaymentStatus']);
Thank you for your work When verifying the transaction by passing it the id, this error occurs in the TokenUtilTrait at the level of the isExpired() function in the vendor. The expires_at field should have been of type dateTime but turns out to be a string.
To avoid the error I had to modify it to make sure it was in the right type before using isPast(), using Carbon.
Thanks again
Hey, I am facing similar issues, how did you get around it? i need your help.
Thank you for your work When verifying the transaction by passing it the id, this error occurs in the TokenUtilTrait at the level of the isExpired() function in the vendor. The expires_at field should have been of type dateTime but turns out to be a string.
To avoid the error I had to modify it to make sure it was in the right type before using isPast(), using Carbon.
Thanks again