pay-now / paynow-php-sdk

PHP Library for Paynow API
https://docs.paynow.pl
MIT License
15 stars 10 forks source link

Refund API Error #61

Closed pperzyna closed 2 years ago

pperzyna commented 2 years ago

Dear PayNow,

I've tried to use your Refund Service, but it looks like there is an API error. The underlying HTTP request in the create function returns null.

How to replicate it?

$refund = new Refund(new Client($this->config['key'], $this->config['signature'], $this->config['environment']));
$response = $refund->create('R3FU-UND-D8K-WZD', '5e3b80f7-c48c-429c-9686-ddba817e8231', 1000, 'RMA');

Expected output: The Status object

emilleszczak2 commented 2 years ago

@pperzyna Is it a test environment refund or production?

pperzyna commented 2 years ago

@emilleszczak2 It was on sandbox, but on the production is the same problem

emilleszczak2 commented 2 years ago

Thanks, I'll check it. What kind of http client do you use?

pperzyna commented 2 years ago
Symfony\Component\HttpClient\Psr18Client {#2232 ▼
  -client: Symfony\Component\HttpClient\CurlHttpClient {#2222 ▶}
  -responseFactory: Nyholm\Psr7\Factory\Psr17Factory {#2235}
  -streamFactory: Nyholm\Psr7\Factory\Psr17Factory {#2227}
}
pperzyna commented 2 years ago

@emilleszczak2 Any news regarding this one?

emilleszczak2 commented 2 years ago

Not yet, API returns 404 Not Found for wrong Payment ID. It maybe a problem with the client or SDK

emilleszczak2 commented 2 years ago

@pperzyna I checked two variants and both works

{
    "name": "emilleszczak2/curl-paynow-test",
    "type": "project",
    "require": {
        "php-http/curl-client": "^2.2",
        "pay-now/paynow-php-sdk": "^2.2",
        "nyholm/psr7": "^1.5"
    },
    "minimum-stability": "stable"
}

and with guzzle/psr7 - there is needed change for SDK, see https://github.com/pay-now/paynow-php-sdk/pull/62

{
    "name": "emilleszczak2/curl-paynow-test",
    "type": "project",
    "require": {
        "php-http/curl-client": "^2.2",
        "guzzlehttp/psr7": "^2.1",
        "pay-now/paynow-php-sdk": "^2.2",
    },
    "minimum-stability": "stable"
}
<?php

use Paynow\Exception\PaynowException;
use Paynow\HttpClient\HttpClientException;

require 'vendor/autoload.php';

$apiKey       = 'xxxxxxxxxxx';
$signatureKey = 'yyyyyyyyyy';

$paynow = new \Paynow\Client(
    $apiKey,
    $signatureKey,
    \Paynow\Environment::SANDBOX,
    'curl-paynow-test'
);

$refund = new \Paynow\Service\Refund($paynow);
try {
    $refund->create('CXU-XYZ-123', uniqid(), 100, 'RMA');
} catch (PaynowException $exception) {
    var_dump($exception->getCode());
    var_dump($exception->getMessage());
    var_dump($exception->getPrevious()->getStatus());
    var_dump($exception->getPrevious()->getBody());
}
pperzyna commented 2 years ago

@emilleszczak2 Thanks for the update! Please release new version

emilleszczak2 commented 2 years ago

@pperzyna Released v2.2.1