curl --location --request POST 'https://sandbox.api.getsafepay.com/order/v1/init' \
--header 'Content-Type: application/json' \
--data-raw '{
"client": "sec_c18b707b-bd0f-41fe-947a-e894adf81e20",
"amount": 1000.00,
"currency": "PKR",
"environment": "sandbox"
}'
response:
{
"data":{
"token":"track_a323b3d5-c9e8-410f-9020-6f3a9395f13e",
"created_at":"2019-12-23T20:28:54Z",
"updated_at":"2019-12-23T20:28:54Z",
"user":"",
"billing":"",
"client":"sec_c18b707b-bd0f-41fe-947a-e894adf81e20",
"environment":"local",
"state":"TRACKER_STARTED",
"state_reason":"",
"amount":10,
"currency":"USD",
"default_currency":"PKR",
"conversion_rate":153.37580742
},
"status":{
"errors":[
],
"message":"success"
}
}
const PRODUCTION_CHECKOUT_URL = "https://www.getsafepay.com/components";
const SANDBOX_CHECKOUT_URL = "https://sandbox.api.getsafepay.com/components";
function construct_url($order, $tracker="")
{
$baseURL = $this->sandbox ? self::SANDBOX_CHECKOUT_URL : self::PRODUCTION_CHECKOUT_URL;
$params = array(
"env" => $this->sandbox ? Safepay_API_Handler::$SANDBOX : Safepay_API_Handler::$PRODUCTION,
"beacon" => $tracker,
"source" => 'silverapp', // Change this to the name of the billing app you're using
"success_url" => $this->get_success_url(),
"cancel_url" => $this->get_cancel_url()
);
$baseURL = add_query_arg($params, $baseURL);
return $baseURL;
}