Hello People, 
i have php data that i should send to my API provider who requested the data to be in XML format like this:
I am getting data from a form that has a PAY NOW button.
if(isset($_POST['pay_now'])){
$userid = $_POST['user-id'];
$total_amount = $_POST['total_amount'];
$currency = $_POST['currency'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$reasons = $_POST['reasons'];
$application_id = $_POST['application_id'];
$order_id = password_hash($application_id, PASSWORD_DEFAULT);
$token = "XXXXX";
$payUrl = "https://secure1.sandbox.directpay.online/payv2.php?ID=".$token;
$CompanyRef = "XXXXX";
$CompanyRefUnique = "olord11of2273host";
$RedirectURL = "www.mydomain.com/example?success=".$CompanyRefUnique."&congrats=".$CompanyRef."&user=".$userid;
$DeclinedURL = "www.mydomain.com/example?paymentdecline=".$CompanyRef."&user=".$userid;
$PTLtype = 20 ." minutes";
$DefaultPayment = "MO";
$ServiceDescription = $reasons;
$ServiceType = "5525";
$ServiceDate = date("YⓂ️d: hⓂ️ ")
$datainput = '
        
            
                    '.$total_amount.'
                <PaymentCurrency>'.$currency.'</PaymentCurrency>
'.$RedirectURL.'
'.$DeclinedURL.'
                      <CompanyRefUnique>'.$CompanyRefUnique.'</CompanyRefUnique>
                        <CompanyRef>'.$CompanyRef.'</CompanyRef>
'.$PTLtype.'
                        <customerFirstName>'.$firstname.'</customerFirstName>
                        <customerLastName>'.$lastname.'</customerLastName>
'.$email.'
                        <DefaultPayment>'.$DefaultPayment.'</DefaultPayment>
    
        
            '.$ServiceType.'
                                                    '.$ServiceDescription.'
                '.$ServiceDate.'
        
</Services>
';
    $ch = curl_init($payUrl);
            curl_setopt($ch, CURLOPT_URL, $payUrl);
            curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_SSLVERSION,6);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
            curl_setopt($ch, CURLOPT_POSTFIELDS, $datainput);
            $response = curl_exec($ch);
            curl_close($ch);
}
I am not getting any errors, but am not getting a redirect to the sandbox url. How can i make the Paynow Button to work like that?
    
Top comments (0)