0
我正在尋找一種方法來使用PHP和MySQL來跟蹤一些產品並將其出售到我的網站上。我在網上找到了以下代碼,並且希望對其進行編輯以使其可以用於定期付款(PayPal訂閱)而不是單次付款。我不確定要對經常性付款進行更改。我已經閱讀了PayPal開發者網站,但它沒有顯示我需要的代碼。誰能幫忙?Paypal從MySQL和PHP腳本定期付款
下面是對產品的SQL:
--
-- Table structure for table `products`
--
CREATE TABLE IF NOT EXISTS `products` (
`id` int(11) NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`price` float(10,2) NOT NULL,
`status` tinyint(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `products`
--
INSERT INTO `products` (`id`, `name`, `price`, `status`) VALUES
(1, 'LavaBasic', 1.99, 1),
(2, 'LavaStarter', 2.99, 1),
(3, 'LavaAdvanced', 4.99, 1),
(4, 'LavaFlow', 5.99, 1);
這裏是頁面上的PHP我在哪裏展示產品:
<body>
<?php
//fetch products from the database
$results = $db->query("SELECT * FROM products");
while($row = $results->fetch_assoc())
{
?>
<br/>Name: <?php echo $row['name']; ?>
<br/>Price: <?php echo $row['price']; ?>
<form action="<?php echo $paypal_url; ?>" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="Lavastack" value="<?php echo $paypal_id; ?>">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="<?php echo $row['name']; ?>">
<input type="hidden" name="item_number" value="<?php echo $row['id']; ?>">
<input type="hidden" name="amount" value="<?php echo $row['price']; ?>">
<input type="hidden" name="currency_code" value="USD">
<!-- Specify URLs -->
<input type='hidden' name='cancel_return' value='http://localhost/nitya/paypal_integration_php/cancel.php'>
<input type='hidden' name='return' value='http://localhost/nitya/paypal_integration_php/success.php'>
<!-- Display the payment button. -->
<input type="image" name="submit" border="0"
src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>
<?php } ?>
</body>
我試圖找到如何更改等等我在SQL上列出的價格將反覆出現,而不是一次性付款。任何建議將不勝感激!提前感謝大家。
您只需調整按鈕參數即可將按鈕轉換爲訂閱按鈕,而不是立即購買按鈕。查看[PayPal標準變量文檔](https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/)瞭解更多詳情。 –