Closed m-pastuszek closed 2 years ago
Have you tried to call the REST API from the postman or curl for your credentials?
@emilleszczak2, calling API directly from postman returns data correctly.
It was a problem on my side with array to JSON conversion. I've made it this way:
public function availablePaymentMethods(): \Illuminate\Http\JsonResponse
{
$client = new Client(config('paynow.api_key'), config('paynow.signature_key'), Environment::SANDBOX);
try {
$payment = new Payment($client);
$paymentMethods = $payment->getPaymentMethods();
$availablePaymentMethods = $paymentMethods->getOnlyCards();
$responseTable = array();
foreach ($availablePaymentMethods as $availablePaymentMethod) {
$responseTable[] = [
'id' => $availablePaymentMethod->getId(),
'type' => $availablePaymentMethod->getType(),
'name' => $availablePaymentMethod->getName(),
'description' => $availablePaymentMethod->getDescription(),
'image' => $availablePaymentMethod->getImage(),
'status' => $availablePaymentMethod->getStatus(),
'authorizationType' => $availablePaymentMethod->getAuthorizationType()
];
}
return response()->json($responseTable);
} catch (PaynowException $exception) {
return response()->json('Error occurred: '. $exception->getMessage(), 400);
}
}
We can close the issue.
Hello,
I'm integrating Paynow with Laravel 9 project / PHP 7.4.
API returns 200, but it's content is only empty elements:
Http Client: