hi
i am using this code its sending the data to the api but shows form error even form submitted
An error occurred while processing the form. Please try again
add_action( 'forminator_custom_form_submit_before_set_fields', function( $entry, $form_id, $field_data_array ) {
// Can be replaced using $entry variable, to find out
// what is included in entry variable, use error_log( print_r($entry, true ) ); then check debug.log
// This is a simple way
$emailNo = intval($_POST['number-1']);
$trademarked = $_POST['select-1'];
$configure = $_POST['select-2'];
$FirstName = $_POST['name-1'];
$LastName = $_POST['name-2'];
$OrganizationName = $_POST['text-1'];
$Email = $_POST['email-1'];
$PhoneNumber = $_POST['phone-1'];
$Country = $_POST['address-1-country'];
$AddressLine1 = $_POST['address-2-street_address'];
$AddressLine2 = $_POST['address-3-street_address'];
$Zipcode = $_POST['address-4-zip'];
$Region = $_POST['address-5-state'];
$transaction_id = $field_data_array[15]['value']['transaction_id'];
$productname = $field_data_array[15]['value']['product_name'];
$status = $field_data_array[15]['value']['status'];
$amount = $field_data_array[15]['value']['amount'];
$cat = 'Digicert';
$provider = 'Stripe';
$paymenttype = 'Payment';
$portaltype = 'Retail';
$url = 'api url';
$data = [
"username" => $Email,
"couponcode" => "",
"coupondiscount" => "0",
"resonseobj" => null,
"portaltype" => $portaltype,
"productdetails" => [
[
"category" => $cat,
"productname" => $productname,
"totalsans" => 0,
"qty" => $emailNo,
"validity" => 12,
"domainname" => $configure,
"servertype" => $trademarked,
"supporttype" => null
]
],
"Paymentmodel" => [
"key" => null,
"salt" => null,
"txnid" => $transaction_id,
"amount" => $amount,
"userfundamount" => "0",
"productinfo" => null,
"fname" => $FirstName,
"email" => $Email,
"mobile" => $PhoneNumber,
"udf5" => null,
"hash" => null,
"status" => $status,
"mihpayid" => "0",
"userid" => 0,
"gatwaytransactionid" => "0",
"provider" => $provider,
"paymenttype" => $paymenttype
],
"billingmodel" => [
"bfirstName" => $FirstName,
"blastName" => $LastName,
"baddress1" => $AddressLine1,
"baddress2" => $AddressLine2,
"bzipcode" => $Zipcode,
"bcountry" => $Country,
"bregion" => $Region,
"bphonenumber" => $PhoneNumber,
"btaxnumber" => "",
"borganizationname" => $OrganizationName
],
"registermodel" => [
"email" => $Email,
"firstname" => $FirstName,
"lastname" => $LastName,
"phonenumber" => $PhoneNumber,
"country" => $Country,
"region" => $Region,
"addressline1" => $AddressLine1,
"addressline2" => $AddressLine2,
"zipcode" => $Zipcode,
"organizationname" => $OrganizationName
]
];
$data_string = json_encode($data);
// Send data to API
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
// Print the result
print($result);
error_log( print_r($emailNo, true ) );
error_log( print_r($trademarked, true ) );
error_log( print_r($configure, true ) );
error_log( print_r($FirstName, true ) );
error_log( print_r($LastName, true ) );
error_log( print_r($OrganizationName, true ) );
error_log( print_r($Email, true ) );
error_log( print_r($PhoneNumber, true ) );
error_log( print_r($Country, true ) );
error_log( print_r($AddressLine1, true ) );
error_log( print_r($AddressLine2, true ) );
error_log( print_r($Zipcode, true ) );
error_log( print_r($Region, true ) );
error_log( print_r($transaction_id, true ) );
error_log( print_r($amount, true ) );
error_log( print_r($productname, true ) );
error_log( print_r($status, true ) );
error_log( print_r($entry, true ) );
}, 10, 3);
-
This reply was modified 1 year, 5 months ago by avinash24.