Paypal showing error page while passing variables to sandbox environment

116
April 13, 2018, at 7:40 PM

I am trying to integrate paypal for one time donation save data to database and then mark paid/unpaid using Paypal IPN, I was working with below code yesterday, it was working fine and was redirecting me to sandbox page to pay and then come back.

below is my php form

<form method="post" action="<?php echo base_url(); ?>controller/function" name="DonationForm" id="DonationForm" class="mt-20">
 <input type="number" min="1" placeholder="Amount" id="amount" name="amount" class="form-control">
---- here i have some more variables to insert in database--
</form>

and below is my codeigniter function

$UniqueIdGenrated=md5(uniqid(mt_rand(), FALSE));
$UniqueId=$UniqueIdGenrated;
$paypal_email = 'my_sandbox_bussiness_email@gmail.com';
$return_url = 'https://my_domain.com/controller/payment-successful';
$cancel_url = 'https://my_domain.com/controller/payment-cancelled';
$notify_url = 'https://my_domain.com/paypal/listener.php';
$currency_code='USD';
$item_name='Donation for a cause';
$item_number=$UniqueId;
$amount=$_POST['amount'];
$cmd='_xclick';
//$lc='UK';
//$bn='PP-BuyNowBF:btn_buynow_LG.gif:NonHostedGuest';
$querystring = '';
$querystring .= "?business=".urlencode($paypal_email)."&";
$querystring .= "item_name=".urlencode($item_name)."&";
$querystring .= "amount=".urlencode($amount)."&";
$querystring .= "item_number=".urlencode($item_number)."&";
$querystring .= "currency_code=".urlencode($currency_code)."&";
$querystring .= "cmd=".urlencode($cmd)."&";
// Append paypal return addresses
$querystring .= "return=".urlencode(stripslashes($return_url))."&";
$querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&";
$querystring .= "notify_url=".urlencode($notify_url);
header('location:https://www.sandbox.paypal.com/cgi-bin/webscr'.$querystring);
exit();

However today when I started testing again, paypal says "Things don't appear to be working at the moment. Please try again later."

I tried keeping below as header, live paypal

header('location:https://www.paypal.com/cgi-bin/webscr'.$querystring);

then it has taken me properly on paypal payment page below is the screen shot

Can anyone please help me, am i missing something :(

Answer 1

Weird, now it's working fine with the same code and redirecting me to paypal sandbox as intended. below is the screen shot. I guess paypal sandbox server was down or something, or might be there was some temporary glitch... don't know. Thanks!!

Screen shot

READ ALSO
How to create REST api for php program [on hold]

How to create REST api for php program [on hold]

i'm creating the program for PHP validation i want to know that how to get JSON data using PHP script i'm working on PHP validation program and i want to make a REST API for this PHP code

103
Apache configuration limits for PHP FTP

Apache configuration limits for PHP FTP

I've got a PHP script, launched via an AJAX POST request, which does the following actions :

112
Combine two php scripts/functions

Combine two php scripts/functions

Good morning, everyone

132