【问题标题】:How to integrate PayPal into PHP with MySQL ecommerce website如何通过 MySQL 电子商务网站将 PayPal 集成到 PHP 中
【发布时间】:2021-12-29 03:50:23
【问题描述】:

我是这方面的初学者,我正在开发一个电子商务网站。我的问题是,当我使用 Paypal 结账时,我试图将购物车总数提取到 Paypal,但是,它仍然显示默认的 0.01 新西兰元,而不是我的购物车金额。我正在关注的教程是 https://github.com/EvolutedNewMedia/paypal-example/blob/master/payment-successful.html[1] 。 几个小时前我问了一个问题:PayPal integration to PHP eCommerce site not working。正如@Preston PHX 要求我遵循一些步骤。我现在为此苦苦挣扎了 2 周,这是我最后一年的项目。我不擅长编码,所以如果我能得到一些帮助,将不胜感激。

【问题讨论】:

  • 这个问题太笼统了。我们很高兴帮助您解决您的代码可能遇到的具体和具体问题,但是您需要发布相关代码(在问题本身中),解释失败的位置/方式,示例数据,预期结果和目前发生的事情。仅仅在 github 上发布一些代码的链接并不能告诉我们太多关于您的实现的信息。但是,如果问题更多的是“我如何使用此第三方服务”,则该问题应该针对他们的支持(因为我们不是)。
  • 嗨,谢谢@M 的回复。 Eriksson,我指的是很多教程,GitHub 上的链接是我迄今为止找到的最好的链接。然而,我是一个绝对的初学者,这是我最后一年的项目,因为要求是选择一种我们从未在大学教过的语言,所以我选择了 PHP,给了我 4 个月的时间来完成我的项目,所以我做到了没有足够的时间学习 PHP。我只剩下10天了。抱歉,如果我的问题描述性不够,正如您所见,我也是 StackOverflow 的新手。

标签: php paypal paypal-sandbox


【解决方案1】:

由于您只剩下 10 天,您可能希望使用一些基本的(但有效)

请使用以下表格:

(1) 将“business”的值替换为您的 paypal 电子邮件帐户

(2) 将 $itemAmount 的值替换为您的购物车总数

(3) 如有必要,将 $custom 替换为自定义变量(字符串或数字),以便您以后可以使用它(如果您不需要这个,请忽略此 $custom 值

(4)success.php和cancelled.php分别是用户完成交易和取消交易的两个页面。


<form id=form1 action="https://www.paypal.com/cgi-bin/webscr" method="post">

  <!-- Identify your business so that you can collect the payments. -->
  <input type="hidden" name="business" value="xxxxxx@xxxxxx.com">

  <!-- 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="Purchase Item">
  <input type="hidden" name="amount" value="<?php echo $itemAmount; ?>">
  <input type="hidden" name="currency_code" value="NZD">
  <input type="hidden" name="custom" value="<?php echo $custom; ?>">

 <input type="hidden" name="return" value="success.php">
 <input type="hidden" name="cancel_return" value="cancelled.php">



</form>

<script>
document.getElementById('form1').submit();
</script>

如果你有时间,你可以改用其他更复杂的 paypal API。

【讨论】:

    猜你喜欢
    • 2021-12-28
    • 2013-02-22
    • 1970-01-01
    • 2015-12-04
    • 2019-03-16
    • 1970-01-01
    • 1970-01-01
    • 2011-10-07
    • 2014-07-18
    相关资源
    最近更新 更多