Backend Code
Step 1: Receive the POST request from your frontend script
Step 2: Get the browser information necessary to make a charge request
2A) Get server specific browser information needed to make a BreathePay charge request:
//PHP
$serverBrowserInfo = array(
'deviceChannel' => 'browser',
'deviceIdentity' => (isset($_SERVER['HTTP_USER_AGENT']) ? htmlentities($_SERVER['HTTP_USER_AGENT']) : null),
'deviceTimeZone' => '0',
'deviceCapabilities' => '',
'deviceScreenResolution' => '1x1x1',
'deviceAcceptContent' => (isset($_SERVER['HTTP_ACCEPT']) ? htmlentities($_SERVER['HTTP_ACCEPT']) : null),
'deviceAcceptEncoding' => (isset($_SERVER['HTTP_ACCEPT_ENCODING']) ? htmlentities($_SERVER['HTTP_ACCEPT_ENCODING']) : null),
'deviceAcceptLanguage' => (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? htmlentities($_SERVER['HTTP_ACCEPT_LANGUAGE']) : null),
'deviceAcceptCharset' => (isset($_SERVER['HTTP_ACCEPT_CHARSET']) ? htmlentities($_SERVER['HTTP_ACCEPT_CHARSET']) : null)
);2B) Merge the frontend browser information from the POST request, with the server specific browser information retrieved above:
//PHP, Laravel
$browserInfo = array_merge($serverBrowserInfo, (array) $request->browserInfo);Step 3: Create the data object to POST to the BreathePay API
3A) Create initial object with payment information:
3B) Merge the browser information collected in step 2 with the initial object above:
Step 4: Create a BreathePay Request Signature
4A) Copy this function for creating a BreathePay signature:
4B) Calculate and attach the signature to the data object:
Step 5: Send the POST request to the BreathePay API
5A) Add this function for sending CURL requests to the BreathePay API
5B) Use the function to send the data above to BreathePay:
Step 6: Handling a response
To check how to handle responses from the BreathePay API, check the next page
Last updated