0

I am trying to implement BlueSnap payment(Embedded Checkout) on my WebApp in Laravel 6.

https://developers.bluesnap.com/v8976-Tools/docs/embedded-checkout.

I allowed server and public IP to access the BlueSnap Sandbox routes

First, I am getting the token from BlueSnap and this work perfect. https://developers.bluesnap.com/v8976-Tools/docs/create-embedded-checkout-token.

But then, when I request for card transaction (https://developers.bluesnap.com/v8976-JSON/docs/auth-capture), with "pfToken" which I get from previous request, I am getting 401.

public function makePayment(Request $request) {

    $endpoint = 'https://sandbox.bluesnap.com/services/2/transactions';

    try {

        $client = new \GuzzleHttp\Client();

        $response = $client->request('POST', $endpoint, [
            'headers' => [
                'Content-Type' => 'application/json',
                'Accept' => 'application/json',
                'Authorization' => 'Basic dXNlcm5hbWU6cGFzc3dvcmQ='
            ],
            'json' => [
                'cardTransactionType' => 'AUTH_CAPTURE',
                'amount' => '25.00',
                'currency' => 'USD',
                'pfToken' => $request->token,
            ],

        ]);

    } catch (RequestException $e) {

        dd($e);

    }


    dd($response);

}

I also tried to send request with Postman, and I got same error.

Michael Nelles
  • 5,426
  • 8
  • 41
  • 57
makiTurbo
  • 79
  • 3
  • 6
  • What is error message? – Tpojka Feb 09 '20 at 01:08
  • 401 Unauthorised – makiTurbo Feb 09 '20 at 10:58
  • I succeeded to make request from Postman and get successful response: 1.) I went first on their sandbox page, 2.) then make one request on the bottom of the page (for valid request you should use some of body contents provided above sandbox input field). 3.) From response I used valid token (Autorization: Basic __TOKEN_HERE__) and used that one in Postman. 4.) After that successful response has been got in Postman. You should go through docs double checking how to get valid token. Usually you would need to send credentials in exchange for token since that way most Restful state APIs work. – Tpojka Feb 09 '20 at 11:32
  • Thanks you, I missed section about auth headers. That was the problem. Again, thank you. – makiTurbo Feb 09 '20 at 20:05
  • You are welcome. I am glad if I could be helpful. – Tpojka Feb 09 '20 at 20:07

0 Answers0