如何使用沙箱测试 Paypal 订阅按钮?

发布于 2024-12-23 18:34:32 字数 1011 浏览 2 评论 0 原文

经过 5 个小时的研究和阅读过时的 paypal 文档后,我终于放弃了!

我需要使用贝宝沙箱测试一个简单的贝宝订阅按钮。

按钮代码:

<form action="https://www.sandbox.paypal.com/us/cgi-bin/webscr" method="post">
     <input type="hidden" name="cmd" value="_s-xclick">
     <input type="hidden" name="hosted_button_id" value="34CXHXVU2J8BY">
     <input type="image" 
            src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_subscribeCC_LG.gif" 
            border="0" name="submit" 
            alt="PayPal — The safer, easier way to pay online." 
            style="border:none;padding:0;height:auto;width:auto">
     <img alt="" border="0" 
          src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" 
          width="1" height="1">
</form>

但是当我尝试发送表单时,我在 paypal 网站上收到此错误:

https://i.sstatic.net/AVuTz.png

提前致谢, 菲利普

after 5 hours of research and reading outdated paypal documentation I finally give up!

I need to test a simple paypal subscription button with the paypal sandbox.

Button Code:

<form action="https://www.sandbox.paypal.com/us/cgi-bin/webscr" method="post">
     <input type="hidden" name="cmd" value="_s-xclick">
     <input type="hidden" name="hosted_button_id" value="34CXHXVU2J8BY">
     <input type="image" 
            src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_subscribeCC_LG.gif" 
            border="0" name="submit" 
            alt="PayPal — The safer, easier way to pay online." 
            style="border:none;padding:0;height:auto;width:auto">
     <img alt="" border="0" 
          src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" 
          width="1" height="1">
</form>

But when I try to send the form, I get this error on the paypal website:

https://i.sstatic.net/AVuTz.png

Thanks in Advance,
Phillip

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

宁愿没拥抱 2024-12-30 18:34:32

问题是您已在实时 PayPal 网站中生成了“托管”PayPal 按钮,但您正在将此数据发送到沙盒。
由于沙盒中无法识别 hosted_button_id,因此它会返回错误。

您需要:

  • 创建一个非托管按钮,并更改“操作”和“业务”参数以匹配 Sandbox 详细信息
  • 通过 www.sandbox.paypal 在 Sandbox 中创建一个新的“托管”按钮.com >简介> PayPal 按钮。

TL;DR:沙箱与 Live PayPal 网站 100% 分离。在 Live 中生成的托管按钮在 Sandbox 中不起作用。

The problem is that you've generated a 'hosted' PayPal button in the live PayPal website, but you're sending this data to the Sandbox.
Since the hosted_button_id isn't recognized in the Sandbox, it returns an error.

You'd need to either:

  • Create a non-hosted button, and change the 'action' and 'business' parameters to match Sandbox details
  • Create a new 'hosted' button in Sandbox via www.sandbox.paypal.com > Profile > PayPal Buttons.

TL;DR: Sandbox is 100% separated from the Live PayPal website. A hosted button generated in Live, doesn't work in Sandbox.

小瓶盖 2024-12-30 18:34:32

只需简单添加如何在沙箱中创建托管按钮:

  1. 创建并登录您的沙箱帐户
    https://developer.paypal.com/
  2. 选择“测试帐户”。
  3. 为卖家创建一个“预配置”测试帐户,确保您
    记住密码,并确保密码包含数字或
    您将无法使用它登录。
  4. 单击黄色按钮“进入沙箱测试站点”。
  5. 我的帐户>>简介>>销售偏好>>我保存的按钮
  6. 编辑您的按钮。 (那里有 3 个“已保存”的预制按钮。)
    当然你不要停留太久,它在没有告诉我的情况下就让我退出了
    当我第一次摆弄按钮时,我得到了一个空白的代码字段。

希望这可以节省您一些时间:)

Just a short add how to make the hosted button in the sandbox:

  1. Create and log in to your sandbox account on
    https://developer.paypal.com/
  2. Choose "Test Accounts".
  3. Create a "Preconfigured" test account for a seller, make sure you
    remember the password, and make sure the password contain numbers or
    you will not be able to log in with it.
  4. Click the yellow button "Enter Sandbox Test Site".
  5. My Account >> Profile >> Selling Preferences >> My Saved Buttons
  6. Edit your button. (There are 3 "saved" pre-made buttons there.) Make
    sure you dont dwell too long, it logged me out without telling me so
    and I got a blank code field first time I fiddled with my button.

Hopefully this saved you some time :)

岛徒 2024-12-30 18:34:32

也许这会有所帮助: https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ButtonMgrAPIIntro

并非每个国家/地区的所有商家都可以使用所有可创建的按钮。例如,德国商家无法使用订阅按钮,即使可以通过 API 创建订阅按钮

Perhaps this will help: https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ButtonMgrAPIIntro

Not all merchants in every country can use all the buttons that can be created. For example, German merchants cannot use Subscribe buttons even though they can be created through the API

°如果伤别离去 2024-12-30 18:34:32

是的,确实如此,PayPal 确实这么认为 在单独的沙箱系统中创建另一个按钮相当于“测试”。嗯,不,贝宝测试的目的是测试实际的东西,而不是你在另一个系统中从头开始制作的东西的副本。如果某些事情以不同的方式完成(错误地完成,这是测试的重点)或者在其他系统中进行设置时出现错误怎么办?这不是测试。这是在做一个试验。

所以在回答这个问题时,你不能用沙箱测试PayPal按钮,你只能进行试验。实际测试 PayPal 按钮的唯一方法是在测试时将价格降低到较小的水平,例如一美分,或者只是付款然后退款。

Yes, it's true, PayPal actually thinks creating another button in a separate sandbox system is equivalent to "testing". Erm, no, the point of testing, PayPal, is to test the actual thing, not a copy of the thing you make from scratch in another system. What if something is done differently (by mistake, which is the point of testing) or goes wrong when setting it up in the other system? This is not testing. This is doing a trial.

So in answer to the question, you can't test a PayPal button with sandbox, you can only do trials. The only way to actually test a PayPal button, is to reduce the price to something small while testing, like a cent, or just pay for it and then refund.

饮湿 2024-12-30 18:34:32

是的,您还可以通过以下步骤在沙盒上进行测试:

  1. 创建一个新的沙盒企业帐户。
  2. 登录企业帐户。
  3. 进入个人资料>我的设置工具。
  4. 单击 Paypal 按钮 >更新。
  5. 单击“创建新按钮”。
  6. 填写您所需的所有以下详细信息。
  7. 最后,您可以通过“hosted_id”获取表单代码。
  8. 您可以将代码粘贴到您的网站中并进行测试。

希望这些步骤对您有用。

Yes, you can test also on sandbox with following steps:

  1. Create a new sandbox business account.
  2. Login to the business account.
  3. Go with profile > My setting tools.
  4. Click on Paypal buttons > Update.
  5. Click on "Create new button".
  6. Fill up all following details you required.
  7. At last, you can get the form code with "hosted_id".
  8. You can paste the code in your website and you can test it.

Hope, These steps are useful to you.

静若繁花 2024-12-30 18:34:32

现在是:

  1. 创建一个新的沙盒企业帐户。
  2. 使用 https://www.sandbox.paypal.com/ 登录沙盒企业帐户。
  3. 点击“付款和收款”,然后点击“PayPal 按钮”。
  4. 对于不使用 API 调用的简单 PayPal 按钮,选择“立即购买”。

该按钮现在可能已被弃用,因为开发人员网站似乎不再有它。

This is now:

  1. Create a new sandbox business account.
  2. Login to the sandbox business account using https://www.sandbox.paypal.com/.
  3. Click on "pay and get paid" then "PayPal buttons".
  4. Choose "Buy Now" for the simple PayPal button which does not use an API call.

It is possible this button is now deprecated because the developer site does not seem to have it anymore.

三人与歌 2024-12-30 18:34:32
  1. 导航至 https://developer.paypal.com/dashboard/applications/sandbox REST API 应用程序 单击所需的APP
  2. 复制您的沙盒帐户 & 客户端 ID
  3. 导航至 https://developer.paypal.com/dashboard/accounts
  4. 找到相同的沙盒帐户并点击管理(3点),然后查看/编辑帐户
  5. 复制您的系统生成的密码更改密码
  6. 导航至https://www.sandbox。 paypal.com/
  7. 使用您的沙盒帐户登录 + 系统生成的密码
  8. 导航到https://www.sandbox.paypal.com/billing/plans 并创建与之前相同的计划
  9. 复制您的计划 ID,例如:P-2BPE0RQ33UO7KJ5A8GV0AE08
  10. 添加此脚本标记并将 $clientId 替换为 (3)
<script src='https://www.paypal.com/sdk/js?client-id=$clientId&vault=true&intent=subscription' data-sdk-integration-source='button-factory'></script>
  1. 使用以下 JS 渲染您的 PayPal 按钮 中的 Client ID代码:
/**/
var params = {
    /**/
    style: {
        /**/
        shape: "rect",
        /**/
        color: "blue",
        /**/
        layout: "vertical",
        /**/
        label: "subscribe"
        /**/
    },
    /**/
    createSubscription: function(data, actions){ return actions.subscription.create({ plan_id: "P-2BPE0RQ33UO7KJ5A8GV0AE08" }); },
    /**/
    onApprove: function(data, actions){
        /**/
        alert("Subscribed!");
        /**/
    }
};
/**/
paypal.Buttons(params).render("#paypal-button-container");
/**/
  1. 导航至https://developer.paypal.com/dashboard/accounts再次

  2. This是时候找到您的个人帐户,而不是企业帐户

  3. 复制电子邮件地址

  4. 点击管理(3 点),然后点击查看/编辑帐户

  5. 复制您的系统生成的密码更改密码

  6. 使用此个人帐户测试您的按钮

  7. 如果一切顺利,您将收到订阅警报

  1. Navigate to https://developer.paypal.com/dashboard/applications/sandbox
  2. From REST API apps click your desired APP
  3. Copy your Sandbox Account & Client ID
  4. Navigate to https://developer.paypal.com/dashboard/accounts
  5. Locate the same Sandbox Account and click Manage (3 Dots) then View/Edit Account
  6. Copy your System Generated Password or Change Password
  7. Navigate to https://www.sandbox.paypal.com/
  8. Login using your Sandbox Account + System Generated Password
  9. Navigate to https://www.sandbox.paypal.com/billing/plans and create the same plans as before
  10. Copy your plan ID, for example: P-2BPE0RQ33UO7KJ5A8GV0AE08
  11. Add this script tag and replace $clientId with your Client ID from (3)
<script src='https://www.paypal.com/sdk/js?client-id=$clientId&vault=true&intent=subscription' data-sdk-integration-source='button-factory'></script>
  1. Render your PayPal Button using the following JS code:
/**/
var params = {
    /**/
    style: {
        /**/
        shape: "rect",
        /**/
        color: "blue",
        /**/
        layout: "vertical",
        /**/
        label: "subscribe"
        /**/
    },
    /**/
    createSubscription: function(data, actions){ return actions.subscription.create({ plan_id: "P-2BPE0RQ33UO7KJ5A8GV0AE08" }); },
    /**/
    onApprove: function(data, actions){
        /**/
        alert("Subscribed!");
        /**/
    }
};
/**/
paypal.Buttons(params).render("#paypal-button-container");
/**/
  1. Navigate to https://developer.paypal.com/dashboard/accounts again

  2. This time locate your Personal Account, not the Business Account

  3. Copy the email address

  4. Click Manage (3 Dots) then View/Edit Account

  5. Copy your System Generated Password or Change Password

  6. Test your button using this Personal Account

  7. If everything goes well you will get a Subscribed alert

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文