axotion / laravel-dotpay

Paczka do Laravela umożliwająca wysyłanie danych bezpośrednio po API
MIT License
12 stars 11 forks source link

Constructor call #26

Closed Xematos closed 3 years ago

Xematos commented 3 years ago

Hello, sorry for my newbie question but I cant make it work. When I call the route in Postman it cant even go further than this GuzzleHttp\Exception\ConnectException: cURL error 6: Could not resolve host: api (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for api/v1/accounts//payment_links/ in file /var/www/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 210 Route::post('/dotpay', 'App\Http\Controllers\DotPayController@pay');

plumthedev commented 3 years ago

You probably missed trailing slash on start of url. Instead of api/v1/accounts//payment_links/ pass /api/v1/accounts//payment_links/

Better option is pass full URL to your api: https://my-cool-app.com/api/v1/accounts//payment_links/

Xematos commented 3 years ago

If im not wrong there is code for it Client.php public function makeRequest(IRequest $request) { $options = [ 'auth' => [ $this->username, $this->password ], 'headers' => ['content-type' => 'application/json', 'Accept' => 'application/json'], 'body' => json_encode($request->toArray(), 320) ]; return json_decode($this->client->request($request->method(),$this->base_url.$request->path(), $options)->getBody()); }

dotpay.php

    'api' => [
        'api_version' => 'dev',
        'username' => env('DOTPAY_USERNAME'),
        'password' => env('DOTPAY_PASSWORD'),
        'shop_id' => env('DOTPAY_SHOP_ID'),
        'pin' => env('DOTPAY_PIN'),
        'base_url' => env('DOTPAY_BASE_URL')
    ],
    'options' => [
        'url' => '127.0.0.1',
        'curl' => 'callback_url',
        'recipient' => [
            'company' => 'YourCompany',
            'address' => [
                'street' => 'Wojka',
                'building_number' => '2',
                'postcode' => '59-303',
                'city' => "Warszawa"
            ]
        ],
    ]
];

.env

DOTPAY_USERNAME=********
DOTPAY_PASSWORD=********
DOTPAY_SHOP_ID=73********
DOTPAY_PIN=******
DOTPAY_BASE_URL=https://ssl.dotpay.pl/test_seller/

If somebody wonder what happen.. After change to .env file I had to php artisan config:cache php artisan config:clear.