如何让我的注册脚本检查付款验证

时间:2022-05-09 21:02:11

//Users Registration Function
function vpb_users_registration() 
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var vpb_fullname = $("#fullname").val();
	var vpb_username = $("#username").val();
	var vpb_email = $("#email").val();
	var vpb_passwd = $("#passwd").val();
	
	if(vpb_fullname == "")
	{
		$("#signup_status").html('<div class="info">Please enter your fullname in the required field to proceed.</div>');
		$("#fullname").focus();
	}
	else if(vpb_username == "")
	{
		$("#signup_status").html('<div class="info">Please enter your desired username to proceed.</div>');
		$("#username").focus();
	}
	else if(vpb_email == "")
	{
		$("#signup_status").html('<div class="info">Please enter your email address to proceed.</div>');
		$("#email").focus();
	}
	else if(reg.test(vpb_email) == false)
	{
		$("#signup_status").html('<div class="info">Please enter a valid email address to proceed.</div>');
		$("#email").focus();
	}
	else if(vpb_passwd == "")
	{
		$("#signup_status").html('<div class="info">Please enter your desired password to go.</div>');
		$("#passwd").focus();
	}
	else
	{
		var dataString = 'vpb_fullname='+ vpb_fullname + '&vpb_username=' + vpb_username + '&vpb_email=' + vpb_email + '&vpb_passwd=' + vpb_passwd + '&page=signup';
		$.ajax({
			type: "POST",
			url: "vpb_save_details.php",
			data: dataString,
			cache: false,
			beforeSend: function() 
			{
				$("#signup_status").html('<br clear="all"><br clear="all"><div align="left"><font style="font-family:Verdana, Geneva, sans-serif; font-size:12px; color:black;">Please wait</font> <img src="images/loadings.gif" alt="Loading...." align="absmiddle" title="Loading...."/></div><br clear="all">');
			},
			success: function(response)
			{
				var vpb_result_broght = response.indexOf('completed');
				if (vpb_result_broght != -1 ) 
				{
					$("#fullname").val('');
					$("#username").val('');
					$("#email").val('');
					$("#passwd").val('');
					$("#signup_status").hide().fadeIn('slow').html(response);
				}
				else
				{
					$("#signup_status").hide().fadeIn('slow').html(response);
				}
				
			}
		});
	}
}

//Users Login Function
function vpb_users_login() 
{
	var vpb_username = $("#username").val();
	var vpb_passwd = $("#passwd").val();
	
	if(vpb_username == "")
	{
		$("#login_status").html('<div class="info">Please enter your account username to proceed.</div>');
		$("#username").focus();
	}
	else if(vpb_passwd == "")
	{
		$("#login_status").html('<div class="info">Please enter your account password to go.</div>');
		$("#passwd").focus();
	}
	else
	{
		var dataString = 'vpb_username=' + vpb_username + '&vpb_passwd=' + vpb_passwd + '&page=login';
		$.ajax({
			type: "POST",
			url: "vpb_save_details.php",
			data: dataString,
			cache: false,
			beforeSend: function() 
			{
				$("#login_status").html('<br clear="all"><br clear="all"><div align="left"><font style="font-family:Verdana, Geneva, sans-serif; font-size:12px; color:black;">Please wait</font> <img src="images/loadings.gif" alt="Loading...." align="absmiddle" title="Loading...."/></div><br clear="all">');
			},
			success: function(response)
			{
				var vpb_result_broght = response.indexOf('completed');
				if (vpb_result_broght != -1 ) 
				{
					$("#login_status").html('');
					$("#username").val('');
					$("#passwd").val('');
					window.location.replace("index1.php");
					
				}
				else
				{
					$("#login_status").hide().fadeIn('slow').html(response);
				}
				
			}
		});
	}
}

I want my signup form to check if payment was processed before saving the user credentials to the database which will gain them access to the member section. once payment is processed I want the user's information to log them into thier account. the way i have my code setup is so that the usernames/database saved in a txt file on the hosting site.

我希望我的注册表单在将用户凭据保存到数据库之前检查付款是否已处理,这将使他们能够访问成员部分。处理完付款后,我希望用户的信息将其记录到他们的帐户中。我的代码设置方式是将用户名/数据库保存在托管站点的txt文件中。

1 个解决方案

#1


0  

What you posted has nothing to do with payment, credit card numbers, etc. I only see full name, user name, password, email. Looks like functionality to log in or create a user.

您发布的内容与付款,信用卡号等无关。我只看到全名,用户名,密码,电子邮件。看起来像登录或创建用户的功能。

On the server side you have to have some code for the merchant processing (PHP for example) and it should return a disposition telling you if the charge was successful or not. If you don't have code implemented for Paypal already, I'd recommend using Stripe, they have low 2.9% fees and no monthly fees and it's extremely easy to implement.

在服务器端,您必须有一些商家处理代码(例如PHP),它应该返回一个处理,告诉您收费是否成功。如果你没有为Paypal实现代码,我建议使用Stripe,它们的费用低2.9%而且没有月费,而且非常容易实现。

In Javascript, on the client side, you could use the $.post method, or $.ajax like you're doing already in your call to vbp_save_details.php

在Javascript中,在客户端,您可以使用$ .post方法或$ .ajax,就像您在调用vbp_save_details.php时已经做的那样

Personally, I use the $.post method. On the server, my payment processing script returns a json object letting you know if it was approved or not. Something like this:

就个人而言,我使用$ .post方法。在服务器上,我的付款处理脚本返回一个json对象,通知您是否已批准。像这样的东西:

$.post('stripe.php',payload,
    function(data) {
        $('#submit_button').removeAttr('disabled');
        var json = JSON.parse(data);
        console.log(json);
        if ( json.disposition == 1 ) {
            console.log("APPROVED");
            window.location.href = "thank_you.php";
        } else {
            console.log("DECLINED");
        }
    }
);

#1


0  

What you posted has nothing to do with payment, credit card numbers, etc. I only see full name, user name, password, email. Looks like functionality to log in or create a user.

您发布的内容与付款,信用卡号等无关。我只看到全名,用户名,密码,电子邮件。看起来像登录或创建用户的功能。

On the server side you have to have some code for the merchant processing (PHP for example) and it should return a disposition telling you if the charge was successful or not. If you don't have code implemented for Paypal already, I'd recommend using Stripe, they have low 2.9% fees and no monthly fees and it's extremely easy to implement.

在服务器端,您必须有一些商家处理代码(例如PHP),它应该返回一个处理,告诉您收费是否成功。如果你没有为Paypal实现代码,我建议使用Stripe,它们的费用低2.9%而且没有月费,而且非常容易实现。

In Javascript, on the client side, you could use the $.post method, or $.ajax like you're doing already in your call to vbp_save_details.php

在Javascript中,在客户端,您可以使用$ .post方法或$ .ajax,就像您在调用vbp_save_details.php时已经做的那样

Personally, I use the $.post method. On the server, my payment processing script returns a json object letting you know if it was approved or not. Something like this:

就个人而言,我使用$ .post方法。在服务器上,我的付款处理脚本返回一个json对象,通知您是否已批准。像这样的东西:

$.post('stripe.php',payload,
    function(data) {
        $('#submit_button').removeAttr('disabled');
        var json = JSON.parse(data);
        console.log(json);
        if ( json.disposition == 1 ) {
            console.log("APPROVED");
            window.location.href = "thank_you.php";
        } else {
            console.log("DECLINED");
        }
    }
);