hear is my code for paypal payment it redirects to login of paypal gateway,
but i want it redirect to direct payment page so that if i haven't paypal account
i can countinue with that option.
<?php
$paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$paypal_id = 'gohilpriyank-facilitator#ymail.com';
?>
<div class="form-group row-fluid">
<div class="span6">
<span style="font-weight: bold">Ship To Address:-</span>
<div><?php echo $ship_to['ship_address']; ?></div>
<div><?php echo $ship_to['ship_landmark']; ?></div>
<div><?php echo $ship_to['ship_city']; ?></div>
<div><?php echo $ship_to['ship_state']; ?></div>
<div><?php echo $ship_to['ship_pincode']; ?></div>
</div>
<div class="span6">
<span style="font-weight: bold">Choose Payment Mode</span>
<form action="<?php echo $paypal_url; ?>" method="post" name="frmPayPal1">
<input type="hidden" name="business" value="<?php echo $paypal_id; ?>">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_name" value="Kevalam Payment">
<input type="hidden" name="item_number" value="<?php echo count($this->cart->contents()); ?>">
<input type="hidden" name="credits" value="510">
<input type="hidden" name="userid" value="1">
<input type="hidden" name="amount" value="<?php echo $_SESSION['grand_total']; ?>">
<input type="hidden" name="cpp_header_image" value="http://k1-pc/myriad/assets/user_temp/image/logo.png">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="handling" value="0">
<input type="hidden" name="cancel_return" value="http://k1-pc/myriad/cancel.php">
<input type="hidden" name="return" value="http://k1-pc/myriad/success.php">
<input type="image" src="https://paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" name="submit">
</form>
</div>
</div><div class="clear"></div>
When using Payments Standard like this the Guest Checkout (direct credit card) option is displayed differently based on the cookies set for the current browser.
If you've ever signed in to any PayPal with the same browser it will find a cookie and assume that you'll be signing in again, so it will show you a landing page that really pushes the login aspect of PayPal checkout.
If you clear your browser cache/cookies (or just try a fresh browser) you should see a different landing page where the Guest Checkout option is more prominently displayed.
If you switch to the Express Checkout API instead of using Payments Standard you can force Guest Checkout to be displayed more prominently regardless of browser cookies. The SetExpressCheckout request includes parameters you can use to adjust the checkout pages accordingly.
Since you're using PHP, I'd recommend taking a look at my PHP class library for PayPal. It would make integrating Express Checkout very simple for you. Basically, it consists of the following API calls, which are included in the /templates directory with the library.
SetExpressCheckout
GetExpressCheckoutDetails
DoExpressCheckoutPayment
The parameters you'll use to handle the Guest Checkout options are in the SetExpressCheckout request and consist of...
SOLUTIONTYPE=Sole
LANDINGPAGE=Billing
USERSELECTEDFUNDINGSOURCE=CreditCard
Related
I'm developing an ecommerce website (as a project) and I want to integrate payment gateway in same. In this project when a user clicks on a product at index page, he's redirected to product_detail.php where there is a buy now button which directs him to payment gateway, but I always get the error "BAD_INPUT_ERROR: Things don't appear to be working at the moment. Please try again later."
Here's a part of my code
<form action="<?php echo $paypalURL; ?>" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="<?php echo $paypalID; ?>">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="<?php echo $row['name']; ?>">
<input type="hidden" name="item_number" value="<?php echo $row['id']; ?>">
<input type="hidden" name="amount" value="<?php echo $row['price']; ?>">
<input type="hidden" name="currency_code" value="INR">
<INPUT TYPE="hidden" name="charset" value="utf-8">
<!-- Specify URLs -->
<input type='hidden' name='cancel_return' value='http://localhost/search/cancel.php'>
<input type='hidden' name='return' value='http://localhost/search/success.php'>
<!-- Display the payment button. -->
<input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online">
</form>
Am I missing something? (I'm a beginner in php and I learned this from a website), also I wasn't able to turn on Auto return in my paypal sandbox account because they weren't able to validate my return URL. Do I need to host my project first so that it accepts my return URL?
I'm creating a site with a payment system, I'll explain you the problem with the code :
Order.php
<div class="bg-login" style="background-color: #fef8f8;">
<div id="login">
<div class="order-header">
Détails de la commande
</div>
<div class="order-content">
<h3>Prix:</h3>
<p><?php echo $price; ?> €</p>
<h3>Commande:</h3>
<p><?php echo $paypal['item_name']; ?></p>
<h3>Serveur:</h3>
<p><?php echo strtoupper($server); ?></p>
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" id="paypal-form" method="POST">
<input type="hidden" id="cmd" name="cmd" value="<?php echo $paypal['cmd']; ?>">
<input type="hidden" id="return" name="return" value="<?php echo $paypal['return']; ?>">
<input type="hidden" id="currency_code" name="currency_code" value="<?php echo $paypal['currency_code']; ?>">
<input type="hidden" id="business" name="business" value="<?php echo $paypal['business']; ?>">
<input type="hidden" id="amount" name="amount" value="<?php echo $paypal['amount']; ?>">
<input type="hidden" id="item_name" name="item_name" value="<?php echo $paypal['item_name']; ?>">
<button type="button" onclick="payment()" class="order-submit">Payer <?php echo $price; ?> €</button>
</form>
</div>
</div>
</div>
This is my page which get me the price of the order to Paypal. And with this :
<input type="hidden" id="return" name="return" value="<?php echo $paypal['return']; ?>">
I can, after the transaction, get the user on a page "Paypal.php" when the transaction is done.
On this page paypal.php i'll ask the user to create an account after his order (will add order infos in the database when he has created his account).
The problem is, I had as idea to make every order infos in sessions variables to get them in paypal.php, but everyone can go on paypal.php even if they didn't payed, so they just have to go on order.php then go to paypal.php to get a free order.
I'd like to know how is possible to get the status of the order with paypal on paypal.php, I looks a bit on paypal doc, there's a IPN thing to know the status of the transaction, but I don't know how to use it :( If someone could help me to know if the user has well payed on paypal.php, would be really awesome And If you've any smart idea instead of take the order infos in sessions, tell me, I've no idea for it.
Thanks !!
I choose "on" for auto return from my selling tools:
https://www.paypal.com/webapps/customerprofile/
But auto return is not working! why?
and this my form:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="example#mail.com">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_name" value="<?php echo $name; ?>">
<input type="hidden" name="item_number" value="<?php echo $id; ?>">
<input type="hidden" name="amount" value="0.01">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="return" value="http://example.com/done.php">
<input type="hidden" name="cancel_return" value="http://example.com/cancel.php">
<input type="submit" name="submit" value="Buy">
</form>
now my return page not has parameters like this:
http://example.com/done.php?tx=XXXX&st=Completed&amt=200.00&cc=USD&cm=&item_number=7
I need auto return and paramteres!
Help me.
Most Likely, you did not enable Payment Data Transfer(PDT).
You enabled PDT, but if transaction is made via Credit card, you will need to manually click on "return to merchant site" link to get redirected
to your return URL which means auto-return only works if payment is made via paypal account.
Steps to enable PDT
-Login to your PayPal account
-click on Profile
-click 'My selling preferences
-click on Update next to Website preferences
-Go to the Payment Data Transfer Section
-Choose Payment Data Transfer ON and the Token will be displayed below
PDT Sample codes
I'm trying to set up a button that offers buyers the option of inserting multiples
of an item and forces them to enter a shipping address here's the code:
<form action="<?php echo($paypal_url); ?>" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="<?php echo($paypal_email_address); ?>">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="<?php echo($item_name3); ?>">
<input type="hidden" name="amount" value="<?php echo($item_price3); ?>">
<input type="hidden" name="currency_code" value="<?php echo($item_currency3); ?>">
<input type="hidden" name="custom" value="<?php echo($mask); ?>">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="return" value="<?php echo($paypal_return); ?>">
<input type="hidden" name="notify_url"value="http://www.mywebsite.co.uk/ipn2.php">
<input type="hidden" name="cancel_return" value="<?php echo($cancel_return); ?>">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="2">
<!-- Display the payment button. -->
<input type="image" src="/img/PocketMask.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online." />
I'm in the process of testing it in the sandbox and the quantity option works fine but there doesn't appear to be an option for shipping address, if anyone could help me with this I'd really appreciate it.
The no_shipping variable determines whether or not you receive the shipping address with the transaction details after a payment completes. There isn't a shipping address field that would appear on the checkout page. The buyer would need to log into their account to select the shipping address to use to complete the payment.
Basically I just want to turn off the button after people purchase the art and send them a receipt. I would also like to have a copy of their information. This is what I am passing through my array:
<form method="post" action="https://www.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="email#mydomain.com" />
<input type="hidden" name="item_name" value="<?php echo $title; ?> (ID:#<?php echo " {$p['id']}" ?>)" />
<input type="hidden" name="item_number" value="<?php echo "{$p['id']}" ?>" />
<input type="hidden" name="amount" value="<?php echo "{$p['price']}" ?>" />
<input type="hidden" name="shipping" value="39.99" />
<input type="hidden" name="return" value="http://mydomain.com/thankyou.php" />
<input type="submit" value=" " class="button" />
</form>
How do I setup a sold field in my database and show/hide my button in php?
IPN, API which do I need to use to make it happen?
Cheers!
I would setup the IPN listener to mark the item's status as sold in it's database table (you are generating that form based on a database?) when the IPN comes back "VERFIFIED" and payment_status = 'Complete'. Then, only generate that form when the item is not sold.
If you don't know how to implement an IPN listener, here is a tutorial: PayPal IPN with PHP