-1

please i need to connect my html form to php script form payment proccessing but i don't know how to build it. i want php to start processing the payment when the submit button is clicked here are the sample codes

sample payload

{
  "price": 1,
  "network": "mtn",
  "recipient_number": "026xxxxxxx",
  "sender": "024xxxxxxx",
  "option": "rmta",
  "apikey": "",
  "orderID": ""
}

sample request

<?php
$url = 'https://client.teamcyst.com/api_call.php';


$additional_headers = array(
   'Content-Type: application/json'
);

$data = array(
  "price"=> 1,
  "network"=> "mtn",
  "recipient_number"=> "026xxxxxxx",
  "sender"=> "024xxxxxxx",
  "option"=> "rmta",
  "apikey"=> ""
  );
$data = json_encode($data);

$ch = curl_init($url);                                                                      
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // $data is the request payload in JSON format                                                                 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, $additional_headers); 

$server_output = curl_exec ($ch);
?>

sample response

{"code":1,"status":"success","id":"XXXXX"}

1 Answers1

0

You just make a form with input type submit button and when you submit your form you can access your form data with like below

if(isset($_POST['button_name']))
{
  // access all form field data here
}
Abra
  • 19,142
  • 7
  • 29
  • 41
Hitesh Kumar
  • 383
  • 2
  • 6