简体   繁体   中英

Paypal integration into existing shopping cart

I have developed my own shopping cart and now I want to integrate Paypal to allow the payment process to happen once the customer has clicked on the 'buy now' button.

How is it possible so that the item details are reciprocated in Paypal on the left hand side? I need to pass the item details over to Paypal based on what the customer has added to their cart.

After researching, I noticed that you can have buy now buttons on individual items and do it that way - but I have my own cart which allows for multiple items. So how can I pass these over to Paypal dynamically?

My attempt is below but when testing - the 'buy now' button does nothing when clicked on.

<?php
$checkout = "<form action='https://www.paypal.com/cgi-bin/webscr' method='post'>";
$checkout .= "<input type='hidden' name='cmd' value='_cart'><input type='hidden' name='upload' value='1'>";
$checkout .= "<input type='hidden' name='business' value='derrysnurseries@hotmail.co.uk'>";

$count = 1;
$checkout .= "<input type='hidden' name='item_name_" + $count + "' value='" + $product['common_name']+ "'>";
$checkout .= "<input type='hidden' name='item_number_" + $count + "' value='" + $count + "'>";
$checkout .= "<input type='hidden' name='quantity_" + $count + "' value='" + $item['quantity'] + "'>";
$checkout .= "<input type='hidden' name='amount_" + $count + "' value='" + $product['price'] + "'>";
$count = $count + 1;
?>

<input type='hidden' name='currency_code' value='GBP'>
<input type='hidden' name='lc' value='GB'>
<input type='hidden' name='return' value='http://www.derrysnurseries.co.uk/checkout?confirm=Confirm&confirmTerms=on'>
<input type='hidden' name='cancel_return' value='http://www.derrysnurseries.co.uk/checkout'>
<input type='hidden' name='notify_url' value='http://www.derrysnurseries.co.uk/checkout?confirm=Confirm&confirmTerms=on'>
<div class='securePayment'>Click <input class='securePaymentButton' type='submit' value='here'> to continue to secure payment site</div>
<?php $checkout .= "</form>"; ?>

You're not echoing the string that has the open form tag, or you're outputting it ($checkout) AFTER this code sample, so after the submit tag stuff. (the non php section is output right away; you can view source on your output to see what i mean).

As a result, your submit button is not part of the form and won't perform the action you specified.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM