simple paypal with add entry in backend


<!-- Paypal form -->
<?php $pageURL = "http://localhost/sublimesourcery/treasure-trove/"; ?>
<!--<form action="https://www.paypal.com/cgi-bin/webscr" method="post">-->
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="raviradadiya.ommune-facilitator@gmail.com">
<input type="hidden" name="item_name" value="Donation">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="amount" value="1">

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

<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 $pageURL; ?>">
<input type="submit" value="Pay with PayPal!">
</form>
<!-- End Paypal form -->

<?php
if(!empty($_POST)){

global $wpdb;
$player_name = $_POST['first_name'];
$payer_email = $_POST['payer_email'];
$payment_gross = $_POST['payment_gross'];
$payment_date = $_POST['payment_date'];
$payer_id = $_POST['payer_id'];

$wpdb->insert(
'wp_paypal',
array(
'name' => $player_name,
'player_id' =>$payer_id,
'email' =>  $payer_email,
'amount' => $payment_gross,
'payment_date' => $payment_date
),
array(
'%s',
'%s',
'%s',
'%s',
)
);

//echo '<pre>';
//print_r($_POST);
/*$paypal_str = array($player_name, $payer_email, $payment_gross, $payment_date, $payer_id);
echo '<pre>';
print_r($paypal_str);

//$comma_separated = implode(",", $paypal_str);
//echo $comma_separated; // lastname,email,phone
global $wpdb;
$wpdb->insert(
'wp_paypal',
array(
'name' =>  $paypal_str[0],
'email' => $paypal_str[1],
'amount' => $paypal_str[2],
'player_id' => $paypal_str[3],
'date' => $paypal_str[4],
)
);*/
}

/* For Displayind data in backend */
functions.php


add_action('admin_menu', 'my_menu_pages');
function my_menu_pages(){
add_menu_page('Members', 'Members', 'manage_options', 'my-menu', 'my_menu_output', 'dashicons-groups' );
//add_submenu_page('my-menu', 'Submenu Page Title', 'Whatever You Want', 'manage_options', 'my-menu' );
}
function my_menu_output(){
echo '<h2>All Membrs</h2>';
global $wpdb;
$retrieve_data = $wpdb->get_results( "SELECT * FROM wp_paypal" );
echo '<table border=1 class="table table-striped"><tr><th>Name</th><th>Email</th><th>Amount</th><th>Player id</th><th>Payment Date</th></tr>';
foreach ($retrieve_data as $retrieved_data){
echo '<tr><td>'. $retrieved_data->name.'</td>';
echo '<td>'.$retrieved_data->email.'</td>';
echo '<td>'. $retrieved_data->amount.'</td>';
echo '<td>'. $retrieved_data->player_id.'</td>';
echo '<td>'. $retrieved_data->payment_date.'</td>';
}
echo '</table>';
}

Advertisements

Tagged:

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: