- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
上周我一直在尝试制作一个加密的“使用 paypal 结帐”按钮。
最后我在这个网站“https://ppmts.custhelp.com/app/answers/detail/a_id/502”中找到了使用 php 进行加密的网络支付
我正在尝试根据我在本地主机中的站点在该示例中实现。但显示错误“收到错误 #3”
这是我的代码例子.php
<?php
$config = array("cert_id" => "PHCVJS6GDV6TY", "business" => "roki_1347003608_biz@gmail.com","basedir" => "./",
"certstore" => "./", "tempdir" => "./", "my_private" => "my-prvkey.pem", "my_public" => "my.pubcert.pem",
"paypal_public" => "paypal_cert_pem.txt");
$paypal = new PayPal_EncryptedButtons($config);
// You can add parameters to the button one by one (name, value) or you can pass two
// arrays of names and values, as documented below.
$names = array("amount", "currency_code", "item_name", "item_number");
$values = array("2.56", "USD", "Dave's secret encryption sauce (encryption via PHP)", "123456");
$paypal->addButtonParam($names, $values);
// We can now generate our code
$result = $paypal->encryptButtonData();
if ($result !== PP_ERROR_OK) {
// Something went wrong
echo "Received Error #".$result."\n";
exit;
}
// Get the string of encrypted button data
echo '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">';
echo '<input type="hidden" name="cmd" value="_s-xclick">';
echo '<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!">';
echo '<input type="hidden" name="encrypted" value="';
echo $paypal->getButton();
echo '">';
echo "</form>\n";
?>
</body>
</html>
加密按钮.php
<?php
define("PP_ERROR_OK", 0);
define("PP_ERROR_FILE", 1);
define("PP_ERROR_OPENSSL", 2);
define("PP_ERROR_DATA", 3);
define("PP_ERROR_PARAMS", 4);
define("PP_ERROR_NOTFOUND", 5);
define("PP_ERROR_UNKNOWN", 6);
require_once "/wamp/www/var/Php/Config.php";
class PayPal_EncryptedButtons {
/** Button Data Array */
var $buttonData = array();
/** Config Pointer */
var $config;
/** Internal Data Handler */
var $_data;
/** Random Transaction ID */
var $_rnd;
var $debug = true;
function PayPal_EncryptedButtons($config = array()) {
$this->config = new PayPal_EncryptedButtons_Config;
/*
foreach ($config as $name => $val) {
if ($this->config->$name) {
$this->config->$name = $val;
}
else {
return PP_ERROR_UNKNOWN;
}
}
*/
return;
}
function changeConfig($name, $value = "") {
if ($this->config->$name) {
$this->config->$name = $value;
return true;
}
else {
return false;
}
}
function addButtonParam($names = "", $values = "") {
if ((is_array($names) && !is_array($values)) || (!is_array($names) && is_array($values))) {
return PP_ERROR_PARAMS;
}
elseif (is_array($names) && is_array($values)) {
if (count($names) !== count($values)) {
return PP_ERROR_PARAMS;
}
$i = 0;
while ($i < count($names)) {
$this->buttonData[$names[$i]] = $values[$i];
$i++;
}
return PP_ERROR_OK;
}
else {
if ($names == "" || $values == "") {
return PP_ERROR_PARAMS;
}
else {
$this->buttonData[$names] = $values;
return PP_ERROR_OK;
}
}
}
function delButtonParam($name = "") {
if ($name == "") {
return PP_ERROR_PARAMS;
}
if ($this->buttonData[$name] !== null) {
$this->buttonData[$name] = null;
return PP_ERROR_OK;
}
return PP_ERROR_NOTFOUND + 10;
}
function encryptButtonData() {
$this->encryptedButton = null;
if (!is_dir($this->config->basedir)) {
if (!mkdir($this->config->basedir)) {
return PP_ERROR_NOTFOUND + 20;
}
}
@chdir($this->config->basedir);
$this->_data = "cmd=_xclick\n";
$this->_data .= "business=".$this->config->business."\n";
$this->_data .= "receiver_email=".$this->config->receiver_email."\n";
foreach ($this->buttonData as $name => $val) {
if ($val == null) { continue; }
$this->_data .= $name."=".$val."\n";
}
$this->_data .= "cert_id=".$this->config->cert_id;
$this->_rnd = rand(100000, 999999);
if (!is_dir($this->config->tempdir)) {
if (!@mkdir($this->config->tempdir)) {
return PP_ERROR_NOTFOUND + 30;
}
}
$f = @fopen($this->config->tempdir.$this->_rnd.".1", "w");
//if (!$f) { return PP_ERROR_FILE; }
if (!$f) { return 41; }
fwrite($f, trim($this->_data), strlen(trim($this->_data)));
fclose($f);
if (!file_exists($this->config->my_private)) {
return 145;
}
if (!file_exists($this->config->my_public)) {
return 245;
}
if (!file_exists($this->config->paypal_public)) {
return 345;
}
if (!file_exists($this->config->my_private) || !file_exists($this->config->my_public) || !file_exists($this->config->paypal_public)) {
return PP_ERROR_NOTFOUND + 40;
}
$exec = $this->config->openssl." smime -sign -in ".$this->config->tempdir.$this->_rnd.".1 -signer ".$this->config->my_public." -inkey ".$this->config->my_private." -outform der -nodetach -binary > ".$this->config->tempdir.$this->_rnd.".2";
$status1 = `$exec`;
$exec = $this->config->openssl." smime -encrypt -des3 -binary -outform pem ".$this->config->paypal_public." < ".$this->config->tempdir.$this->_rnd.".2 > ".$this- >config->tempdir.$this->_rnd.".3";
$status2 = `$exec`;
$this->encryptedButton = trim(file_get_contents($this->config->tempdir.$this->_rnd.".3"));
@unlink($this->config->tempdir.$this->_rnd.".1");
@unlink($this->config->tempdir.$this->_rnd.".2");
@unlink($this->config->tempdir.$this->_rnd.".3");
if (strpos($status1, "No such file or directory") !== false || strpos($status2, "No such file or directory") !== false) {
return PP_ERROR_OPENSSL;
}
if (!$this->encryptedButton) {
return PP_ERROR_DATA;
}
return PP_ERROR_OK;
}
function getButton() {
if (!$this->encryptedButton) {
return "";
}
return $this->encryptedButton;
}
配置.php
<?php
class PayPal_EncryptedButtons_Config {
var $cert_id = "PHCVJS6GDV6TY";
var $business = "roki_1347003608_biz@gmail.com";
var $receiver_email = "";
var $basedir = "/wamp/www/var/";
var $certstore = "/wamp/www/key/cert/";
var $tempdir = "/wamp/www/temp/";
var $openssl = "openssl";
var $my_private = "/wamp/www/key/cert/my-prvkey.pem";
/* Your Public Certificate Filename */
var $my_public = "/wamp/www/key/cert/my.pubcert.pem";
/* PayPal's Public Certificate Filename */
var $paypal_public = "/wamp/www/key/cert/paypal_cert_pem.txt";
}
?>
错误
Received Error #3
任何人都可以知道这是什么错误任何人都可以帮助我如何解决这个问题真的我帮助较少。谢谢
最佳答案
问题是要使脚本正常工作,您需要有 OpenSSL。在脚本的注释中,它确实指定使用它来加密 PayPal 按钮。
这一行是导致问题的原因,因为它无法创建文件,因为尚未指定 OpenSSL。
$exec = $this->config->openssl." smime -encrypt -des3 -binary -outform pem ".$this->config->paypal_public." < ".$this->config->tempdir.$this->_rnd.".2 > ".$this->config->tempdir.$this->_rnd.".3";
您需要指定 OpenSSL 的路径才能使其正常工作。
以下内容摘自您链接的网站。
配置:
/* OpenSSL Path - Path to the OpenSSL Binary */
/* If openssl isn't in your PATH, then change this to where it's located, otherwise leave it as it is */
/* No trailing slash */
var $openssl = "openssl";
有关在本地主机中使用 OpenSSL 的信息可以通过以下谷歌查询找到: https://www.google.co.uk/search?q=openssl+for+localhost
OpenSSL:http://www.openssl.org/
希望对您有所帮助。
关于php - Paypal - 用 php 加密 buynow 动态结帐按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12552124/
我似乎记得在某个地方看到过这个,但在我的一生中,搜索并没有出现我正在寻找的结果。这是我想要的: 我有一个项目存储库。我想将其他 svn 存储库中的库包含在我的项目中。当我对主项目执行 SVN 提交时,
我正在 Magento 中寻找我的结帐购物车页面的解决方案。当我将商品放入购物车时,购物车页面变得空白。!! 我已经尝试了几个选项,但它仍然显示为空白。我启用了 cookie 等,但仍然没有运气。我正
我有一个文件,其中包含 CVS 存储库中包含的许多标签。有没有一种方法可以只使用这些标签 checkout 所有文件及其相关目录,而无需 checkout 整个存储库? 我没有存储库中的目录列表,因此
我正在尝试为客户站点开发一个结帐系统,我想知道执行此操作的最佳方法。请让我知道我在下面尝试过的任何替代方法。 目前我有: 1) 购物车中的商品保存到 $_SESSION 变量 2) 当用户按下“结帐”
我真的很想为我正在开发的市场使用 Paypal。我需要允许用户输入他们的 paypal 电子邮件地址,每当客户购买该用户的产品时,我都会收取少量费用,然后剩下的钱会转到列出该产品的用户。 哪种 pay
有没有办法让输入信用卡信息的部分默认打开,而不是输入paypal信息的部分? 我真的很需要这个,但是到处都找不到! 最佳答案 做到这一点的唯一方法是使用 Express Checkout .在你的Se
我正在使用在 node 下运行的 Stripe Subscription。 我想创建一个预先填写电子邮件地址的新结帐。所以我尝试在客户端做: // Setup event handler to cre
我正在尝试使用 Checkout Dependencies Leiningen 中的功能用于使用 Flambo checkout 的项目.我的 project.clj 看起来像这样: (defproj
谁能告诉我如何使用 Maven 从 SVN 进行结账和进一步更新?我阅读了 maven.apache.org 上的文档,但似乎我对此太愚蠢了,因为我无法理解如何使用 scm:checkout 和 sc
我在 onepage/checkout/success 页面上遇到了麻烦,因为我想将根模板从 2columns-right.phtml 设置为 1column.phtml。应该问题不大... 我得到了
我使用 subversion 创建新存储库的正常工作流程是创建一个新存储库,检查存储库根目录,创建我的分支标签和主干文件夹,并将我的初始文件放在主干中。然后我提交这个“初始导入”,从我的硬盘驱动器中删
我已经使用以下代码向管理员用户添加了自定义元字段:`` function wporg_usermeta_form_field_birthday( $user ) { ?>
我想将 CVS 模块深处的特定文件夹 check out 到我的 Hudson/Jenkins 工作区中。剥离其他选项(例如修剪、分支等),CVS 命令是... cvs checkout -d wor
我正在尝试 git checkout Jenkinsfile跟随方式 stage ('Repo Checkout') { steps { dir('My-Repo') {
我们的大多数项目都使用很多通用代码。我们(最终)正朝着以统一方式管理共享代码的系统迈进。我们将共享代码视为 SVN 中的一个单独项目,然后将其作为外部引用。然而,我们倾向于在项目开发时将外部库指向开发
我已经使用 node.js 实现了 strip 结帐 product.photo是 https://test.s3.amazonaws.com/2213131 const session = awai
将产品添加到购物车时出现问题,它会转到结帐页面,但除了周围的页眉/页脚模板之外,该页面是空的。 我已经尝试了我能想到的一切,它不是主题(发生在所有主题上),我尝试禁用编译器和刷新缓存等.. 服务器日志
有什么方法可以禁用 Magento 中的购物卡/结账/送货选项吗? 我正在开发一个产品比较网站,其价格是从联属网站列出的。 我实际上并没有在我的网站上销售任何东西。 最佳答案 aDVo,如果禁用以下m
我正在做一个订购冰淇淋的程序,用户首先应该在圆锥体或杯子之间进行选择(作为按钮),当他单击按钮时,总数会显示在文本字段中,然后他可以继续选择口味作为复选框,每当他添加额外的 flavor 等时,总数就
我正在使用 HTML 5 required 属性进行表单验证。现在我想要的是,如果表单已经通过了 HTML 5 验证,它应该将用户带到 strip 结帐(我故意在下面的代码中为 SO 问题 xxx 输
我是一名优秀的程序员,十分优秀!