Paypal Express checkout NO PRICE - php

I've used paypal express checkout sandbox, but When I click to purchase something, doesn't show any price or item name in paypal.
On my page I've put this form :
<form action='expresscheckout.php' METHOD='POST'>
<input type='image' name='submit' src='https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif' border='0' align='top' alt='Check out with PayPal'/>
</form>
And I've included these two codes from paypal into my scripts:
https://www.paypal-labs.com/integrationwizard/ecpaypal/download.php?file=ecfile
https://www.paypal-labs.com/integrationwizard/ecpaypal/download.php?file=pplibfile
As I said, when I click on pay button , it takes me to the paypal sandbox, but with no price or item name. I even tried this with real API name and pass but still no price.
Meanwhile, I've also manually set the price in the expressscheckout.php :
$paymentAmount = $_SESSION["Payment_Amount"];
to
$paymentAmount = 32;

For Website Payments Standard :
I have put following two tags in my form tag :
<input type="hidden" name="item_name" value="<?php print $itemName; ?> "/>
<input type="hidden" id="amount" name="amount" value="<?php print $amount; ?>"/>

Related

Having trouble with integrating Sagepay payment gateway in PHP

I am implementing Sagepay payment gateway in PHP, it is working fine with 2.23 protocol. But when i change it to 3.00 it gives my an error code: 3195, which means that the line item amount details do not add up correctly.
I have tried all the solutions but nothing helped me.
Here is some of my code which I am using currently:
$sagePay = new SagePay();
$sagePay->setCurrency('GBP');
$sagePay->setAmount($_SESSION['amount']);
$sagePay->setDescription($_SESSION['tripcode']);
$sagePay->setBillingSurname('Mustermann');
$sagePay->setBillingFirstnames('Amrinder');
$sagePay->setBillingCity('London');
$sagePay->setBillingPostCode('GL51 3AA');
$sagePay->setBillingAddress1('Bahnhofstr. 1');
$sagePay->setBillingCountry('de');
$sagePay->setDeliverySameAsBilling();
<form method="POST" id="SagePayForm" action="https://live.sagepay.com/gateway/service/vspform-register.vsp" style="display:none;">
<input type="hidden" name="VPSProtocol" value= "2.23">
<input type="hidden" name="TxType" value= "PAYMENT">
<input type="hidden" name="Vendor" value= "alpinetravelint">
<input type="hidden" name="Crypt" value= "<?php echo $sagePay->getCrypt(); ?>">
<input type="submit" value="continue to SagePay">
</form>
How can I resolve this problem?
The error refers to the basket field. You have the first item value as 100, tax as 10 and the line total as 100.
The fields in the basket are Quantity:Item Value:Item Tax:Item Total:Line Total
The item value should be the net amount if you are going to use the tax field, so your values should be 1:90.00:10.00:100.00:100.00

Authorize.net Get Response from Server Integration Method

Suppose I have an Authorize.net form opened a pop-up of this form:
<?php
$api_login_id = 'YOUR_API_LOGIN_ID';
$transaction_key = 'YOUR_TRANSACTION_KEY';
$amount = "5.99";
$fp_timestamp = time();
$fp_sequence = "123" . time(); // Can be changed to an invoice or other unique number.
$fingerprint = AuthorizeNetSIM_Form::getFingerprint($api_login_id, $transaction_key,
$amount, $fp_sequence, $fp_timestamp);
?>
<form method='post' action="https://test.authorize.net/gateway/transact.dll">
<input type='hidden' name="x_login" value="<?php echo $api_login_id?>" />
<input type='hidden' name="x_fp_hash" value="<?php echo $fingerprint?>" />
<input type='hidden' name="x_amount" value="<?php echo $amount?>" />
<input type='hidden' name="x_fp_timestamp" value="<?php echo $fp_timestamp?>" />
<input type='hidden' name="x_fp_sequence" value="<?php echo $fp_sequence?>" />
<input type='hidden' name="x_version" value="3.1" />
<input type='hidden' name="x_show_form" value="payment_form" />
<input type='hidden' name="x_test_request" value="false" />
<input type='hidden' name="x_method" value="cc" />
<input type='submit' value="Click here for the secure payment form" />
</form>
After customer has completed the form, and the payment is complete, how do i get the response from the form so I could check if payment is complete? Something like:
if ($response->approved) {
echo "Success! Transaction ID:" . $response->transaction_id;
} else {
echo "ERROR:" . $response->error_message;
}
You need to either use Relay Response
Relay Response is a feature available to merchants using Server Integration Method (SIM) or Simple Checkout. It instructs the payment gateway to return transaction results to the merchant using an HTML form POST to a specified URL on the merchant's Web server. A script or program at the URL can be used to create a custom receipt page using the transaction information. The custom receipt page is then relayed back to the customer's browser. Relay Response does not redirect the end user back to the merchant’s server, but relays the page content to the end user instead of displaying the Authorize.Net default receipt page.
or Silent Post.
Silent Post is an Authorize.Net feature that POSTs transaction data to a URL whenever a transaction is processed by them. It happens behind the scenes and allows a system to automate the handling of approved and declined transactions
I am the author of the Silent Post article as well as instructions for how to implement it in PHP.

Generating paypal buttons for other users dynamically

I am planning on letting people list and sell their items on my site with payment/transaction processing done via paypal. To do this, i plan on letting my users dynamically generate a paypal button of their own when they are uploading their items(using my upload form).
I know that i can generate paypal buttons for my own account simply by logging into my paypal account. However, how would i go about doing this for other people ( if possible), whose accounts i will not have access to, and how would i make it secure?
Inputs would be appreciated!
P.S Im coding the site in php
If I understand the question correctly, you want to have your users customize a PayPal button to their own needs, right?
If so, what you should do is store the user's email address and the image button they want to use in a database (like MySQL) and then retrieve it and print the HTML.
Here's an example:
$query = mysql_query("SELECT * FROM `users`, `items` WHERE users.id = items.user_id") or die(mysql_error());
while($row = mysql_fetch_array($query)) {
?>
<form name="_xclick" action="https://www.paypal.com/us/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?php echo $row['email']; ?>">
<input type="hidden" name="currency_code" value="<?php echo $row['currency']; ?>">
<input type="hidden" name="item_name" value="<?php echo $row['item_name']; ?>">
<input type="hidden" name="amount" value="<?php echo $row['price']; ?>">
<input type="image" src="<?php echo $row['button_image']; ?>" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
<?php } ?>
Here is some very brief documentation from PayPal on it.

customizing paypal checkout, including php variable

I'm trying to add a "custom" value to the 3rd party checkout PayPal option. The problem I'm having is the PHP variable is being displayed on the screen. I'm passing the shopping cart values in a session variable.
if(isset($_SESSION['checkout'])){
$orderData = '<table border="1"><th style="width:80px">Item</th>
<th sytle="width:250px">Size</th>
<th style="width:60px">Quantity</th>';
for ($i=0; $i<count($_SESSION['checkout']); $i++){
$orderData .= '<tr><td style="text-align:center">'.$_SESSION['checkout'][$i][0].'</td><td style="text-align:center">'.$_SESSION['checkout'][$i][1].'</td><td style="text-align:center">'.$_SESSION['checkout'][$i][2].'</td></tr>';
}
}
I want that table to be passed along, and based on the PayPal documentation, all I need to do is include it. I'm echoing out the PayPal form like this:
echo '<form>
//other hidden values
<input type="hidden" name="custom" value="'.$orderData.'">
//input submit button here
</form>
And like I said, the input is supposed to be hidden, but it gets displayed before the PayPal button. How come?
UPDATE: Those code passes the amount perfectly:
<input type="hidden" name="amount" value="';?><?php if(isset($_SESSION['disc'])){print_r($_SESSION['disc']);}?><?php echo '">
It doesn't display on the page but the variable amount is correct in the page source.
UPDATE2: Here's my entire cart script:
echo '<div style="position:absolute; left:770px; top:50px">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="myemail#example.com">
<input type="hidden" name="item_name" value="Merchandise">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="custom" value="'.$orderData.'">
<input type="hidden" name="return" value="backtomywebsite.com">
<input type="hidden" name="cancel_return" value="backtomywebsite.com">
<input type="hidden" name="amount" value="';?><?php if(isset($_SESSION[$disc])){print_r($_SESSION[$disc]);}?><?php echo '">
<input type="image" src="http://www.mywebsite.com/images/BuyNow.png" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!" width="300" height="204">
</form>
</div>';
The script works when instead of $orderData I have a print_r session with the item information. That information gets sent to my paypal account but it is in an array form and looks ugly. If there was a way to make everything (member information, order information) into a php variable and pass it into the custom field, that would be great. Anyway...here's what is on the screen:
Hope you're still willing to help me out.
What do you mean it gets displayed before the PayPal button? If you are viewing the source code of the page, you will see the value in the page.
If you are saying you are passing amount over, but are not seeing it you may be using the wrong variable. The variable amount is a valid PayPal variable but depending what button you are specifically using the amount varialbe is slightly different. I could not tell from your code as I didn't see what you were passing over for "cmd", but if you are using a buy now button or an add to cart button that the variable "amount" would be the correct variable to use. If you are usnig the cart upload method, then you want to use the variable "amount_x". So if I passed two items over, and the first one was 0.99 and the second was 1.99 I would pass over the variable/value of "amount_1=0.99" and "amount_2=1.99".

Save data upon PayPal checkout in

I am using CodeIgniter. My application goes like this,
user selects a topic from a dropdown
user is able to type some text/questions inside a text area under that dropdown
user clicks the PayPal checkout button and pay for asking a question
How will I save the id of the selected topic and the typed question if my submit button is calling PayPal's processing stuff and not my own CodeIgniter controller action thing?
Here's the code of the submit/checkout button of PayPal,
<form action=https://sandbox.paypal.com/cgi-bin/webscr method=post>
<input type=hidden name=cmd value=_cart>
<input type=hidden name=business value="test#gmail.com">
<input type=hidden name=item_name value="test">
<input type=hidden name=item_number value="1">
<input type=hidden name=amount value="<?php foreach($query3->result() as $row){echo $row->price; } ?>">
<input type=hidden name=quantity value="1" disabled="disabled">
<input type=hidden name=currency_code value="USD">
<input type="hidden" name="return" value="http://your-website.com/after-payment-page.html" / >
<input type=image id="checkout" src="https://www.paypal.com/images/x-click-but6.gif" Border="0" name=submit><br>
<input type=hidden name=add value=1></form>
I split the pages into two parts instead
You can use notify_url
The URL to which PayPal posts
information about the transaction, in
the form of Instant Payment
Notification messages
Example:
<input name="notify_url" value="http://yourdomain.com/controller/method" type="hidden">
The example above receives some $_POST variables from PayPal when the payment is completed, even if the customer never returns to your website.
You can save the topic, question and any other information that gets passed in the above method.
You can attach another event to the submit button
For example:
$("#checkout").click(function() {
saveTheParmYouNeed();
});

Categories