php - 使用 paypal 按钮 - 我的网页可以判断 paypal 交易是否成功吗?

标签 php paypal joomla paypal-buttons

我正在使用 joomla,并带来了一个允许用户在我的网站上发布列表的组件。该插件使用信用系统来支付列表费用,但信用系统非常复杂且令人困惑,因此我已禁用它。

我发现 PayPal 提供了一些代码,可以在任何网页上插入“立即购买”按钮:) 完美,正是我想要的!

我遇到的唯一问题是,目前该按钮显示在我的“添加列表”表单(这也是该组件的一部分)上,但只需单击表单的提交按钮即可轻松绕过该按钮,这意味着该列表可以无需付费即可发布。

所以我的问题是:

  1. 一旦用户点击“立即购买”按钮,是否可以 将他们重定向回他们刚刚填写的“添加列表”表单 出去?
  2. 在付款完成之前,我可以禁用表单上的提交按钮吗? 确认的?
  3. PayPal“立即购买”按钮是否返回任何信息 确认该过程成功?

我正在使用 html + php :)

我用来生成“立即购买”按钮的代码是

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dfacb2a6bebcbc9fb7b0abb2beb6b3f1bcb0b2" rel="noreferrer noopener nofollow">[email protected]</a>">
    <input type="hidden" name="lc" value="GB">
    <input type="hidden" name="item_name" value="listing-purchase">
    <input type="hidden" name="amount" value="2.99">
    <input type="hidden" name="currency_code" value="GBP">
    <input type="hidden" name="button_subtype" value="services">
    <input type="hidden" name="no_note" value="0">
    <input type="hidden" name="shipping" value="0.00">
    <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
    <input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
    <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>

非常感谢任何帮助!

卢克

最佳答案

好消息 - 您的问题的答案基本上是。您的最终目标绝对是可行的,但为了真正彻底解决您的问题,我们可能需要更多信息。

然而,您的操作方式可能因情况而异,不幸的是,我已经有一段时间没有配置这些按钮了,所以请耐心等待;-)

once the user clicks on the buy it now button is it possible to redirect them back the the add listing form they were just filling out?

是的,这是 PayPal 已内置到其按钮和流程中的非常标准的功能。您在这里寻找的是 PayPal 所说的“返回 URL”或“自动返回”。这是the page with more of the documentation I quoted below因此您可以决定返回 URL、自动返回或付款数据传输选项是否最适合您。

Returning buyers to your website after they check out

The basic checkout experience leaves buyers on the PayPal website after they check out. Use one of the following techniques to enhance the checkout experience so that buyers return to your website, instead.

Return URL: Allow buyers return to a page on your website if they click a return link or button on the PayPal payment confirmation page.

To learn more, see item #5 under Step 3: Adding advanced features to your Buy Now button or HTML variables for displaying PayPal checkout pages.

Auto Return: Have PayPal return customers automatically to a page on your website.

Important: PayPal recommends that you turn Payment Data Transfer on when you turn Auto Return on. With Auto Return on, PayPal redirects buyers to your website from an alternative PayPal payment confirmation page, which does not allow them to print PayPal receipts. Payment Data Transfer provides the transaction information that you need to allow buyers to print receipts from your website.

To learn more, see Auto Return.

Payment Data Transfer: PayPal includes information about the completed transaction when you use a return URL or Auto Return to send customers back to your website. Use the information that Payment Data Transfer provides to display a "thank you, print your receipt" page on your website. To learn more, see the Payment Data Transfer.


Question Can I disable the submit button on the form until the payment has been confirmed?

当然。要在付款确认之前禁用表单上的提交按钮,只需执行以下两项操作之一,直到您可以检测到付款已确认:

  1. 将“已禁用”属性添加到“提交”按钮。这将使“提交”按钮变灰并禁用,使其无法使用。然而,由于该按钮仍然可见,因此精通 Web 的最终用户可能只需进入 HTML 并删除禁用的属性即可开始愉快的生活。

<button type="submit" disabled>Submit Listing</button>

  • 隐藏“提交”按钮。在这种情况下,精通网络的最终用户在技术上仍然可以进入 HTML 并删除样式,以便按钮可见,但看不到它......好吧,你知道,“眼不见心不烦”

    <button type="submit" style="display:none">Submit Listing</button>


    Question Does the PayPal 'Buy Now' button return any information confirming the process was successful?

    同样,有几种方法可以解决这个问题。

    方法 1 最简单的方法可能是使用 PayPal 返回 URL 和一些 GET 参数来告诉您事情是否已完成或取消。有一些类似于取消的返回 URL 和完成的返回 URL 之类的内容。在我链接的同一页面上,PayPal 记录了与此功能相关的按钮的创建:

    Take buyers to a specific webpage (URL) after checkout cancellation (optional)?

    Select the checkbox and enter a URL in the text box if you have a special page on your website where you want buyers to return to if they cancel their checkouts before completing their transactions.

    Take buyers to a specific webpage (URL) after successful checkout (optional)?

    Select the checkbox and enter a URL in the text box if you have a special page on your website where you want buyers to return to after they complete checkout successfully.

    方法 2 更高级的方法(也更加万无一失,因为在第一种方法中,黑客可能会尝试猜测您的成功返回 URL)是使用 PayPal 的即时付款通知 功能。通过此功能,PayPal 会向私有(private)(幕后)URL 发送 POST 请求,该 URL 允许您捕获它发送给您的与付款完成相关的数据。

    因此,您的后端会收到付款完成的信息,并且有无数种方式(AJAX 请求、要求用户刷新浏览器或向用户发送电子邮件告诉他们回来完成付款等)可以为用户更新前端,以便他们可以使用现在可见/启用的提交按钮。

    对于details and documentation on PayPal's notify_url通过他们的 IPN 系统。

    祝你好运!

  • 关于php - 使用 paypal 按钮 - 我的网页可以判断 paypal 交易是否成功吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33762967/

    相关文章:

    javascript - 将数据从 php 发送到 javascript

    php - 更新两个表中的数据。一个在一列中包含多个数据

    php - 根据登录用户的 ID 显示数据库表中的数据

    c# - 获取 Web 服务引用的实例

    php - jQuery - 单击链接/按钮时显示文本框

    paypal - Mass Pay操作中如何查看每笔付款?

    php - Paypal IPN - 通知网址

    css - 二级下拉菜单在其他页面上保持事件状态

    javascript - 如何从 AJAX 提交的表单中获取响应?

    php - 写入 joomla Assets 表的正确模式是什么?