I'm trying to add integration with Opayo payment on website.
The form
I just have this code:
I change card and card holder details for security reason
$text ='Description=Finishing transaction&Currency=GBP&VendorTxCode=22013115512924219800&amount=5.00&BillingSurname=Paul&BillingFirstnames=Smith&BillingAddress1=ddd&BillingCity=London&BillingPostCode=BH99PU&BillingCountry=GB&DeliveryState=&DeliverySurname=Jhon&DeliveryFirstnames=Jhon&DeliveryAddress1=ddd&DeliveryCity=London&DeliveryPostCode=BH99PU&BillingState=&DeliveryCountry=GB&VendorData=Testing Data &ApplyAVSCV2=2&referid=&language=&website=&Phone=SendEmail=&CardHolder=Smith Alves Gomety&Cardnumber=5434391244446116&ExpiryDate=1229&CardType=MC';
$key = "yuG4B75PE2Gaqgus";
$iv = hex2bin('00000000000000000000000000000000');
$ciphertext_raw = openssl_encrypt($text , "AES-128-CBC", $key , OPENSSL_RAW_DATA, $iv);
$hex = bin2hex($ciphertext_raw);
$hex ='#' . $hex;
<form method="POST" id="SagePayForm" action="https://test.sagepay.com/gateway/service/vspform-register.vsp">
<input type="hidden" name="VPSProtocol" value= "4.00">
<input type="hidden" name="TxType" value= "PAYMENT">
<input type="hidden" name="Vendor" value= "xxxxxxxxxxxxxxx">
<input type="hidden" name="Crypt" value= "<?php echo $hex; ?>">
<input type="submit" value="continue to SagePay">
</form>
The page comes like following
Page generated
And, when I click on "Continue to SagePay" I'm receiving the following
Ssubmiting result
Does anyone can help me with this?
How to integrate in my own form or on SagePay?
Does anyone has full PHP code to this integration including returnings codes,,,,
Related
i am new to this matter. I am trying to create a search form, that allows searching a database via http api and display the result on a website. The call requires authorization:
$headers = array ('headers' => array(
'Authorization' => 'bearer' . $token ,
'Content-type' => 'application/json',
'Accept' => 'application/json'));
My search form looks like this:
<form method="GET" accept="application/json" action="https://example.xx/api/v1/products?page=1&size=5&direction=asc&search=value">
<input type="text" name="search" size="40" maxlength="256" value="" placeholder="testsearch">
<input type="submit" name="search_button" value="Search">
</form>
When i enter something into the input field and hit the submit button, the browser displays:
{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}
And in the browsers address field i see:
https://example.xx/api/v1/products?search=testvalue&search_button=Search
Obviously the authorisation is ignored and the url shows that i have left my website.
Do i have to make this work with an action="somephp.php"?
How can i authorize the call from the form and display the response in a website?
Hints much appreciated. theo
Thanks to the german wordpress forum, i found the answer –
The Form:
<form method="post" id="api-result-searchform" action="">
<input type="text" class="search" placeholder="<?php echo esc_attr_x( 'Author?', 'placeholder' ) ?>" value="" name="searchauthor" id="s" title="api-search" />
<input class="button"type="submit" name="search_button" value="Search">
</form>
And the call:
<?php
$searchterm = $_POST['searchauthor'];
$url = 'https://example.de/api/v1/product?search=ti=' . $searchterm;
$response = wp_remote_get($url, $headers);
//etc.
This works well.
i create simple plugin wordpress , one validationform.php and rflinsertdb.php
when user click on submit form , i want got rflinsertdb.php the page validation and insert information to db , but wordpress give me Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
this 2 php page in one folder that name in public ,i see to many codes in internet but not help, how can i do that ?
thx alot
i try this codes for action form
<form method="post" action="<?php bloginfo('template_url'); ?>/rflInsertdb.php">
<p id="errorMessage"></p>
<p>name: <input type="text" class="register" name="name" id="name"></p>
<p>family: <input type="text" class="registerForm" id="family" name="family"></p>
<p>numbers :<input type="number" class="registerForm" id="numbers" name="numbers" min="1" max="200" value="1"></p>
<p>tell: <input type="text" class="registerForm" id="tell" name="tell"></p>
<p><input type="submit" value="ثبت" class="registerForm" id="submit" name="submit"></p>
</form>
This happens to you, because you are using template directory for: /rflInsertdb.php
Try to use
<form method="post" action="<?php echo plugin_dir_url( __FILE__ ); ?>/rflInsertdb.php">
If your file is under the public (what is under the plugin dir), then maybe:
<form method="post" action="<?php echo plugin_dir_url( __FILE__ ); ?>/public/rflInsertdb.php">
See here: https://codex.wordpress.org/Function_Reference/plugin_dir_url
I created a front end registration form, I used the filters 'registration_errors' to customize the messages.
After WP detects the error and use 'wp-redirect' to return to the registration page and display an error if the email or the user exists for example.
My question is: how I can keep the previous values that generated the error.
¿JS?
Thanks in advance!
To keep values in the form after the error message:
function my_register_sesion (){
session_start();
$_SESSION['key_login']=$_REQUEST['user_login'];
$_SESSION['key_email']=$_REQUEST['user_email'];
}
add_action ('register_post', 'my_register_sesion');
My inputs form should be as follows:
<input type="text" name="user_login" id="user_login" class="input" value="<?php echo $_SESSION['key_login'];?>">
<input type="text" name="user_email" id="user_email" class="input" value="<?php echo $_SESSION['key_email'];?>">
Thank you David!
hi everybody i have my contact form ready in html and php (2 different files one html and one php file) and i want to use it in a worpress page.
the user fills the form, selects support department answers the captcha and presses submit button. the form sends all the form data through email to the administrator, a thank you email to the user and redirects to a thank you page.
the html form is
<html>
<body>
<head>
<script src="http://www.google.com/recaptcha/api.js" async defer> </script>
<script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>
</head>
<i>Use the form to get in touch with us.</i>
<form action="form.php" method="POST">
<strong>Name:*</strong>
<input style="width:300px;" name="username" type="text" required />
<strong>E-mail Adress:*</strong>
<input style="width:300px;" name="useremail" type="text" required />
<strong>Subject:*</strong>
<input style="width:300px;" name="usersubject" type="text" required />
<strong>Message:*</strong>
<textarea style="width:300px;" cols="40" name="usermessage" rows="5" required></textarea>
<strong>Select Support Department </strong>
<select name="support">
<option style="width:200px;" value="" >Choose Service</option>
<option style="width:200px;" value="support#xxxxxxxx.com" required>Technical support</option>
<option style="width:200px;" value="sales#xxxxxxxxxx.com" required>Sales</option>
<option style="width:200px;" value="info#xxxxxxxxxxx.com" required>Press</option>
<option style="width:200px;" value="info#xxxxxxxxxxx.com" required>Other</option>
</select>
//recaptcha
<div class="g-recaptcha" data- sitekey="------my site key---------"></div>
<input type="submit" value="send" name="submit"/>
//it redirects when you hit submit
<?php
if ( isset( $_POST['submit'] ) ){
header("Location:http://xxxxxxxxx.com/thank-you-messasge/");
}
?>
</form>
</html>
</body>
my form.php is
<?
//set up the message for administrator
$msg="Name:".$_POST["username"]."\n";
$msg .="E-mail:".$_POST["useremail"]."\n";
$msg .="Subject:".$_POST["usersubject"]."\n";
$msg .="Usermessage:".$_POST["usermessage"]."\n";
//set up message for customer
$msg_customer="We received your request and we will answer you within 24 hours.";
$msg_customer.="\n"."xxxxxxxxxxxxxx";
//set up the email for the administrator
$recipient=$_POST["support"];
$subject= "Support Contact Form ";
$mailheaders="From: xxxxxxxx sales#xxxxxxxxx.com \n";
//set up the email for the customer
$recipient_customer=$_POST["useremail"];
$subject_customer= "Support Contact Form ";
$mailheaders_customer="From: xxxxxxxxxx sales#xxxxxxxxxxxxxxx.com \n";
//send the emails
mail($recipient,$subject,$msg, $mailheaders);
mail($recipient_customer,$subject_customer,$msg_customer, $mailheaders_customer);
?>
i want this form to appear in one page and be able to run the php code when the submit button is pressed.
i cannot run the form.php file even if i save it on the root directory.
it seems i am loosing something
thank you very much
To troubleshoot your form, press F12 in your browser to access the developer tools menu, and take a look at what happens on the Network panel when you submit the form. This should give you some clues about what is failing.
Also, you should not be using unfiltered $_POST variables directly, e.g.:
$name = sprintf("Name:%s\n", filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING) );
i found out the way:
i copy/pasted the html form inside the page code view and i linked absolutely to my php file
<form action="http://example.com/php_file_directory/form.php" method="POST">
I have a Wordpress page with iframe integrated which contains booking calendar script as per below.
<div class="booking-calendar">
<iframe id="frame1" name="frame1" src="http://www.xxxxxx.co.uk/booking/frontend/" width="100%" height="450px" frameborder="0" scrolling="auto"></iframe>
</div>
Demo for the script in this iframe can be found here: http://www.phpjabbers.com/hotels-booking-system/
What I want to do is once the user clicks on Book now button is to redirect them to Paypal page. At the moment is set up so that they have to click on 'Pay now' button to get to this Paypal page where they make a payment. The code for this Pay now button is as follows:
<?php
if ($deposit > 0) {
if ($_REQUEST['payment_type'] == 'paypal') {
?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?php echo $SETTINGS_DB["paypal_address"]; ?>">
<input type="hidden" name="item_name" value="Booking confirmation - <?php echo $BookingID; ?>">
<input type="hidden" name="item_number" value="">
<input type="hidden" name="amount" value="<?php echo number_format($deposit, 2, '.', ''); ?>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="<?php echo $Currencies[$SETTINGS_DB["currency"]]; ?>">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="return" value="<?php echo $SETTINGS_DB["thankyou_page"]; ?>">
<input name="submit" type='submit' value='PAY NOW' >
</form>
<?php
header ("https://www.paypal.com/cgi-bin/webscr");
exit;
?>
I was wondering how could I make a redirect so that the user goes automatically to Paypal page without clicking on Pay now? If somebody can put me in the right direction that would be great. I understand that hidden values have to be carried over to Paypal page, I just don't know how to make it so they get carried over. Any ideas? Any tips would be really appreciated.
I have been trying to sort it out myself so what I did so far: As I want the redirect to PayPal happen once the user clicks on Book button, I copied hidden fields which are part of Pay now form to the part with Book button --> part of the last bit of code:
($deposit > 0) {
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?php echo $SETTINGS_DB["paypal_address"]; ?>">
<input type="hidden" name="item_name" value="Booking confirmation - <?php echo $BookingID; ?>">
<input type="hidden" name="item_number" value="">
<input type="hidden" name="amount" value="<?php echo number_format($deposit, 2, '.', ''); ?>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="<?php echo $Currencies[$SETTINGS_DB["currency"]]; ?>">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="return" value="<?php echo $SETTINGS_DB["thankyou_page"]; ?>">
<?php }
?>
<div style="float:left"><input type="submit" value="Book"></div>
<div style="clear:both"></div>
</form>
Once the user clicks on Book button, the code will check if it's been submitted with this:
elseif ($_REQUEST["ac"]=='save_booking') {
and then the Booking details (name, tel, email,..) will be inserted into the database like this:
$sql = "INSERT INTO ".$TABLES["bookings"]." SET
`from` = '".Date2MySQL(SaveToDB($_REQUEST["from"]))."',
`to` = '".Date2MySQL(SaveToDB($_REQUEST["to"]))."',
`name` = '".SaveToDB($_REQUEST["name"])."',
`email` = '".SaveToDB($_REQUEST["email"])."',
`phone` = '".SaveToDB($_REQUEST["phone"])."',
`notes` = '".SaveToDB($_REQUEST["notes"])."',
`people` = '".SaveToDB($_REQUEST["people"])."',
`payment_type` = '".SaveToDB($_REQUEST["payment_type"])."',
`dt` = now()";
$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql.mysql_error());
$BookingID = mysql_insert_id();
$total_price = 0;
$sql = "SELECT * FROM ".$TABLES["rooms"]." ORDER BY id DESC";
$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
while ($row = mysql_fetch_assoc($sql_result)) {
if ($_REQUEST["room_".$row["id"]]>0) {
$sql = "INSERT INTO ".$TABLES["bookings_rooms"]." SET
`booking_id` = '".$BookingID."',
`room_id` = '".$row["id"]."',
`quantity` = '".SaveToDB($_REQUEST["room_".$row["id"]])."'";
$sql_resultT = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql.mysql_error());
$total_price = $total_price + $_REQUEST["room_price_".$row["id"]]*$_REQUEST["room_".$row["id"]];
};
};
$sql = "UPDATE ".$TABLES["bookings"]." SET
`price` = '".$total_price."'
WHERE id = '".$BookingID."'";
$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql.mysql_error());
$deposit = $SETTINGS_DB["payment_deposit"];
$sql = "SELECT * FROM ".$TABLES["bookings"]." WHERE id='".$BookingID."'";
$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
$booking = mysql_fetch_assoc($sql_result);
$sql = "SELECT * FROM `".$TABLES["bookings_rooms"]."` INNER JOIN ".$TABLES["rooms"]." ON ".$TABLES["rooms"].".id = ".$TABLES["bookings_rooms"].".room_id WHERE `".$TABLES["bookings_rooms"]."`.booking_id='".$BookingID."'";
$sql_resultP = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
while ($rooms = mysql_fetch_assoc($sql_resultP)) {
$roomsemail .= $rooms["quantity"]." x ".$rooms["room_type"].", ";
};
$message = ReadFromDB($SETTINGS_DB["email_message"]);
$search_tokens=array("{name}","{email}","{phone}","{from_date}","{to_date}","{price}","{rooms}");
$replace_tokens=array(ReadFromDB($booking["name"]),ReadFromDB($booking["email"]),ReadFromDB($booking["phone"]),MySQL2Date(ReadFromDB($booking["from"])),MySQL2Date(ReadFromDB($booking["to"])),formatCurrencyExport($booking["price"]),$roomsemail);
$message=str_replace($search_tokens,$replace_tokens,$message);
$mailheader = "From: ".$SETTINGS_DB["admin_email"]."\r\n";
$mailheader .= "Reply-To: ".$SETTINGS_DB["admin_email"]."\r\n";
$mailheader .= "Content-type: text/plain; charset=UTF-8\r\n";
mail($booking["email"], $SETTINGS_DB["email_subject"], $message, $mailheader);
if ($SETTINGS_DB["admin_email"]) {
mail($SETTINGS_DB["admin_email"], $SETTINGS_DB["email_subject"], $message, $mailheader);
}
After the data has been inserted into the database I want the user to go automatically to PayPal payment page, so I inserted this code after the above code:
header ("https://www.paypal.com/cgi-bin/webscr");
exit;
?>
Now when I click on Book button nothing happens, well the form disappears, so I just have some instruction text on the page, but we are not redirected to the PayPal page. Could somebody please point me to the right direction?