cancel
Showing results for 
Search instead for 
Did you mean: 

I need help working out paypal new smart checkout (no item shop, just add balance)

Options
MikePHP
Contributor
Posted on

Hello,

This is the code I've been using for a decade:

HTML:

 

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
	<input type="textarea" id="euroAmount" name="amount" value="" placeholder="How much to spend.."/><br/>
	<input type="hidden" name="cmd" value="_xclick"/>
	<input type="hidden" name="business" value="mymail"/>
	<input type="hidden" name="lc" value="en_US"/>
	<input type="hidden" name="item_name" value="Item at mysite"/>
	<?php echo '<input type="hidden"  name="custom" value="'.$user_id.'">'; ?>
	<input type="hidden" name="button_subtype" value="products"/>
	<input type="hidden" name="currency_code" value="EUR"/>
	<input type="hidden" name="no_shipping" value="1"/>
	<input type="hidden" name="no_note" value="1"/>
	<input type="hidden" name="notify_url" value="https://mysite/ipn.php"/>
	<input type="hidden" name="return" value="https://mysite/shop"/>
	<input type="hidden" name="rm" value="0"/>
	<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest"/>
	<input type="submit" class="btn btn-success" name="submit" value="Purchase with paypal"/><br/>
</form>

 

 

PHP:

 

<?php
if(gethostbyaddr($_SERVER['REMOTE_ADDR']) != 'notify.paypal.com'){ 
	exit();
}
	// Variables //
	$receiverEmail	= htmlspecialchars(strtolower($_REQUEST['receiver_email']));
	$paymentStatus	= htmlspecialchars(strtolower($_REQUEST['payment_status']));
	$account_id		= (int)$_REQUEST['custom'];
	$time			= (int)time();
	$transaction_id	= htmlspecialchars($_REQUEST['txn_id']);
	$transaction_type	= htmlspecialchars($_REQUEST['txn_type']);
	$money_gross	= (int)$_REQUEST['mc_gross'];
	$money_fee		= (int)$_REQUEST['mc_fee'];
	$money_net		= (int)($money_gross-$money_fee);
	$money_currency	= htmlspecialchars(strtolower($_REQUEST['mc_currency']));
	$payer_email	= htmlspecialchars($_REQUEST['payer_email']);
	$payer_id		= htmlspecialchars($_REQUEST['payer_id']);
	$first_name		= htmlspecialchars($_REQUEST['first_name']);
	$last_name		= htmlspecialchars($_REQUEST['last_name']);
	
    // Setup
    $receiver = 'mymail';
    if($paymentStatus == 'completed' && ($receiverEmail == $receiver) && $money_gross > 0 && $money_currency == "eur"){
		//allowed payment, giving the user whatever was ordered
    }elseif($paymentStatus == 'reversed' && ($receiverEmail == $receiver)){
		//do something
    }else{
        exit();
    }
?>

 

 

 

 

 

 

I've tried to look into manuals for the new smart checkout, but to be honest, there's A LOT of things there and since I'm not used to those new things I don't even know where to look.

 

All I need is a HTML/PHP system there the amount of EUR is changeable depending on how much the user wants to purchase for.

 

To make this easier to understand, I let users "add balance" to my website.

So that's what I want and need, a friendly code that allow the user to edit how much he'd like to add to balance and that the balance is refilled automatically and quickly.

 

I'm sorry for sounding like a complete noob, but these new things are so confusing, especially when it seems like most of it is for carts of physical item sellers.

 

Sincerely, Mike

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.