What is the payza equivalent php code for this snippet? - php

Below is the code I use to process payment in my site. This cart has only one item. This code is for paypal. I want to sell same item on payza.
//process order for paypal
// Prepare GET data
$query = array();
$query['notify_url'] = 'http://mywebsite.com/ipn.php';
$query['cmd'] = '_cart';
$query['upload'] = '1';
$query['business'] = 'payment#mywebsite.com';
//main item
$query['item_name_1'] = $item_name;
$query['item_number_1'] = '1';
$query['amount_1'] = $item_price;
$query['currency_code'] = "USD";
// Prepare query string
$query_string = http_build_query($query);
header('Location: https://paypal.com/cgi-bin/webscr?' . $query_string);

<form method="post" action="https://secure.payza.com/checkout">
<input type="image" name="Checkout" src="btn_buynow.gif" />
<input type="hidden" name="ap_merchant" value="payza_email"/>
<input type="hidden" name="ap_purchasetype" value="item"/>
<input type="hidden" name="ap_itemname" value="SITENAME"/>
<input type="hidden" name="ap_itemcode" value="row->id"/>
<input type="hidden" name="ap_description" value="item1_desc"/>
<input type="hidden" name="ap_amount" value="amt"/>
<input type="hidden" name="ap_currency" value="CURRENCY_CODE"/>
<input type="hidden" name="ap_returnurl" value="returnurl"/>
<input type="hidden" name="ap_cancelurl" value="cancelurl"/>
</form>

Related

How to retrieve and confirm form inputs on another php file

I have The following form inputs I am trying to send these input data to "placebet.php" then retrieve the data and add a confirm or cancel button, then It can add to the database
<form action="placebet.php" method="post">
<div id="box" class="boxlit">
<div class="box" data-id="0">Myanmar - Vietnam<br>Home [1]<div class="crtTotal">4.30</div>
<input type="hidden" name="kickoff[]" value="7/17/2022 10:00">
<input type="hidden" name="match[]" value="Myanmar - Vietnam">
<input type="hidden" name="result[]" value="Home [1]" readonly="">
<input type="hidden" name="value[]" value="4.30"></div>
<div class="box" data-id="4">Thailand - Philippines<br>Draw [2]<div class="crtTotal">3.20</div>
<input type="hidden" name="kickoff[]" value="7/17/2022 13:30">
<input type="hidden" name="match[]" value="Thailand - Philippines">
<input type="hidden" name="result[]" value="Draw [2]" readonly="">
<input type="hidden" name="value[]" value="3.20"></div>
<div class="box" data-id="11">Botswana - Cameroon<br>Away [3]<div class="crtTotal">1.35</div>
<input type="hidden" name="kickoff[]" value="7/17/2022 22:00">
<input type="hidden" name="match[]" value="Botswana - Cameroon">
<input type="hidden" name="result[]" value="Away [3]" readonly="">
<input type="hidden" name="value[]" value="1.35"></div></div><br>
<input type="hidden" name="account[]" value="0818054386" readonly="">
<input type="hidden" name="balance[]" value="20" readonly="">
<input type="hidden" id="todds" name="todds[]" value="18.58" readonly="">
<input type="hidden" id="inp" name="payout[]" value="92.90" readonly="">
<div>Total Odds: <b id="ct1">18.58</b></div><br>
<div>(N$)Stake: <input id="stake" type="number" name="stake[]" value="5"> NAD</div><br>
<div>Payout: N$ <b id="payout">92.90</b></div>
<input class="bet1" type="submit" name="submit" value="Bet">
</form>
Php code in "placebet.php"
I'm not sure if the code below is correct but I need it to show the input data from the form and give me a option to confirm the data(button) and then it can finally add to the database
<?php
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
$link = mysqli_connect("localhost", "root", "", "forms");
$dba = mysqli_connect("localhost","root","","login");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$error = false; //set the error status value
$error_msg = "";
$back = mysqli_real_escape_string($link, $_REQUEST['kickoff'][0]);
$total = count($back); // get the length of the match
for($i=0;$i<$total;$i++){
// Escape user inputs for security
$kickoff = mysqli_real_escape_string($link, $_REQUEST['kickoff'][$i]);
$match = mysqli_real_escape_string($link, $_REQUEST['match'][$i]);
$selection = mysqli_real_escape_string($link, $_REQUEST['result'][$i]);
$odd = mysqli_real_escape_string($link, $_REQUEST['value'][$i]);
$account = mysqli_real_escape_string($link, $_REQUEST['account'][0]);
$stake = mysqli_real_escape_string($link, $_REQUEST['stake'][0]);
$payout = mysqli_real_escape_string($link, $_REQUEST['payout'][0]);
$todds = mysqli_real_escape_string($link, $_REQUEST['todds'][0]);
$accabal = mysqli_real_escape_string($link, $_REQUEST['balance'][0]);
//run sql query for every iteration
$charge = mysqli_query($dba, "UPDATE users SET balance = $accabal- $stake WHERE username='".$_SESSION['username']."'") ;
$_SESSION["balance"] = $accabal- $stake ;
$date = date ('Ymd');
$create = mysqli_query($link,"CREATE TABLE R$date LIKE receipts") ;
$insert = mysqli_query($link,"INSERT INTO `R$date`(`Match`, `Selection`, `Odd`,`Account`,`Stake Amount`,`Payout`,`Total Odds`) VALUES ('$match','$selection','$odd','$account','$stake','$payout','$todds')");
if(!$insert)
{
$error = true;
$error_msg = $error_msg.mysqli_error($link);
}
//check your error status variable and show your output msg accordingly.
if($error){
echo "Error :".$error_msg;
}else{
header("location: index.php");
exit;
}
}
mysqli_close($db);
?>
What you want to do isn't redirect to index.php, cause with this you start a new request and cant point on the request data of placebet.php anymore.
You want either to send your form via javascript ajax request and then react to the response of placebet.php (https://www.w3schools.com/js/js_ajax_intro.asp) or generating your own new output at placebet.php which then can be a confirm page or something similar.
e.g.
if($error){
echo "Error :".$error_msg;
}else{
echo "Data has been stored!";
}
You also could put your html at the end of the php file after closing the php part with ?> like mentioned here https://www.thoughtco.com/php-with-html-2693952#:~:text=As%20you%20can%20see%2C%20you,re%20inside%20the%20PHP%20tags).

How to call overrider controller from html form

Like in topic. How can I call the overrider controller from html form like this below:
<form method="post" action="index.php?controller=CmsController">
<input name="test" type="text" />
<input name="action" value="getStatus" type="hidden" />
<input value="test" type="submit" />
</form>
This code above I have in my tpl file.
File: /override/controllers/front/CmsController.php
---edit
{$link->getModuleLink('blockcms', 'CmsController')|escape:'html'}
doesn’t work.
---edit
public function initContent() {
parent::initContent();
if (Tools::getValue('action') && Tools::getValue('action') == 'getStatus') {
$id = $this->getIdByCode(Tools::getValue('voucher'));
$obj = new CartRuleCore($id);
$context = Context::getContext();
$response = $obj->checkValidity($context);
if ($response == NULL or $response == 'Koszyk jest pusty'){
$response = 'Kod ';
}
}
if (isset($this->cms)) {
$this->cms->content = str_replace("<!--response-->", $response, "{$this->cms->content}");
}
$this->setTemplate(_PS_THEME_DIR_ . 'cms.tpl');
This is part of initContent function in \override\controllers\front\CmsController.php And in my file tpl I have
<form method="post" action="index.php?controller=CmsController">
<input name="test" type="text" />
<input name="action" value="getStatus" type="hidden" />
<input value="test" type="submit" />

php Notice: Trying to get property of non-object in

I have to recognize that I'm new in php oop, but I want to learn. I searched for the same title here but I didn't see any topic close to mine to get an idea.
I have an function in a events calendar class, that display a form to add an event. Where I have the form I get an error on each line, about the event variable:
Notice: Undefined variable: event in C:\wamp\www
This is the function:
public function displayForm() {
/*
* Check if an ID was passed
*/
if(isset($_POST['event_id'])) {
$id = (int)$_POST['event_id'];
}
else {
$id = NULL;
}
/*
* Instantiate the headline/submit button text
*/
$submit = "Create a New Event";
/*
* If an ID is passed, loads the associated event
*/
$event = NULL;
if(!empty($id)) {
$event = $this->_loadEventById($id);
/*
* If no object is returned, return NULL
*/
if(!is_object($event)) {
return NULL;
}
$submit = "Edit This Event";
}
/*
* Build the markup
*/
return <<<FORM_MARKUP
<form action="assets/inc/process.inc.php" method="post">
<fieldset>
<legend>$submit</legend>
<label for="event_title">Event Title</label>
<input type="text" name="event_title" id="event_title" value="$event->title" />
<label for="event_start">Event Start</label>
<input type="text" name="event_start" id="event_start" value="$event->start" />
<label for="event_end">Event End</label>
<input type="text" name="event_end" id="event_end" value="$event->end" />
<label for="event_description">Event Description</label>
<textarea name="event_description" id="event_description" >$event->description</textarea>
<input type="hidden" name="event_id" value="$event->id" />
<input type="hidden" name="token" value="$_SESSION[token]" />
<input type="hidden" name="action" value="event_edit" />
<input type="hidden" name="event_submit" value="$submit" />
or cancel
</fieldset>
</form>
FORM_MARKUP;
}
If anyone has an idea feel free to tell me. Thank you.
You should make sure all the variables you use in your form markup are defined in all circumstances... So, $event should never be NULL... you should define default values in case no POST it's received or the id it's not found.
Also, $_SESSION should have the parameter with quotation marks and also should be checked before printing!
Here it's the code I propose you to use:
public function displayForm() {
// Initialize vars
$id = NULL;
$token = '';
/*
* Check if an ID was passed
*/
if(isset($_POST['event_id'])) {
$id = (int)$_POST['event_id'];
}
if (isset($_SESSION['token'])) {
$token = $_SESSION['token'];
}
/*
* Instantiate the headline/submit button text
*/
$submit = "Create a New Event";
/*
* If an ID is passed, loads the associated event
*/
if(!empty($id)) {
//$event = $this->_loadEventById($id);
$event = new stdClass();
$event->title = 'title';
$event->start = '1';
$event->end = '1';
$event->id = '1';
$event->description = 'description';
$submit = "Edit This Event";
}
if (empty($id) || !is_object($event)) {
$event = new stdClass();
$event->title = 'default title';
$event->start = 'default start';
$event->end = 'default end';
$event->id = 'default id';
$event->description = 'default description';
}
/*
* Build the markup
*/
return <<<FORM_MARKUP
<form action="assets/inc/process.inc.php" method="post">
<fieldset>
<legend>$submit</legend>
<label for="event_title">Event Title</label>
<input type="text" name="event_title" id="event_title" value="$event->title" />
<label for="event_start">Event Start</label>
<input type="text" name="event_start" id="event_start" value="$event->start" />
<label for="event_end">Event End</label>
<input type="text" name="event_end" id="event_end" value="$event->end" />
<label for="event_description">Event Description</label>
<textarea name="event_description" id="event_description" >$event->description</textarea>
<input type="hidden" name="event_id" value="$event->id" />
<input type="hidden" name="token" value="$token" />
<input type="hidden" name="action" value="event_edit" />
<input type="hidden" name="event_submit" value="$submit" />
or cancel
</fieldset>
</form>
FORM_MARKUP;
}
You set $event = NULL; and you probably pass an empty $id

how to integrate paypal with codeigniter?

I'm trying to integrate PayPal payment with my codeigniter project. My project is about a dating site, in which two different users interact with each other. So I'm selling plans, on the based of which users will be provided access to send messages to to other for the that period of time. For that i have developed a very simple page containing radio buttons to choose from different plans.
These are the following plans
one month ($2)
Two month ($4)
Three month ($6)
Four month ($8)
Five month ($10)
and so on
Six month ($12)
So, user can choose anyone plan from the above and can then proceed further to pay the amount on PayPal. This page will be available to user who have accounts on our site.
so we can transfer all the details of current user to PayPal, such as -- name,email,etc..
I have tried reading many articles on how to integrate paypal but none of them helped me.
As I'm new to codeigniter.
I have also created Paypal and sandbox account on paypal. I downloaded php-toolkit from sourceforge.net and used it independently, then it runs properly. but when i try to implement in codeigniter, it does not take anywhere.
Please help me !!
EDIT :
<?php
//Configuration File
include_once APPPATH.'../php_paypal/includes/config.inc.php';
//Global Configuration File
include_once APPPATH.'../php_paypal/includes/global_config.inc.php';
?>
<?php echo form_open('https://www.sandbox.paypal.com/cgi-bin/webscr');?>
<input type="hidden" name="amount" value="9.95">
<input type="hidden" name="item_name" value="Test Payment">
</form>
This is what i'm simply trying to create. Earlier i tried to use "process.php" in the form action, but i was getting URL error in codeigniter. So i thought why not use this way. I know there are function responsible which are sending values to paypal. But through this action method. I'm being redirected to simple paypal page.
Here are the steps you can follow.
Step1 Create IPN Form. make sure to pass IPN URL (notify URL) to paypal.
For Form variables, you can refer https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/
<form name="paypalFrm" id="paypalFrm" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_ext-enter">
<input type="hidden" name="redirect_cmd" value="_xclick-subscriptions">
<input type="hidden" name="return" value="<?php echo $return_url;?>">
<input type="hidden" name="cancel_return" value="<?php echo $cancel_return;?>">
<input type="hidden" name="notify_url" value="<?php echo $notify_url;?>">
<input type="hidden" name="custom" value="<?php echo $custom.",".$custom2;?>">
<input type="hidden" name="business" value="<?php echo $business_id;?>">
<input type="hidden" name="item_name" value="<?php echo $item_name;?>">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="a3" value="<?php echo $plan_amount;?>">
<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="sra" value="1">
<input type="hidden" name="srt" value="12">
<input type="hidden" name="first_name" value="<?php echo $txtname;?>">
<input type="hidden" name="lc" value="<?php echo $merchant_country;?>">
<input type="hidden" name="email" value="<?php echo $txtemail;?>">
</form>
Step 2 Create IPN controller. For detailed understanding review https://developer.paypal.com/docs/classic/ipn/gs_IPN/
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) { $_POST[$key] = mysql_real_escape_string($value); }
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$header = '';
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
// assign posted variables to local variables
$content['payment_status'] = $this->input->post('payment_status');
$content['payment_amount'] = $this->input->post('mc_gross');
$content['payment_currency'] = $this->input->post('mc_currency');
$content['txn_id'] = $this->input->post('txn_id');
$content['receiver_email'] = $this->input->post('receiver_email');
$content['payer_email'] = $this->input->post('payer_email');
$custom = explode(",",$this->input->post('custom'));
$content['payment_id'] = $custom[0];
$content['type'] = $custom[1];
$content['txn_type'] = $this->input->post('txn_type');
$content['paydate'] = date('Y-m-d H:i:s');
if (!$fp)
{
// HTTP ERROR
}
else
{
fputs ($fp, $header . $req);
if (!feof($fp))
{
$res = fgets ($fp, 1024);
if(strcasecmp($content['txn_type'], "subscr_payment") == 0)
{
//Action
}
else if(strcasecmp($content['payment_status'], "Completed") == 0)
{
//Action
}
else if(strcasecmp($content['txn_type'], "subscr_cancel") == 0)
{
//Action
}
}
fclose ($fp);
}
$orderide = $this->checkout_model->user_order($order_table);
$business='paypal#business.example.com';
$cancel_url="http://".$_SERVER['SERVER_NAME']."/checkout/cancel?orderide=".$orderide;
$success_url="http://".$_SERVER['SERVER_NAME']."/checkout/success?order_id=".$orderide;
$data['payment_url']="https://www.sandbox.paypal.com/cgi-bin/webscr?business=$business&cmd=_xclick&item_name=$title&item_number=$product_id&amount=$totalamount&currency_code=EUR&return=$success_url&cancel_return=$cancel_url";
redirect($data['payment_url']);
In return success URL you can able to get the user id and payment amount
Step 1: Download the CodeIgniter PayPal library from here: https://github.com/nrshoukhin/codeigniter-paypal-library.
Step 2: Drag and drop the entire "application" folder from the library to your codeigniter project. Make sure it's not conflict with your existing files.
Step 3: Load the library from your controller construtor:-
public function __construct(){
parent::__construct();
$this->load->library("paypal");
}
Step 4: Open the file from "application/config/paypal.php". And provide your client ID, client secret and currency.
Step 5: Create a controller method like below:-
public function subscribe(){
if ( !empty($_POST["plan_name"]) && !empty($_POST["plan_description"]) ) {
$this->paypal->set_api_context();
$this->paypal->set_plan( $_POST["plan_name"], $_POST["plan_description"], "INFINITE" );
$definition = "Regular Payments";
$type = "REGULAR";
$frequency = "MONTH";
$frequncy_interval = '1';
$cycles = 0;
$price = "49";
$this->paypal->set_billing_plan_definition( $definition, $type, $frequency, $frequncy_interval, $cycles, $price );
$returnurl = base_url()."payment/success";
$cancelurl = base_url()."payment/cancel";
$this->paypal->set_merchant_preferences( $returnurl, $cancelurl );
$line1 = "Street - 1, Sector - 1";
$city = "Dhaka";
$state = "Dhaka";
$postalcode = "12345";
$country = "AU";
$this->paypal->set_shipping_address( $line1, $city, $state, $postalcode, $country );
$agreement_name = "Payment Agreement Name";
$agreement_description = "Payment Agreement Description";
$this->paypal->create_and_activate_billing_plan( $agreement_name, $agreement_description );
}
}
Here, set the frequency as "MONTH" and set the frequency_interval according to your desired recurring period.

How can I get posted data passed along when the user is first redirected through Paypal?

I've been trying to tackle this for some time now. I have an order page where the customer must enter information like name, address, etc. and some more unique fields. I have set up IPN with Paypal and the customer is redirected to the page I specified. But the data does not come along with it. I hope I'm asking my question properly so that I don't get "closed." Here is the HTML in the Paypal submit button that redirects to their page.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="NT2YC6LP7SWBE">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<input type="hidden" name="child_name" id="child_name" value ="<? echo $child_name; ?>" maxlength="20"/>
<input type="hidden" name="age" id="age" value ="<? echo $age; ?>" maxlength="4"/>
<input type="hidden" name="hometown" id="hometown" value ="<? echo $hometown; ?>" maxlength="32"/>
<input type="hidden" name="boy_girl" id="boy_girl" value ="<? echo $boy_girl; ?>" maxlength="4"/>
<input type="hidden" name="first_name" id="first_name" value ="<? echo $first_name; ?>" maxlength="32"/>
<input type="hidden" name="last_name" id="last_name" value ="<? echo $last_name; ?>" maxlength="32"/>
<input type="hidden" name="email" id="email" value ="<? echo $email; ?>" maxlength="64"/>
<input type="hidden" name="address1" id="address1" value ="<? echo $address1; ?>" maxlength="64"/>
<input type="hidden" name="address2" id="address2" value ="<? echo $address2; ?>" maxlength="32"/>
<input type="hidden" name="city" id="city" value ="<? echo $city; ?>" maxlength="32"/>
<input type="hidden" name="state" id="state" value ="<? echo $state; ?>" maxlength="20"/>
<input type="hidden" name="zip" id="zip" value ="<? echo $zip; ?>" maxlength="10"/>
<input type="hidden" name="country" id="country" value ="<? echo $country; ?>" maxlength="32"/>
<input type="hidden" name="payment_type" id="payment_type" value ="paypal" maxlength="6"/>
<input type="hidden" name="paid" id="paid" value ="yes" maxlength="3"/>
<input type="hidden" name="mailed" id="mailed" value ="no" maxlength="3"/>
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
It has been pointed out to me that some of the variables are not "Paypal variables" and I can fix that later, but none of my data is making it back to my specified page after visiting Paypal, even the variables that Paypal supports like "city." Here is the PHP that I have on the page that they get redirected to.
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode ('=', $keyval);
if (count($keyval) == 2)
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
$ch = curl_init('https://www.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
if( !($res = curl_exec($ch)) ) {
// error_log("Got " . curl_error($ch) . " when processing IPN data");
curl_close($ch);
exit;
}
curl_close($ch);
if (strcmp ($res, "VERIFIED") == 0) {
$child_name = htmlentities($_POST['child_name']);
$age = $_POST['age'];
$hometown = $_POST['hometown'];
$boy_girl = $_POST['boy_girl'];
$email = $_POST['email'];
$first_name = htmlentities($_POST['first_name']);
$last_name = htmlentities($_POST['last_name']);
$address1 = htmlentities($_POST['address1']);
$address2 = htmlentities($_POST['address2']);
$city = htmlentities($_POST['city']);
$state = $_POST['state'];
$zip = htmlentities($_POST['zip']);
$country = htmlentities($_POST['country']);
$payment_type = $_POST['payment_type'];
$paid = $_POST['paid'];
$mailed = $_POST['mailed'];
} else if (strcmp ($res, "INVALID") == 0) {
}
$query = "INSERT INTO customer_list (
number, child_name, age, hometown, boy_girl, first_name, last_name, email,
address1, address2, city, state, zip, country, payment_type, paid, mailed)
VALUES ('',
'".mysql_real_escape_string($child_name)."',
'".mysql_real_escape_string($age)."',
'".mysql_real_escape_string($hometown)."',
'".mysql_real_escape_string($boy_girl)."',
'".mysql_real_escape_string($first_name)."',
'".mysql_real_escape_string($last_name)."',
'".mysql_real_escape_string($email)."',
'".mysql_real_escape_string($address1)."',
'".mysql_real_escape_string($address2)."',
'".mysql_real_escape_string($city)."',
'".mysql_real_escape_string($state)."',
'".mysql_real_escape_string($zip)."',
'".mysql_real_escape_string($country)."',
'".mysql_real_escape_string($payment_type)."',
'".mysql_real_escape_string($paid)."',
'".mysql_real_escape_string($mailed)."')";
if ($query_run = mysql_query($query)) {
$subject = "Thank You for Your Order";
$message = "Thank you for placing your order with My-Letter-From-Santa-Claus.com. \n\nYou can expect to receive your personalized letter soon. Please make note of your customer number. Your customer number is: ".mysql_insert_id().". \n\nPlease send all inquiries to : info#my-letter-from-santa-claus.com";
$from = "info#my-letter-from-santa-claus.com";
$headers = "From:" . $from;
mail($email, $subject, $message, $headers);
echo 'Thank you for your order.';
echo 'Letter For '.$child_name;
} else {
echo mysql_error();
}
I copied most of it directly from x.com except for changing to my own variables of course. Nothing is getting posted to the database but that's not the issue since I cannot even echo the data. A couple things are being entered into the database but it's not the data from my order page - it is the first name and last name that is entered as the credit card info on Paypal, and for payment_type it says "instan" (I maxed it at 6 characters) but as you can see from the hidden input field in the HTML, I wanted to post the value "paypal." How do I fix this?
are you using the Paypal Sandbox for testing? If not, I strongly recommend it: https://developer.paypal.com/, and the manual: https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_Sandbox_UserGuide.pdf.
I don't see the field name="business" in you code. That is the field which Paypal uses to identify you seller account. But maybe it only has to do with the "cmd" parameter (I use _xclick).
Here is a set of fields which works at this time for me, maybe it helps you:
<form name="_xclick" action="https://www.paypal.com/de/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="seller_email_here">
<input type="hidden" name="notify_url" value="ipn_url_here">
<input type="hidden" name="return" value="redirect_url">
<input type="hidden" name="cancel_return" value="redirect_if_cancelled_url">
<input type="hidden" name="amount" value="number_of_items">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="item_name" value="product_name">
<input type="hidden" name="item_number" value="product_number">
Your problem is that you're using a hosted button. You can't include custom stuff in the general HTML for those. The only custom fields that can be included have to be done in the PayPal button creation wizard.
You also need to make sure you're not confusing IPN and PDT. If you simply want data to come back to your return URL that the user is sent to after completing payment that would be PDT. It's not recommended that you handle post-order-processing with this, though, because there is no guarantee the user will make it there.
IPN can be used for that because it will be triggered no matter what, but again, that's totally separate from your checkout and PDT.
I would highly recommend using Express Checkout instead of standard buttons since you seem to be familiar with PHP, too. I've got a PHP class library for PayPal that makes this very simple for you, and I can provide 30 min of free training if you need it, which is generally more than enough to get people up-and-running as long as you understand PHP and how to work with array data.
You can do it with Standard, too, but you'd have to move away from using a hosted button #AndreiHardau is showing. That would allow you to include additional fields like address1, address2, address_overide, etc, and those fields would then be returned in IPN, PDT, and in GetTransactionDetails.

Categories