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'); ?>">
Related
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, :)
Am going to implement the paypal in the form of user subscription...
Bellow code runs fine...
Transaction also works fine...
But am not getting back the 'custom parameters' which i have send(as shown in following code of form)...
<form name="_xclick" id="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="xxx#xxx.com">
<!-- Specify a Subscribe button. -->
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<!-- Identify the subscription. -->
<input type="hidden" name="item_name" value="<?php echo $description; ?>">
<!-- Set the terms of the regular subscription. -->
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="a3" value="<?php echo $amount; ?>">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="<?php echo $trial_period; ?>">
<!-- Set recurring payments until canceled. -->
<input type="hidden" name="src" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="notify_url" value="<?php echo $return_domain;?>">
<input type="hidden" name="cancel_return" value="<?php echo $cancel_return;?>">
<input type="hidden" name="return" id="return" value="<?php echo $return_domain;?>" />
<input type="hidden" name="custom" value="<?php echo $serialized_cust_par;?>" />
</form>
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="POST">
<input type="hidden" name="invoice" id="" value="<?php echo $pay_data['order_id']; ?>" />
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="mymail#gmail.com">
<input type="hidden" name="item_name" value="suite number">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="amount" value="<?php echo $pay_data['amount']; ?>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="return" value="<?php echo base_url()."/home/paypal_subscripton"; ?>">
<input type="hidden" name="cancel_return" value="<?php echo base_url(); ?>">
<input type="hidden" name="notify_url" value="<?php echo base_url(); ?>" />
<input type="submit" value="Donate!" />
</form>
i payed successfully with this code. but page is not redirecting to my website? what is the problem with my code?
amount: 1
bn: PP-BuyNowBF
business: mymail#gmail.com
cancel_return: http://localhost/ebin/Spacelance/
cmd: _xclick
currency_code: USD
invoice: 50d04dd5ab186
item_name: suite number
item_number: 1
lc: US
no_note: 1
no_shipping: 1
notify_url: http://mydomain/ebin/Spacelance/
return: http://mydomain/ebin/Spacelance/home/paypal_subscripton
this is post params to paypal(from firebug)
If you're using the button as it looks like you are, Paypal only redirects users who have a Paypal account. This is what their documentation says:
Note: If you have turned on Auto Return and have chosen to turn on PayPal Account Optional for new users, a new user will not be automatically directed back to your website, but will be given the option to return.
So what I did, was create a page where the I would display instructions to click on the "return to website" link after the transaction is done. Though this is a very inefficient way of taking care of it.
source: www.sandbox.paypal.com/?cmd=p/pop/express_return_learn_more
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.
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.