简体   繁体   English

Paypal PHP SDK从沙箱生效

[英]Paypal PHP SDK going from sandbox to live

Hey guys I followed this tutorial 嘿伙计们我按照这个教程

http://www.sanwebe.com/2014/09/paypal-rest-api-payment-system http://www.sanwebe.com/2014/09/paypal-rest-api-payment-system

I have the paypal sandbox mode working perfect. 我有贝宝沙盒模式工作完美。 It's time to launch the site & I want to switch it to live. 现在是时候启动网站了,我想把它切换到现场。 I've been messing with it for hours and cannot figure out how to direct this to the live mode. 我已经搞乱了好几个小时,无法弄清楚如何将它指向实时模式。

Any help at all will be greatly appreciated. 任何帮助都将非常感谢。

If you are using PayPal-PHP-SDK, 如果您使用的是PayPal-PHP-SDK,

Step 1: You need to set the mode to live to point the SDK to live endpoints. 步骤1:您需要将mode设置为live以将SDK指向实时端点。 To do that, there are multiple ways: 要做到这一点,有多种方法:

  • sdk_config.ini sdk_config.ini
    • you need to set this there 你需要在那里设置它
    • 在此输入图像描述
  • dynamically using ApiContext 动态使用ApiContext
    • you could do that by setting it similar to this 你可以通过设置它类似于来做到这一点
    • 在此输入图像描述

Step 2: , Please update the clientId and secret for Live environment, as they are different based on sandbox or live. 第2步:请更新liveId的clientId和secret,因为它们根据沙箱或实时不同而不同。 Visit PayPal Developer and check on live select box as shown below: 访问PayPal Developer并查看实时选择框,如下所示:

在此输入图像描述

These two steps should get you going with the live API endpoint. 这两个步骤可以让您使用实时API端点。

Can't comment to H Patel, but there's another sdk_config.ini file in the PayPal PHP SDK files which includes an endpoint and mode. 无法对H Patel发表评论,但PayPal PHP SDK文件中还有另一个sdk_config.ini文件,其中包含端点和模式。

I've noticed I had to change the service.EndPoint in this other config file to https://api.paypal.com , change the mode in both config files to live , set the log.LogLevel to INFO , AND dynamically set the mode to live in my PHP script. 我注意到我必须将此其他配置文件中的service.EndPoint更改为https://api.paypal.com ,将两个配置文件中的mode更改为live ,将log.LogLevel设置为INFO ,并动态设置mode live在我的PHP脚本中。 I ALSO changed the acct1.ClientId and acct1.ClientSecret in both of these config ini files and it seems like maybe I've got it working now. 我还改变了这两个配置ini文件中的acct1.ClientIdacct1.ClientSecret ,似乎我现在已经有了它。

So it's not a matter of choosing how you want to do it, you have to do all of it and then some beyond what PayPal tells you to do. 所以这不是选择你想要的方式,你必须做所有这些,然后超出PayPal告诉你做的一些事情。

You can set manualy to go live without creating config.ini file 你可以设置manualy而不创建config.ini文件

Just set in the value you want 只需设置您想要的值

\PayPal\Core\PayPalConfigManager::getInstance()->addConfigs(['mode' => 'live' /*or "sandbox" */]) ;

then set your live Credential id/secret with the live information 然后使用实时信息设置您的实时凭据ID /机密

$credential = new \PayPal\Auth\OAuthTokenCredential($paypal_id, $paypal_secret);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM