Paypal Integration with custom fields


1) Create simple user form

2) Create simple paypal form

3) paypal form auto submit on user form submit (Using Ajax Trigger)

4) User and User meta create in database when user make payment successfully and return on website. (Admin User and Created user get username and password via email address).

5) Paypal Account for Sandbox(Test) and Business Managed from themeoptions.

membership.php (pagetemplate)

//echo "<pre>";

$paypal_payer_id = $_POST['payer_id'];
$paypal_payment_gross = $_POST['payment_gross'];
$paypal_payer_email = $_POST['payer_email'];
$paypal_payment_date = $_POST['payment_date'];
$paypal_custom = $_POST['custom'];
$data_explode = explode(",",$paypal_custom);

$mname = $data_explode[0];
$maddress = $data_explode[1];
$mphone = $data_explode[2];
$memail = $data_explode[3];
$muname = $data_explode[4];
$mpass = $data_explode[5];

$data_explode = array(
'user_email' => $data_explode[3],
'user_login' => $data_explode[4],
'user_pass' =>  $data_explode[5],

$user_id = wp_insert_user($data_explode);

update_user_meta($user_id, 'm_name', $mname);
update_user_meta($user_id, 'm_address', $maddress);
update_user_meta($user_id, 'm_phone_num', $mphone);

update_user_meta($user_id, 'paypal_payer_id', $paypal_payer_id);
update_user_meta($user_id, 'paypal_payment_gross', $paypal_payment_gross);
update_user_meta($user_id, 'paypal_payer_email', $paypal_payer_email);
update_user_meta($user_id, 'paypal_payment_date', $paypal_payment_date);

$blogusers = get_users( 'role=administrator');
foreach ( $blogusers as $user ) {

$to = array($memail,$from_email);
//$urllink = ""; //get_page_link(54);
$subject = 'Your Admin Password';
$body = 'Your User name is: <b>' . $muname . '</b> </br>
Your Password is: <b>' . $mpass . '</b></br>';
wp_mail($to, $subject, $body);


<form id="ajaxform_member" action="ajaxform_member" method="post">
<table class="signup-tbl">
<td><label for="mname">Name:</label></td>
<td><input type="text" required id="mname" name="mname"></td>
<td><label for="maddress">Address:</label></td>
<td><input type="text" name="maddress" id="maddress" required></td>
<td><label for="mphone_num">Phone Number:</label></td>
<td><input type="text" name="mphone_num" id="mphone_num" required></td>
<td><label for="memail">Email:</label></td>
<td><input type="email" name="memail" id="memail" required></td>
<td><label for="muname">User Name:</label></td>
<td><input type="text" name="muname" id="muname" required></td>
<td><label for="mpass">Password:</label></td>
<td><input type="password" name="mpass" id="mpass" required></td>
<input class="signup-tbl-btn" id="form-ajax-submit" type="button" value="Paypal Ckeckout " name="mregister">
<p class="status"></p>

<!-- <form action="" method="post" id="point_buy"> -->
<!-- <form action="" method="post" id="point_buy"> -->
<form action="<?php if($medics_options['paypalac']== 'YES') { echo ''; } else { echo ''; } ?>" method="post" id="point_buy">

<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="
<?php if($medics_options['paypalac'] == 'YES') {  echo sanitize_email($medics_options['paypal_email']); } else { echo sanitize_email($medics_options['paypal_business_email']); }?>">

<input type="hidden" name="amount" id="amount" value="<?php if(!empty($medics_options['paypal_amount'])) { echo esc_attr($medics_options['paypal_amount']); } ?>" >

<input type="hidden" name="rm" value="2">
<input type="hidden" name="custom" id="paypal_custom" value="" />

<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="AU">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="return" value="<?php echo get_permalink(115); ?>" />

<br /><br />
<input class="paypal" type="image" src="" style="width:auto; height:auto; border:0;" alt="PayPal" />


jQuery(document).ready(function($) {
var mname = $("#mname").val();
var maddress = $("#maddress").val();
var mphone_num = $("#mphone_num").val();
var memail = $("#memail").val();
var muname = $("#muname").val();
var mpass = $("#mpass").val();

if($("#mname").val() == "" ){
alert('Enter Name');
return false;
if($("#maddress").val() == "" ){
alert('Enter Address');
return false;
if($("#mphone_num").val() == "" ){
alert('Enter Phone Number');
return false;
if($("#memail").val() == "" ){
alert('Enter Email');
return false;
if($("#muname").val() == "" ){
alert('Enter User Name');
return false;
if($("#mpass").val() == "" ){
alert('Enter Password');
return false;
type: 'POST',
dataType: 'json',
url: ajax_signup_object.ajaxurl,
data: {
'action': 'member', //calls wp_ajax_nopriv_ajaxsignup
'mname': $('#mname').val(),
'maddress': $('#maddress').val(),
'mphone_num': $('#mphone_num').val(),
'memail': $('#memail').val(),
'muname': $('#muname').val(),
'mpass': $('#mpass').val(),
success: function (response) {


<div class="ft-control">
<div class="explain"><?php _e( 'Select Youre Paypal Account.', 'medics' ) ?></div>
<?php if(empty($medics_options['paypalac'])) $medics_options['paypalac']='NO'; ?>
<input type="radio"  name="medics_theme_options[paypalac]" <?php if($medics_options['paypalac']== 'YES') { ?> checked="checked" <?php } ?> value="YES"/>Business Account
<input type="radio"  name="medics_theme_options[paypalac]" <?php if($medics_options['paypalac']== 'NO') { ?> checked="checked" <?php } ?> value="NO"/>Sendbox Account
<div class="ft-control">
<div class="explain"><?php _e( 'Enter Youre Paypal Business Email Asddress here.', 'medics' ) ?></div>
<input type="text" id="paypal_business_email" class="of-input" name="medics_theme_options[paypal_business_email]" size="32"  value="<?php if(!empty($medics_options['paypal_business_email'])) { echo sanitize_email($medics_options['paypal_business_email']); } ?>">
<div class="ft-control">
<div class="explain"><?php _e( 'Enter Youre Paypal Test Email Asddress here.', 'medics' ) ?></div>
<input type="text" id="paypal_email" class="of-input" name="medics_theme_options[paypal_email]" size="32"  value="<?php if(!empty($medics_options['paypal_email'])) { echo sanitize_email($medics_options['paypal_email']); } ?>">
<div class="ft-control">
<div class="explain"><?php _e( 'Enter Youre Product Amount here.', 'medics' ) ?></div>
<input type="number" id="paypal_amount" class="of-input" name="medics_theme_options[paypal_amount]" size="32"  value="<?php if(!empty($medics_options['paypal_amount'])) { echo esc_attr($medics_options['paypal_amount']); } ?>">



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: