沃梦达 / 编程问答 / php问题 / 正文

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

using paypal button - can my webpage tell if paypal transaction was successful or not?(使用 paypal 按钮 - 我的网页可以判断 paypal 交易是否成功吗?)

本文介绍了使用 paypal 按钮 - 我的网页可以判断 paypal 交易是否成功吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

所以我的问题是:

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

我正在使用 html + php :)

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

<input type="hidden" name="cmd" value="_xclick"><input type="hidden" name="business" value="smyacc@hotmail.com"><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 – 更安全, 更简单的在线支付方式."><img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"></表单>

非常感谢您对此的任何帮助!!!

卢克

解决方案

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

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

<块引用>

一旦用户点击立即购买"按钮,是否可以将他们重定向回他们刚刚填写的添加列表表单?

是的,这是 PayPal 已内置到其按钮和流程中的一项非常标准的功能.您在这里寻找的是 PayPal 所说的返回 URL"或自动返回".这是我引用的更多文档的页面 以便您可以决定是返回 URL 还是自动返回或付款数据传输选项最适合您.

<块引用>

买家在结帐后返回您的网站

基本的结账体验让买家留在 PayPal 网站上他们退房后.使用以下技术之一来增强结帐体验,以便买家返回您的网站,相反.

返回 URL:允许买家返回到您网站上的页面,如果他们点击 PayPal 付款确认页面上的返回链接或按钮.

要了解更多信息,请参阅第 3 步下的第 5 项:将高级功能添加到用于显示 PayPal 结帐的立即购买"按钮或 HTML 变量页.

自动返回:让 PayPal 自动将客户返回到您的网站.

重要提示:PayPal 建议您开启支付数据传输当您打开自动返回时.启用自动退货后,PayPal 会重定向买家通过替代 PayPal 付款确认访问您的网站页面,不允许他们打印 PayPal 收据.支付数据Transfer 提供您需要允许的交易信息买家从您的网站打印收据.

要了解更多信息,请参阅自动返回.

付款数据传输:PayPal 包含有关已完成的信息当您使用返回 URL 或自动返回发送客户时的交易回到你的网站.使用支付数据传输的信息提供显示谢谢,打印收据"页面网站.要了解更多信息,请参阅付款数据传输.

<小时><块引用>

问题我可以在确认付款之前禁用表单上的提交按钮吗?

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

  1. 向提交按钮添加禁用"属性.这将变灰并禁用提交按钮,使其无法使用.然而,由于按钮仍然可见,所以精通网络的最终用户可能只需进入 HTML 并删除 disabled 属性,就可以愉快地工作了.

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

<button type="submit" style="display:none">提交列表</button>

<小时><块引用>

问题 PayPal 的立即购买"按钮是否会返回任何确认流程成功的信息?

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

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

<块引用>

取消结帐后将买家带到特定网页(URL)(可选)?

选中复选框并在文本框中输入 URL(如果您有您网站上您希望买家返回的特殊页面,如果他们在完成交易之前取消了结账.

成功结帐后将买家带到特定网页(URL)(可选)?

选中复选框并在文本框中输入 URL(如果您有您网站上的特殊页面,您希望买家在此之后返回他们成功完成结帐.

方法 2 使用贝宝的即时付款通知 功能.借助此功能,PayPal 会向私有(幕后)URL 发送 POST 请求,该 URL 允许您捕获它发送给您的与付款完成相关的数据.

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

对于 有关 PayPal notify_url 的详细信息和文档 通过他们的 IPN 系统.

祝你好运!

I am using joomla and have brought a component which allows users to post listings on my site. The plugin uses a credit system to pay for the listing but the credit system is quite complex and confusing so i have disabled it.

I found that PayPal provides some code which inserts a Buy Now button on any webpage :) perfect, just what i wanted!

The only problem I am having is at the moment the button is displayed on my Add Listing form (which is again part of the component) but it can easily be bypassed by just clicking on the form's submit button, meaning the listing can be published without having to pay.

So my questions are:

  1. Once the user clicks on the Buy It Now button is it possible to redirect them back to the 'Add Listing' form they were just filling out?
  2. Can I disable the submit button on the form until the payment has been confirmed?
  3. Does the PayPal 'Buy Now' button return any information confirming the process was successful?

i am using html + php :)

the code i used to produce the buy now button is

<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="smyacc@hotmail.com">
    <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>

would really appreciate any help with this!!!

Luke

解决方案

Good news - the answer to your questions is essentially yes. Your end goal is definitely doable, but in order to really solve your problem in its entirety, we may need a little bit more information.

How you go about it can vary from case to case, however, and unfortunately it's been a while since I configured these buttons, so bear with me ;-)

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?

Yes, this is a very standard functionality that PayPal has built into their buttons and their process. What you are looking for here is what PayPal calls "Return URLs" or "Auto Return". Here's the page with more of the documentation I quoted below so you can decide whether the Return URL or the Auto Return or the Payment Data Transfer option is best suited for you.

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?

Certainly. To disable the submit button on the form until the payment has been confirmed, simply do one of two things until you can detect that the payment has been confirmed:

  1. Add the 'disabled' attribute to the Submit button. This will grey out and disable the Submit button, rendering it unusable. However, since the button would still be visible and all, a web-savvy end user might just go into the HTML and remove the disabled attribute and be on his merry way.

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

  1. Hide the Submit button. In this case, the web-savvy end user could technically still go into the HTML and remove the styling so that the button is visible, but without seeing it...well, you know, 'out of sight, out of mind'

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


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

Again, there's a few ways of attacking this.

Method 1 The simplest way might be to use the PayPal Return URLs and some GET parameters to tell you whether or not things were completed or cancelled. There is something like a Return URL for Cancellations and a Return URL for Completions. From that same page that I linked, PayPal documents the creation of a button with respect to this feature:

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.

Method 2 The more advanced way (which is also more foolproof, given that in the first Method a hacker could try and guess your Successful Return URL) is using PayPal's Instant Payment Notification feature. With this feature, PayPal sends a POST request to a private (behind the scenes) URL which allows you to capture the data it sends you pertaining to the payment completion.

So your backend receives the information on the completion of the payment, and there are countless ways (AJAX requests, require the user refresh the browser or send the user an email telling them to come back and finish it, etc) that you can go about updating the frontend for the user so that they can use the now visible/enabled Submit button.

For details and documentation on PayPal's notify_url through their IPN system.

Best of luck!

这篇关于使用 paypal 按钮 - 我的网页可以判断 paypal 交易是否成功吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:使用 paypal 按钮 - 我的网页可以判断 paypal 交易是否成功吗?

基础教程推荐