I’m trying to create a custom payment gateway.
I’m at the point where I need to update the order, so trying to connect with the ‘private/custom-payment-gateway/payment’, but getting 401 no matter what I try.
I’m using GuzzleHttp to connect in my PHP script:
$snipClient = new Client(['base_uri' => "https://payment.snipcart.com/api/"]);
try {
$snipClient->post('private/custom-payment-gateway/payment', [
'headers' => [
'Authorization' => "Basic " . base64_encode(App::env('SNIPCART_SECRET_API_KEY') . ':'),
'Content-Type' => 'application/json'
],
'body' => json_encode([
'paymentSessionId' => $paymentSessionId,
'state' => $state,
'transactionId' => $transactionId,
])
]);
} catch (ClientException $e) {
throw new MethodNotAllowedHttpException($e->getMessage(), 401);
}
I also tried, as told in the documentation:
'Authorization' => "Bearer " . App::env('SNIPCART_SECRET_API_KEY'),
Secret key generated on Login - Snipcart
What am I doing wrong?