I am trying to learn integrating paypal for shopping checkouts. I have created a website with custom cart. Now I have added the paypal integration code after watching this http://www.youtube.com/watch?v=qDbTqeSUrQY&feature=relmfu
It works but only problem is when I try it out with sandbox, or real account from buyers perspective I can't use credit card i.e i need paypal account to perform. I have no idea whether I need to change the code or change settings in paypal. I tried going through their documents nothing is mention, it says i can accept credit card payments in express and standard accounts, but how?
The code I used
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="abhishek.salian.85#gmail.com">
<?php if($_SESSION['cart']) { $total = 0;$i=0;
foreach($_SESSION['cart'] as $product_id => $quantity) {
$product_details = get_product_details($product_id);
$row_cost = $product_details[product_price] * $quantity;
$total = $total + $row_cost; $x=$i+1; ?>
<input type="hidden" name="item_name_<?php echo $x; ?>" value="<?php echo $product_details[product_title]; ?>">
<input type="hidden" name="quantity_<?php echo $x; ?>" value="<?php echo $_SESSION['cart'][product_id]; ?>">
<input type="hidden" name="amount_<?php echo $x; ?>" value="<?php echo $product_details[product_price]; ?>">
<?php $product_id_array = $product_details[product_id]."-".$_SESSION['cart'][product_id].",";$i++; } } ?>
<input type="hidden" name="custom" value="<?php echo $product_id_array; ?>">
<input type="hidden" name="notify_url" value="<?php echo WEBSITE.'paypal/ipn.php'; ?>">
<input type="hidden" name="return" value="<?php echo WEBSITE.'products/thank_you'; ?>">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="cbt" value="Retun to Flash Shop">
<input type="hidden" name="cancel_return" value="<?php echo WEBSITE.'products/cancel'; ?>">
<input type="hidden" name="lc" value="AU">
<input type="hidden" name="currency_code" value="AUD">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"></form>
I believe that's a setting in your seller account - not something you pass in with the form.
Under Profile, fund the "Website Payment Preferences" link and then look for the "PayPal Account Optional" section. Choose "On" and save your settings.
Related
I have integrated Paypal standard payment in my php website now i required to send tax in Paypal payment so i have pass tax_rate variable in paypal form, all are working nice but tax is not send in paypal.
My Paypal form code is below.
<form action="<?php echo PAYPAL_URL;?>" name="paypalForm" method="post">
<input type="hidden" name="business" value="<?php echo PAYPAL_EMAIL;?>">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_name" id="item_name" value="<?php echo $mainObj->listing_title;?>">
<input type="hidden" name="item_number" id="item_number" value="<?php echo $booking_id;?>">
<input type="hidden" name="custom" value="<?php echo $mainObj->user_id.'__'.$objExtraPostData->message_to_host.'__'.$objExtraPostData->host_call.'__'.$vat.'__'.$mainObj->pay_price.'__'.$guest_invite_id.'__'.$host_invite_id.'__'.$review_guest_invite_id.'__'.$review_host_invite_id; ?>"/>
<input type="hidden" name="amount" id="amount" value="<?php echo $mainObj->pay_price;?>">
<input type="hidden" name="discount_amount" id="discount_amount" value="<?php echo $discount_price;?>">
<input type="hidden" name="tax_rate" value="<?php echo $vat;?>">
<input type="hidden" name="currency_code" value="<?php echo DEFAULT_PAYMENT_CURRENCY_CODE;?>">
<input type="hidden" name="return" value="<?php echo SITE_MOD."nct-paypal/thankyou.php";?>">
<input type="hidden" name="cancel_return" value="<?php echo SITE_MOD."nct-paypal/failed.php";?>">
<input type="hidden" name="notify_url" value="<?php echo SITE_MOD."nct-paypal/notify.php";?>">
</form>
Check if the tax_rate can be used with your payment type. In addition, it might be better when you set your tax rate in your account profile as described beneath.
Transaction-based tax override variable. Set this variable to a percentage that applies to the amount multiplied by the quantity selected during checkout. This value overrides any tax settings set in your account profile. Allowable values are numbers 0.001 through 100. Valid only for Buy Now and Add to Cart buttons. Default – Profile tax settings, if any, apply.
I create a function for admin of my website send money back to users using Paypal. I created a button with Paypal. My problem is: when Admin login Paypal with business account then he send money to personal account, Paypal do not redirect to my website.
Here is my code
<form target="myWindowPayment" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="payPalForm">
<input type="hidden" name="item_number" value="<?php echo $idProject ?>">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="business" value="charly#zondertag.net">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="return" value="<?php echo base_url() ?>crowdpp/backingProject/3">
<input type="hidden" name="cancel" value="<?php echo base_url() ?>crowdpp/backingProject/3">
<input name="item_name" type="hidden" id="item_name" value="Pledging for <?php echo $result->title ?> project" size="45">
<input name="amount" type="hidden" id="amount" value="<?php echo $pledgeAmount ?>" size="45">
</form>
In payment integration,we get two results.
1.successful payment
2.unsuccessful payment
put success page name in return url if successful payment.put failure page name in cancelurl if unsuccessful payment.example.
$setExpressCheckoutRequestDetails->ReturnURL = "http://localhost:8080/success.php";
$setExpressCheckoutRequestDetails->CancelURL = "http://localhost:8080/cancel.php";
<input type="hidden" name="return_url" value="<?php echo urlencode(base_url().'crowdpp/backingProject/3'); ?>">
<input type="hidden" name="return" value="<?php echo urlencode(base_url().'crowdpp/backingProject/3'); ?>">
I am using paypal REST API for making direct payments.
I want to create internal transaction id before initiating the transaction and use that for identifying the transactions from my end.
I am trying to set id using
$payment = new Payment();
$payment->setId($tId);
Paypal is approving the request and payment is getting done but I am not getting this id in response.
Is there any way by which I can send custom parameters to paypal and get them back in response?
You can use custom variable to pass your custom data, and paypal will return it backto you in post in response.
<input type="hidden" name="amount" value="<?php echo $totalAmount; ?>"/>
<input type="hidden" name="business" value="your_paypal_biz_id"/>
<input type="hidden" name="notify_url" value="<?php echo site_url(); ?>/zad_notify.php"/>
<input type="hidden" name="item_name" value="Image editing"/>
<input type="hidden" name="currency_code" value="USD"/>
<input type="hidden" name="return" value="<?php echo $paypalReturnUrl; ?>"/>
<input type="hidden" name="cancel_return" value="<?php echo site_url(); ?>/payment_error.php?id=<?php echo $sr_no; ?>"/>
<input type="hidden" name="custom" value="<?php echo $sr_no; ?>" />
alternatively you can also pass your id in notify url as query string parameter and you will get it back in return url file.
<input type="hidden" name="amount" value="<?php echo $totalAmount; ?>"/>
<input type="hidden" name="business" value="your_paypal_biz_id"/>
<input type="hidden" name="notify_url" value="<?php echo site_url(); ?>/zad_notify.php?id=5"/>
<input type="hidden" name="item_name" value="Image editing"/>
<input type="hidden" name="currency_code" value="USD"/>
<input type="hidden" name="return" value="<?php echo $paypalReturnUrl; ?>"/>
<input type="hidden" name="cancel_return" value="<?php echo site_url(); ?>/payment_error.php?id=<?php echo $sr_no; ?>"/>
Hope this help to you, :)
For checking out process while redirecting the user https://www.sandbox.paypal.com the paypal does not show more than one type item and only the last (with its quantity) i.e, if user add two types product in his cart and click for checking out process the paypal show only the second type with its quantity but not the first type in billing process. how can i solve the problem?
here is my api code in view file
<form style=" padding:0px;margin:0px;" name="frmOrderAutoSubmit" method="post" >
<input type="hidden" name="upload" value="1">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="sunymegh#gmail.com">
<?php $cdata = $this->cart->contents() ?>
<?php foreach ($cdata as $items) { ?>
<input type="hidden" name="quantity" value="<?php echo $items['qty']; ?>" />
<input type="hidden" name="item_name" value=" <?php echo $items['name']; ?>"/>
<input type="hidden" name="amount" value="<?php echo $items['price']; ?>"/>
<input type="hidden" name="rm" value="2" />
<input TYPE="hidden" name="address_override" value="0">
<?php } ?>
</form>
You only have one name attribute submitted name="quantity" for example. PayPal uses a format of name="quantity_1".
I have integrated paypal with my website and but it does take the payment but it doesnot send any IPN to my php file which should update my databse....
there is the code I have been using:
to call
session_start();
if($mode=='live')
{
$url=" https://www.paypal.com/cgi-bin/webscr";
$email="nnnnnnn_singh#live.com";
$_SESSION['url']=$url;
$_SESSION['email']=$email;
$_SESSION['subtotal']=$subtotal;
}
else if($mode=='sandbox')
{
$url= "https://www.sandbox.paypal.com/cgi-bin/webscr";
$email="nnnnnnn_1329707350_biz#gmail.com";
$_SESSION['url']=$url;
$_SESSION['email']=$email;
$_SESSION['subtotal']=$subtotal;
}
?>
<form action="<?php echo $url; ?>" method="post">
<input type="hidden" name="cmd" value="_xclick"/>
<input type="hidden" name="business" value="<?php echo $email; ?>"/>
<input type="hidden" name="item_name" value="shopping cart"/>
<input type="hidden" name="currency_code" value="GBP"/>
<input type="hidden" name="amount" value="<?php echo $subtotal;?>"/>
<input type="hidden" name="return" value="<?php echo SITE_URL; ?>"/>
<input type="hidden" name="cancel_return" value="<?php echo SITE_URL."/shoppingCart.php" ?>"/>
<input type="hidden" name="notify_url" value="php url" />
<input type="hidden" name="rm" value="2"/>
<input type="hidden" name="custom" value="<?php echo $customer_ID;?>"/>
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"/>
</form>
and php code
from php IPN sample code.....
Try:
1. login in your paypal account
2. go to profile --> History --> IPN history --> turn on my IPN
3. insert your IPN listener URL.
What's the value of:
<input type="hidden" name="notify_url" value="php url" />
This shouldn't be on localhost, since PayPal sends POST data from its servers to that URL. So localhost won't work.