How to switch PayPal sandbox account to live account in PHP - php

Hi guys hope you are all safe. i just want to know that how can i switch sandbox account to live account.
First i was using https://www.sandbox.paypal.com/cgi-bin/webscr in paypal form action but when i go to live i changed it into https://www.paypal.com/cgi-bin/webscr
i also changed the business attribute in form to Paypal live business account.
right now PayPal is accepting the payment which is coming from website but when it redirects to my website paypal_success(page after payment success) page i cant able to get return values from Paypal like transaction id, item value, item name etc.
Can you please help me. here is my code.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" class="float-right w_100">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="business#awakeningsme.com">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Awakenings Products">
<input type="hidden" name="item_number" value="<?php echo $pro_id ?>">
<input type="hidden" name="amount" value="<?php echo $total; ?>">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="return" value="http://mywebsite.com/paypal_success.php">
<input type="hidden" name="cancel_return" value="http://mywebsite.com/paypal_cancel.php">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
<input type="image" src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/buy-logo-large.png" alt="Buy now with PayPal" border="0" name="submit">
</form>

A more important issue is that PDT should never be used for anything important. It is for informational purposes only (e.g. to show a success page to the buyer)
If you depend on the information from PDT to trigger business logic like updating order records, you are going to have a bad time. After a successful Payments Standard payment, the customer may never return.
Their browser may crash, or they may be shown a receipt at PayPal and need to click a button to return, and so just close the window.
If you need reliable notifications of payment completion, your options are:
Implement a separate asynchronous service, such as Webhooks or IPN.
Switch to an API-based integration that is notified synchronously when the capture is successful, such as a server-side integration of v2/orders with Smart Payment Buttons (front-end code: https://developer.paypal.com/demo/checkout/#/pattern/server ). This way, the capture happens on your server, and you have an immediate API notification of success/failure

Related

paypal subscription error when doing the purchase on live site, but works on sandbox. "Action could not be completed"

I have 2 purchase button for paypal.
Regular checkout (this works perfectly well in sandbox AND live site)
A recurring payment.
The recurring button works perfectly well in the sandbox. I can make the transaction, no problem. Everything is good.
If I switch over the live site, my #1 (regular checkout button still works with a real money exchange), but my recurring button doesn't.
It Does bring me to the paypal subscription payment page. I use a paypal account with real live credits in it (NOT the same account as the seller's account). And when I press login, I see:
Sorry — your last action could not be completed
If you were making a
purchase or sending money, we recommend that you check both your
PayPal account and your email for a transaction confirmation after 30
minutes.
If you came to this page from another website, please return to that
site (don't use your browser's Back button) and restart your activity.
If you came from PayPal's website, click the PayPal logo in the
upper-left corner to return to our home page and restart your
activity. You might have to log in again.
I tried the following:
Change browser, FF and Chrome
Clear all cache, cookies
I am not using frames as other people have suggested
Nothing works.
here is my code to submit to paypal, in case someone sees a mistake:
<form name="_xclick" action="https://www.paypal.com/ca/cgi-bin/webscr" id="myform" method="post">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="MY EMAIL HERE">
<input type="hidden" name="item_name" value="MY NAME Subscription">
<input type="hidden" name="add" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="currency_code" id="currency" value="<?=$currency?>">
<input type="hidden" name="a3" id="hiddentotal2" value="<?=$total2?>">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<input type="hidden" name="src" value="1">
<input type="hidden" name="custom" id="custompaypal" value="<?=$custom?>">
<input type="hidden" name="notify_url" value="http://www.mysite..../notify_paypal.php">
<input type="hidden" name="return" value="http://www.mysite..../myorders.php">
<input class="submit-button2" type="submit" name="submit" value="PURCHASE SUB" />
</form>
What could be causing this and how can I fix this.

Paypal return with produt id array

I am using paypal payment gateway with my website for payment.
Here I want a feature like where I could send list of product id those I want to purchase.
And after successful payment I want to these all id so that I could update my datasbe.
I can not use IPN, because its already used for other site.
Below is my html form for paypal..
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="praveend06-facilitator#gmail.com">
<input type="hidden" name="item_name" value="PAYMENT REASON">
<input type="hidden" name="amount" value="10">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="MX">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="notify_url" value="http://localhost/paypal/notify.php">
<input type="hidden" name="return" value="http://localhost/paypal/success.php">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="cbt" value="Return to The Store">
<input type="hidden" name="cancel_return" value="http://localhost/paypal/fail.php">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
I wrote below code in success.php
but its returning blank array. Even i didn't get transaction id.
Please help me to achieve this. Thank you
There is only one parameter that you can use for custom data with Website Payments Standard and that's "custom".
Simply pass in you custom data in
<input type="hidden" name="custom" value="your custom data here">
In the custom data, first add the product IDs as a comma separated string and then you will get that back on successful payment.
You can retrieve the value for 'custom' by polling through PayPal PDT (https://www.paypal.com/pdt/) or getting the data POST'ed to you by PayPal, using PayPal IPN (https://www.paypal.com/ipn/).
But you already mentioned that you cannot use IPN. So go for PDT instead.
PDT is NOT the recommended way to update your database. Even with Auto-Return enabled there is no guarantee the user would make it back to your site. In these cases the return page would never be reached and that code would never run, leaving your database without the updates it needs.
You CAN use IPN with multiple PayPal accounts. You just need to use the notify_url parameter to specify the unique URL you want to use for IPN on that particular checkout.
On that note I see you're already including the notify_url parameter in your code here, but you're using localhost for it. That won't work because it will be PayPal's server sending data to that URL. As such, "localhost" is their own server at that point.
What you need to do for testing purposes is use your public IP address or setup a domain to resolve to your IP address so you can use that as your IPN URL instead of localhost.
So then, again, you can use as many different IPN URL's with a single account as you need to. Just set notify_url to whichever one you need to use based on the checkout that you're setting up.

How to transform PayPal Classic Payment form into PayPal REST API PHP Application?

The following is the simplest PayPal interface form:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" />
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="JohnDoe2#example.com" />
<input type="hidden" name="item_name" value="Purchase at the Virtual Store" />
<input type="hidden" name="item_number" value="Organic-001" />
<input type="hidden" name="amount" value="17.4" />
<input type="hidden" name="currency_code" value="EUR" />
<input type="hidden" name="notify_url" value="http://www.example.com/paypalnotify.php" />
<input type="submit" name="submit" value="Pay now By PayPal" />
</form>
This form is specific to a PayPal premier business account and a given amount to pay, with following key parameters:
business=JohnDoe2#example.com.
amount=17.4EUR.
currency_code=EUR or USD.
notify_url as the callback for PayPal.com as it ends.
By clicking on the [submit] button, it perfoms this:
It redirects the customer to the paypal.com site.
The user will login into her/his PayPal account, and validate the payment.
The PayPal site will call the paypalnotify.php like a callback, passes information indicating if the payment has suceeded, cancelled, or not valid...
Now in the new interface using PalPal REST API, using PHP development kit, how one has to proceed to accomplish the payment ?
There are a few options. Start by looking at the code in these files:
https://github.com/paypal/rest-api-sdk-php/blob/master/sample/payments/CreatePayment.php
https://github.com/paypal/rest-api-sdk-php/blob/master/sample/payments/CreatePaymentUsingPayPal.php
Obviously they don't have any interactive forms, but they show the general process. Dig in and work through creating your code. Then when you hit problems, open a new question with the specific issues. StackOverflow is not for "how do I" type questions. https://stackoverflow.com/help/on-topic

PayPal _cart Upload to Sandbox never allows login

So I have been doing a lot of Googling on PayPal's _cart Upload ability and so far, this is what I have managed to put together. And this seems to be working just fine; I am taken to a PayPal page with the purchase info and it asks me to login. But when I login with a Sandbox buyer account, it simply shows that it's logging me in but it never logs me in nor does it allow me to complete the purchase. The merchant sandbox account is working fine as it displays the Example store name on the PayPal page.
<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="xxx#xxx.xxx">
<input type="hidden" name="item_number_1" value="3">
<input type="hidden" name="item_name_1" value="Foo">
<input type="hidden" name="amount_1" value="22.97">
<input type="hidden" name="shipping_1" value="0">
<input type="hidden" name="shipping2_1" value="0">
<input type="hidden" name="quantity_1" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="22.97">
<input type="hidden" name="notify_url" value="http://******/order.php">
<input type="hidden" name="no_shipping" value="2">
<input class="paypal_button" type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but03.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
Am I doing something wrong when I'm logging in to PayPal or is the _cart upload ability deprecated after PayPal moved to a new a developer site and API? Any and all help would be appreciated it, I have been banging my head against the wall for hours trying to figure out what I'm doing wrong.
I don't think it'd make a difference but I am using PHP to generate the checkout information.
Thank you very much for your help.
I just submitted a payment using your code and my own sandbox account. It worked fine for me.
PayPal's servers can sometimes be pretty finicky with cookies in browsers. Close your browser (all instances of it so it's completely closed) and then reopen it and try again. Make sure you're signed in at developer.paypal.com before you try it and you should be just fine.

IPN not receiving from paypal sandbox

I had developed a website with online transaction using paypal as payment option.
Checkout and the shopping cart calculations on paypal side are working, but i'm not receiving any IPN messages from paypal sandbox.
<form name="paypal_form" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="invoice" value="1234" />
<input type="hidden" name="business" value="merchant#domain.com" />
<input type="hidden" name="return" value="http://domain.com/success" />
<input type="hidden" name="cancel_return" value="http://domain.com/cancel" />
<input type="hidden" name="notify_url" value="http://domain.com/notify">
<input type="hidden" name="item_name_1" value="First item"/>
<input type="hidden" name="amount_1" value="6.00"/>
<input type="hidden" name="quantity_1" value="1"/>
<input type="hidden" name="shipping_1" value="5.00"/>
<input type="hidden" name="currency_code" value="EUR"/>
</form>
The overview page in merchant paypal account shows the transactions are completed. When i click on transaction details it shows error 3004 .
Also the IPN history page does not displaying any IPN records. It says "no records found in last 24 hours" .
How can i solve this?
Thanks & Regards.
It can be PayPal error - see: https://www.x.com/developers/paypal/forums/instant-payment-notifications-ipn-payment-data-transfer-pdt/ipn-failing-hasn-t-been-changed?page=0%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C1
The most iportant messages from the link above are PayPal responses:
July 18:
"I have found that the problem you are experiencing with IPN in the Sandbox is being caused by some technical issues with the PayPal system. Our engineers are currently working diligently on a solution to this problem."
and July 19:
"We are aware of this issue and our engineers are currently working on a solution. Unfortunately, i can't give you an exact timeframe when this will be done, however this should be resolved within the next days."
Make sure that your ipn is actually world-accessible (and not under localhost or a private network)
If you are trying this on localhost, it wont work. IPN just works on live. And you are saying you are not getting message from paypal sandbox ? If you are working on sandbox, why are you keeping the action url for actual paypal form ?

Categories