Zenguy
New Member
I'm having trouble getting my button to work.
Below is my code so far.
Can you give me some direction or do you have some code for a button?
I wasn't sure if I had to create code to figure out the fees either...so that's
in there too.
Thanks for your time
Below is my code so far.
Can you give me some direction or do you have some code for a button?
I wasn't sure if I had to create code to figure out the fees either...so that's
in there too.
Code:
<?php
function paypalFees($sub_total, $round_fee) {
// Set Fee Rate Variables :
$fee_percent = '2.9';
$fee_cash = '0.30';
// Calculate Fees
$paypal_fee = ((($sub_total / 100) * $fee_percent) + $fee_cash);
if ($round_fee == true) {
$paypal_fee = ceil($paypal_fee);
}
// Calculate Grand Total
$grand_total = ($sub_total + $paypal_fee);
// Tidy Up Numbers
$sub_total = number_format($sub_total, 2, '.', ',');
$paypal_fee = number_format($paypal_fee, 2, '.', ',');
$grand_total = number_format($grand_total, 2, '.', ',');
// Return Array
return array('grand_total'=>$grand_total, 'paypal_fee'=>$paypal_fee, 'sub_total'=>$sub_total);
}
// Set the fees and gross minus fees
$calc = paypalFees('20.00', false);
$mc_gross = $receipt['sub_total'];
$mc_fee = $receipt['paypal_fee'];
$settle_amount = $mc_gross - $mc_fee;
?>
<form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<!-- Business Info -->
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="notify_url" value="http://mysite.com/ipn/ipn_process.php">
<input type="hidden" name="return" value="http://mysite.com/ppb.php">
<input type="hidden" name="receiver_email" value="[email protected]" />
<input type="hidden" name="mc_currency" value="USD">
<input type="hidden" name="settle_currency" value="USD">
<!-- Customer Info -->
<input name="first_name" type="hidden" value="First Name" />
<input name="last_name" type="hidden" value="Last Name" />
<input name="payer_email" type="hidden" value="[email protected]" />
<input name="payer_business_name" type="hidden" value="Payer Business Name" />
<input name="address_street" type="hidden" value="10 Home Street" />
<input name="address_zip" type="hidden" value="K7K 9A9" />
<input name="address_city" type="hidden" value="Ottawa" />
<input name="address_state" type="hidden" value="Ontario" />
<input name="address_country" type="hidden" value="Canada" />
<input name="address_country_code" type="hidden" value="CA" />
<input name="residence_country" type="hidden" value="CA" />
<!-- Art Item Info -->
<input type="hidden" name="on0" value="Item Name">Art Item Name<br />
<input type="text" name="os0" maxlength="200"><br />
<input type="hidden" name="on1" value="Item Size">Art Item Size<br />
<input type="text" name="os1" maxlength="200"><br />
<input type="hidden" name="on2" value="Item Info">Art Item Info<br />
<input type="text" name="os2" maxlength="200"><br />
<!-- Item Customer Is Purchasing -->
<input type="hidden" name="item_name" value="Call For Art - 1 Item">
<input type="hidden" name="item_number" value="CFA-001">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="mc_gross" value="<?php echo $mc_gross;?>">
<input type="hidden" name="amount" value="<?php echo $mc_gross;?>">
<input type="hidden" name="mc_fee" value="<?php echo $mc_fee;?>">
<input type="hidden" name="settle_amount" value="<?php echo $settle_amount;?>">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="shipping" value="0">
<input type="hidden" name="tax" value="0">
<input type="image" src="http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
Thanks for your time