This is the code which I tried for mastercard implementation in php. Got the Sessionid using rest api version 59. but after session when it need to go to checkout page getting blank response. When checked in console getting the errors shown in image. It is a php file getting error "Invalid Request"
$data = array(
'apiOperation' => 'CREATE_CHECKOUT_SESSION',
'interaction' => array(
'operation' => 'AUTHORIZE',
'merchant' => array(
'name' => $merchant
)
),
'order' => array(
'id' => $orderId,
'amount' => $amount,
'currency' => $currency
),
);
$jsonPayload = json_encode($data);
$headers = array(
'Content-Type: application/json',
'Authorization: Basic ' . base64_encode('merchant.MERCHANTID:mypassword')
);
$options = array(
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $jsonPayload,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers
);
$curl = curl_init();
curl_setopt_array($curl, $options);
$response = curl_exec($curl);
if ($response === false) {
echo 'cURL error: ' . curl_error($curl);
} else {
// $sessionId = explode("=", explode("&", $response)[2])[1];
$responseData = json_decode($response, true);
$sessionId = $responseData['session']['id'];
}
curl_close($curl);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>
Checkout.configure({
merchant: '<?php echo $merchant; ?>',
order: {
amount: function(){
return <?php echo $amount ?>;
},
currency: '<?php echo $currency; ?>',
description: 'Order Goods',
id: '<?php echo $orderId; ?>'
},
interaction: {
merchant: {
name: "Milind Mhaskar",
address: {
line1: "Anna nagar",
line2: "Jalgaon"
}
}
},
session: {
id: '<?php echo $sessionId; ?>'
}
});
Checkout.showPaymentPage();
Not showing showPaymentPage. Getting invalid request error message
