helmutschneider / swish-php

PHP-wrapper for the Swish merchant api
MIT License
40 stars 19 forks source link

Working against production endpoint but failing on test #6

Closed larsemil closed 5 years ago

larsemil commented 7 years ago

I am trying to test this but get problems when trying to do it against test endpoint. If I use it against test endpoint i get:

cURL error 60: SSL certificate problem: self signed certificate in certificate chain (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

if i set verify to false(rootcert) i get other errors.

When using production URL it works fine, it just gets expensive testing. Do you have any hints on what i can be missing?


$rootCert = storage_path('certs/root.pem');
        $clientCert = null;//[storage_path('certs/swish.pem'),null];

        $client = Client::make($rootCert, $clientCert, Client::SWISH_TEST_URL);
        try {
            $response = $client->createPaymentRequest(
                [
                    'callbackUrl'           => 'https://atb.dalnix.systems/swishdebug',
                    'payeePaymentReference' => $order->id,
                    'payerAlias'            => $phoneNo,
                    'payeeAlias'            => env('SWISH_PAYEE_NR', null),
                    'amount'                => 1,//$order->price,
                    'currency'              => 'SEK',
                    'message'               => 'Beställning'

                ]
            );
        }
        catch(\GuzzleHttp\Exception\ClientException $e){
            dd($e, $phoneNo);
        }
MikeLund commented 6 years ago

@larsemil Why do you think that Swish's test environment should work with your live certificates? Swish uses different environments for Test and Production, just as everyone should do. So you just need to use the test certificates for test server. ;)

If you don't have these, see https://developer.getswish.se/merchants-test-con/3-prerequisites/ (or direct download at https://developer.getswish.se/content/uploads/2017/09/Guide__Testcertificates_171024.zip), containing the test certificates.