API for PHP curl with JSON response using ajax get cc result (using payeezy)?
API for PHP curl with JSON response using ajax to get cc result (using payeezy)?
我现在有一个小问题 我正在使用 PHP curl API 和 JSON 请求使用 ajax 提交表单(使用 ajax部分)?它不提交表单或得到响应。有没有人有提示可以帮助我处理 ajax 部分?我希望每个使用 payeezy 的人都可以选择使用您的 API 实现此代码。另外,我是否正确使用了用户 post PHP 和数据数组参数?
Here is the php form response 请注意,我故意拒绝了这张卡,这是我想要的回复。
Here is the form itself 我希望 ajax 在不刷新页面的情况下在此处提交表单,并且 json 响应显示在表单页面上以指示交易是否成功。此外,如果卡被拒绝,我不希望表单提交并显示其相应的消息。
<?php
#require_once('payeezy-include.php');
$apiKey = "(your api key)";
$apiSecret = "( your api secret)";
$token = "(your merchant token)";
$nonce = strval(hexdec(bin2hex(openssl_random_pseudo_bytes(4, $cstrong))));
$timestamp = strval(time()*1000); //time stamp in milli seconds
$payload = getPayload();
/**
* Generate Payload
*/
function getPayload($args = array())
{
$data = "";
$type = $_POST['type'];
$cardholder_name = $_POST['cardholder_name'];
$card_number = $_POST['card_number'];
$exp_date = $_POST['exp_date'];
$cvv = $_POST['cvv'];
$city = $_POST['city'];
$country = $_POST['country'];
$email = $_POST['email'];
$number = $_POST['number'];
$street = $_POST['street'];
$state_province = $_POST['state_province'];
$zip_postal_code = $_POST['zip_postal_code'];
$data = array(
'merchant_ref'=> '',
'transaction_type'=> "purchase",
'method'=> '$credit_card',
'amount'=> '0001',
'currency_code'=> 'USD',
'credit_card'=> array(
'type'=> '$type',
'cardholder_name'=> '$cardholder_name',
'card_number'=> '$card_number',
'exp_date'=> '$exp_date',
'cvv'=> '$cvv',
'VerificationStr1'=> array(
'city'=> '$city',
'country'=> '$country',
'email'=> '$email',
'phone'=> array(
'number'=> '$number',
'street'=> '$street',
'state_province'=> '$state_province',
'zip_postal_code'=> '$zip_postal_code',
)
)
)
);
return json_encode($data, JSON_FORCE_OBJECT);
}
$data = $apiKey . $nonce . $timestamp . $token . $payload;
$hashAlgorithm = "sha256";
### Make sure the HMAC hash is in hex -->
$hmac = hash_hmac ( $hashAlgorithm , $data , $apiSecret, false );
### Authorization : base64 of hmac hash -->
$hmac_enc = base64_encode($hmac);
$curl = curl_init('https://api.payeezy.com/v1/transactions');
$headers = array(
'Content-Type: application/json',
'apikey:'.strval($apiKey),
'token:'.strval($token),
'Authorization:'.$hmac_enc,
'nonce:'.$nonce,
'timestamp:'.$timestamp,
);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$response = json_decode($json_response, true);
if ( $status != 201 ) {
die("Error: call to URL $serviceURL failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
}
curl_close($curl);
echo "JSON response is: ".$json_response."\n";
?>
//for the heck of it we will call it payment.php^ (the above code)
<html>
<head>
<meta http-equiv="Content-Type" content="application/json; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1 ">
<title> </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="application/json; charset=ISO-8859-1" />
<meta name="layout" content="main" />
<style>
.line-separator {
height: .2px;
background: #717171;
border-bottom: 1px solid #d3d3d3;
}
.success{
border: 2px solid #00940;
background: #B3FFB3;
color: #555;
font-weight: bold;
}
.error {
border: 2px solid #DE001A;
background: #FFA8B3;
color: #000;
font-weight: bold;
}
</style>
<!-- JS and jquery reference Java-script files -->
<script>
function letterspaceOnly(input) {
var regex = /[^\n\r\t a-zA-Z0-9$.']/gi;
input.value = input.value.replace(regex, "");
}
</script>
<script>
function numbersOnly(input) {
var regex = /[^0-9]/gi;
input.value = input.value.replace(regex, "");
}
</script>
<script>
function emailOnly(input) {
var regex = /[^0-9a-zA-Z!@#$%&'*+-/=?^_'{|}]/gi;
input.value = input.value.replace(regex, "");
}
</script>
<script>
$(document).ready(function(){
$("#pay").click(function() {
var type = $("#type").val();
var cardholdername = $("#cardholder_name").val();
var cardnumber = $("#card_number").val();
var cvvcode = $("#cvv_code").val();
var expdate = $("#exp_date").val();
var city = $("#city").val();
var country = $("#country").val();
var email = $("#email").val();
var number = $("#number").val();
var street = $("#street").val();
var stateprovince = $("#state_province").val();
var zippostalcode = $("#zip_postal_code").val();
$.ajax({
type: "POST",
url:"ohyes.php"
data: "cardholder_name="+cardholdername+"&card_number="+cardnumber+"&cvv_code="+cvvcod e+"&exp_date="+expdate+"&city="+city+"&country="+country+"&email="+email+"&numbe r="+number+"&street="+street+"&state_province="+stateprovince+"&zip_postal_code= "+zippostalcode,
success: function(msg,string,jqXHR){
$("#result").html(msg+string+jqXHR);
}
});
});
});
</script>
</head>
<body>
<br>
<div>
<a href="https://developer.payeezy.com" title="Home"> <img
width="120" class="logo"
src="https://developer.payeezy.com/sites/default/files/Payeezy- DevelopersLogo_Horz.png"
alt="Payeezy" />
</a>
<div align="right">
<a href="index.html" title="Home">home page?</a>
</div>
</div>
<br>
<div class="line-separator"></div>
<div>
</div>
<form method="post" name="payment-info-form" id="myForm">
<h4 style="color: red">
<span id="payment-errors"></span>
</h4>
<h4 style="color: green">
<span id="response_msg"></span>
</h4>
<h4 style="color: blue">
<span id="response_note"></span>
</h4>
<div id="someHiddenDiv" style="display: none; color: red">Requesting
Payeezy token...</div>
<table>
<tr>
<td align="right">Card Type :</td>
<td><select required="" payeezy-data="type">
<option value="visa">Visa</option>
<option value="mastercard">Master Card</option>
<option value="American Express">American Express</option>
<option value="discover">Discover</option>
<option value="diners">Diners</option>
<option value="jcb">JCB</option>
</select></td>
</tr>
<tr>
<td align="right">Cardholder Name :</td>
<td><input type="text" onkeyup="letterspaceOnly(this)" required="" payeezy-data="cardholder_name"
value="" /></td>
</tr>
<tr>
<td align="right">Card Number :</td>
<td><input type="text" onkeyup="numbersOnly(this)" required="" payeezy-data="card_number"
value="" minlength="16" maxlength="16" /></td>
</tr>
<tr>
<td align="right">CVV Code :</td>
<td><input type="text" onkeyup="numbersOnly(this)" minlength="3" maxlength="4" payeezy-data="cvv_code" value="" />
<a href="https://www.cvvnumber.com/cvv.html" target="_blank" style="font- size:11px">What is my CVV code?</a>
</td>
</tr>
<tr>
<td align="right">Expiry Date :</td>
<td><select required="" payeezy-data="exp_date">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12" selected>12</option>
</select> <select payeezy-data="exp_year">
<option value="17">2017</option>
<option value="18">2018</option>
<option value="19">2019</option>
<option value="20">2020</option>
<option value="21">2021</option>
<option value="16">2022</option>
<option value="17">2023</option>
<option value="18">2024</option>
<option value="19">2025</option>
<option value="20">2026</option>
<option value="21">2027</option>
<option value="16">2028</option>
<option value="17">2029</option>
<option value="18">2030</option>
<option value="19">2031</option>
<option value="20">2032</option>
<option value="21">2033</option>
</select></td>
</tr>
<tr>
<td align="right">City :</td>
<td><input type="text" onkeyup="letterspaceOnly(this)" required="" payeezy-data="city"
value="" /></td>
</tr>
<tr>
<td align="right">Country :</td>
<td><select required="" payeezy-data="country">
<option value="US">United States</option></td>
</tr>
<tr>
<td align="right">Email :</td>
<td><input type="email" required="" onkeyup="emailOnly(this)" payeezy-data="email"
value="" /></td>
</tr>
<tr>
<td align="right">Phone Number :</td>
<td><input type="text" onkeyup="numbersOnly(this)" minlength="11" maxlength="11" required="" payeezy-data="number"
value="" /></td>
</tr>
<tr>
<td align="right">Address :</td>
<td><input type="text" onkeyup="letterspaceOnly(this)" required="" payeezy-data="street"
value="" /></td>
</tr>
<tr>
<td align="right">State Province :</td>
<td><select required="" payeezy-data="state_province"
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
<option value="AS">American Samoa</option>
<option value="GU">Guam</option>
<option value="MP">Northern Mariana Islands</option>
<option value="PR">Puerto Rico</option>
<option value="UM">United States Minor Outlying Islands</option>
<option value="VI">Virgin Islands</option>
<option value="AA">Armed Forces Americas</option>
<option value="AP">Armed Forces Pacific</option>
<option value="AE">Armed Forces Others</option>
</select> </td>
</tr>
<tr>
<td align="right">Postal Code :</td>
<td><input type="text" onkeyup="numbersOnly(this)" required="" payeezy-data="zip_postal_code" minlength="6" maxlength="9"
value="" /></td>
</tr>
</table>
<table>
<tr>
<td></td>
<td><input type="button" id="pay" value="submit" onsumbmit="myForm()" class="btn"></td>
<p><div id="formResponse"></div></p>
</tr>
</table>
</div>
</form>
</div>
</body>
</html>
lol i actually solved this along time ago... anyone using payeezy i want them to use this so here is the ajax solution code below. I did this in alert box so you can better understand it. Basically when the user clicks the button the form is passed to the processing page without leaving the page, in return sending out a json response hence alert box. Now you can taylor that to your needs say an echo or something. The button starts the function. The Post is where the data arrays are sent to be processed. After the response is sent back in alert box.
Ps...我不介意任何人使用此模板离开。
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"> </script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.post("payment.php",
{
type: "$type",
card_number: "$card_number",
exp_date: "$exp_date",
cvv: "$cvv",
city: "$city",
country: "$country",
email: "$email",
number: "$number",
street: "$street",
state_province: "$state_province",
zip_postal_code: "$zip_postal_code"
},
function(data,status){
alert("Data: " + data + "\nStatus: " + status);
});
});
});
</script>
</head>
<body>
<button>Send an HTTP POST request to a page and get the result back from payment processor</button>
我现在有一个小问题 我正在使用 PHP curl API 和 JSON 请求使用 ajax 提交表单(使用 ajax部分)?它不提交表单或得到响应。有没有人有提示可以帮助我处理 ajax 部分?我希望每个使用 payeezy 的人都可以选择使用您的 API 实现此代码。另外,我是否正确使用了用户 post PHP 和数据数组参数? Here is the php form response 请注意,我故意拒绝了这张卡,这是我想要的回复。
Here is the form itself 我希望 ajax 在不刷新页面的情况下在此处提交表单,并且 json 响应显示在表单页面上以指示交易是否成功。此外,如果卡被拒绝,我不希望表单提交并显示其相应的消息。
<?php
#require_once('payeezy-include.php');
$apiKey = "(your api key)";
$apiSecret = "( your api secret)";
$token = "(your merchant token)";
$nonce = strval(hexdec(bin2hex(openssl_random_pseudo_bytes(4, $cstrong))));
$timestamp = strval(time()*1000); //time stamp in milli seconds
$payload = getPayload();
/**
* Generate Payload
*/
function getPayload($args = array())
{
$data = "";
$type = $_POST['type'];
$cardholder_name = $_POST['cardholder_name'];
$card_number = $_POST['card_number'];
$exp_date = $_POST['exp_date'];
$cvv = $_POST['cvv'];
$city = $_POST['city'];
$country = $_POST['country'];
$email = $_POST['email'];
$number = $_POST['number'];
$street = $_POST['street'];
$state_province = $_POST['state_province'];
$zip_postal_code = $_POST['zip_postal_code'];
$data = array(
'merchant_ref'=> '',
'transaction_type'=> "purchase",
'method'=> '$credit_card',
'amount'=> '0001',
'currency_code'=> 'USD',
'credit_card'=> array(
'type'=> '$type',
'cardholder_name'=> '$cardholder_name',
'card_number'=> '$card_number',
'exp_date'=> '$exp_date',
'cvv'=> '$cvv',
'VerificationStr1'=> array(
'city'=> '$city',
'country'=> '$country',
'email'=> '$email',
'phone'=> array(
'number'=> '$number',
'street'=> '$street',
'state_province'=> '$state_province',
'zip_postal_code'=> '$zip_postal_code',
)
)
)
);
return json_encode($data, JSON_FORCE_OBJECT);
}
$data = $apiKey . $nonce . $timestamp . $token . $payload;
$hashAlgorithm = "sha256";
### Make sure the HMAC hash is in hex -->
$hmac = hash_hmac ( $hashAlgorithm , $data , $apiSecret, false );
### Authorization : base64 of hmac hash -->
$hmac_enc = base64_encode($hmac);
$curl = curl_init('https://api.payeezy.com/v1/transactions');
$headers = array(
'Content-Type: application/json',
'apikey:'.strval($apiKey),
'token:'.strval($token),
'Authorization:'.$hmac_enc,
'nonce:'.$nonce,
'timestamp:'.$timestamp,
);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$response = json_decode($json_response, true);
if ( $status != 201 ) {
die("Error: call to URL $serviceURL failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
}
curl_close($curl);
echo "JSON response is: ".$json_response."\n";
?>
//for the heck of it we will call it payment.php^ (the above code)
<html>
<head>
<meta http-equiv="Content-Type" content="application/json; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1 ">
<title> </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="application/json; charset=ISO-8859-1" />
<meta name="layout" content="main" />
<style>
.line-separator {
height: .2px;
background: #717171;
border-bottom: 1px solid #d3d3d3;
}
.success{
border: 2px solid #00940;
background: #B3FFB3;
color: #555;
font-weight: bold;
}
.error {
border: 2px solid #DE001A;
background: #FFA8B3;
color: #000;
font-weight: bold;
}
</style>
<!-- JS and jquery reference Java-script files -->
<script>
function letterspaceOnly(input) {
var regex = /[^\n\r\t a-zA-Z0-9$.']/gi;
input.value = input.value.replace(regex, "");
}
</script>
<script>
function numbersOnly(input) {
var regex = /[^0-9]/gi;
input.value = input.value.replace(regex, "");
}
</script>
<script>
function emailOnly(input) {
var regex = /[^0-9a-zA-Z!@#$%&'*+-/=?^_'{|}]/gi;
input.value = input.value.replace(regex, "");
}
</script>
<script>
$(document).ready(function(){
$("#pay").click(function() {
var type = $("#type").val();
var cardholdername = $("#cardholder_name").val();
var cardnumber = $("#card_number").val();
var cvvcode = $("#cvv_code").val();
var expdate = $("#exp_date").val();
var city = $("#city").val();
var country = $("#country").val();
var email = $("#email").val();
var number = $("#number").val();
var street = $("#street").val();
var stateprovince = $("#state_province").val();
var zippostalcode = $("#zip_postal_code").val();
$.ajax({
type: "POST",
url:"ohyes.php"
data: "cardholder_name="+cardholdername+"&card_number="+cardnumber+"&cvv_code="+cvvcod e+"&exp_date="+expdate+"&city="+city+"&country="+country+"&email="+email+"&numbe r="+number+"&street="+street+"&state_province="+stateprovince+"&zip_postal_code= "+zippostalcode,
success: function(msg,string,jqXHR){
$("#result").html(msg+string+jqXHR);
}
});
});
});
</script>
</head>
<body>
<br>
<div>
<a href="https://developer.payeezy.com" title="Home"> <img
width="120" class="logo"
src="https://developer.payeezy.com/sites/default/files/Payeezy- DevelopersLogo_Horz.png"
alt="Payeezy" />
</a>
<div align="right">
<a href="index.html" title="Home">home page?</a>
</div>
</div>
<br>
<div class="line-separator"></div>
<div>
</div>
<form method="post" name="payment-info-form" id="myForm">
<h4 style="color: red">
<span id="payment-errors"></span>
</h4>
<h4 style="color: green">
<span id="response_msg"></span>
</h4>
<h4 style="color: blue">
<span id="response_note"></span>
</h4>
<div id="someHiddenDiv" style="display: none; color: red">Requesting
Payeezy token...</div>
<table>
<tr>
<td align="right">Card Type :</td>
<td><select required="" payeezy-data="type">
<option value="visa">Visa</option>
<option value="mastercard">Master Card</option>
<option value="American Express">American Express</option>
<option value="discover">Discover</option>
<option value="diners">Diners</option>
<option value="jcb">JCB</option>
</select></td>
</tr>
<tr>
<td align="right">Cardholder Name :</td>
<td><input type="text" onkeyup="letterspaceOnly(this)" required="" payeezy-data="cardholder_name"
value="" /></td>
</tr>
<tr>
<td align="right">Card Number :</td>
<td><input type="text" onkeyup="numbersOnly(this)" required="" payeezy-data="card_number"
value="" minlength="16" maxlength="16" /></td>
</tr>
<tr>
<td align="right">CVV Code :</td>
<td><input type="text" onkeyup="numbersOnly(this)" minlength="3" maxlength="4" payeezy-data="cvv_code" value="" />
<a href="https://www.cvvnumber.com/cvv.html" target="_blank" style="font- size:11px">What is my CVV code?</a>
</td>
</tr>
<tr>
<td align="right">Expiry Date :</td>
<td><select required="" payeezy-data="exp_date">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12" selected>12</option>
</select> <select payeezy-data="exp_year">
<option value="17">2017</option>
<option value="18">2018</option>
<option value="19">2019</option>
<option value="20">2020</option>
<option value="21">2021</option>
<option value="16">2022</option>
<option value="17">2023</option>
<option value="18">2024</option>
<option value="19">2025</option>
<option value="20">2026</option>
<option value="21">2027</option>
<option value="16">2028</option>
<option value="17">2029</option>
<option value="18">2030</option>
<option value="19">2031</option>
<option value="20">2032</option>
<option value="21">2033</option>
</select></td>
</tr>
<tr>
<td align="right">City :</td>
<td><input type="text" onkeyup="letterspaceOnly(this)" required="" payeezy-data="city"
value="" /></td>
</tr>
<tr>
<td align="right">Country :</td>
<td><select required="" payeezy-data="country">
<option value="US">United States</option></td>
</tr>
<tr>
<td align="right">Email :</td>
<td><input type="email" required="" onkeyup="emailOnly(this)" payeezy-data="email"
value="" /></td>
</tr>
<tr>
<td align="right">Phone Number :</td>
<td><input type="text" onkeyup="numbersOnly(this)" minlength="11" maxlength="11" required="" payeezy-data="number"
value="" /></td>
</tr>
<tr>
<td align="right">Address :</td>
<td><input type="text" onkeyup="letterspaceOnly(this)" required="" payeezy-data="street"
value="" /></td>
</tr>
<tr>
<td align="right">State Province :</td>
<td><select required="" payeezy-data="state_province"
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
<option value="AS">American Samoa</option>
<option value="GU">Guam</option>
<option value="MP">Northern Mariana Islands</option>
<option value="PR">Puerto Rico</option>
<option value="UM">United States Minor Outlying Islands</option>
<option value="VI">Virgin Islands</option>
<option value="AA">Armed Forces Americas</option>
<option value="AP">Armed Forces Pacific</option>
<option value="AE">Armed Forces Others</option>
</select> </td>
</tr>
<tr>
<td align="right">Postal Code :</td>
<td><input type="text" onkeyup="numbersOnly(this)" required="" payeezy-data="zip_postal_code" minlength="6" maxlength="9"
value="" /></td>
</tr>
</table>
<table>
<tr>
<td></td>
<td><input type="button" id="pay" value="submit" onsumbmit="myForm()" class="btn"></td>
<p><div id="formResponse"></div></p>
</tr>
</table>
</div>
</form>
</div>
</body>
</html>
lol i actually solved this along time ago... anyone using payeezy i want them to use this so here is the ajax solution code below. I did this in alert box so you can better understand it. Basically when the user clicks the button the form is passed to the processing page without leaving the page, in return sending out a json response hence alert box. Now you can taylor that to your needs say an echo or something. The button starts the function. The Post is where the data arrays are sent to be processed. After the response is sent back in alert box.
Ps...我不介意任何人使用此模板离开。
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"> </script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.post("payment.php",
{
type: "$type",
card_number: "$card_number",
exp_date: "$exp_date",
cvv: "$cvv",
city: "$city",
country: "$country",
email: "$email",
number: "$number",
street: "$street",
state_province: "$state_province",
zip_postal_code: "$zip_postal_code"
},
function(data,status){
alert("Data: " + data + "\nStatus: " + status);
});
});
});
</script>
</head>
<body>
<button>Send an HTTP POST request to a page and get the result back from payment processor</button>