我一直在寻找一个解决我的paypal自适应愿望的解决方案,我找到了一个,PHP SDK。但是,它使用表单系统(用户输入自己的数据和价格),这对我的系统来说不是最佳的。基本上,人们将上传项目,用户可以购买该项目的项目。价格将从相关数据库中提取并按百分比分割,然后用户将以适当的金额发送给paypal。我可以使用表单并使类型隐藏,但不幸的是,它不起作用,因为它太不安全,我宁愿不公开所有可以更改的数据。
表单的外观:http://i.gyazo.com/e6de8e40ccebbd6c7b381331983304b3.png
我想将数据数组转换为如下所示,但整个库基于[$ i]函数,这是一个数组函数(?),但我不知道如何“转换”它是我想要的那个。
$Receivers = array();
$Receiver = array(
'Amount' => '100.00',
'Email' => 'agb_b_1296836857_per@angelleye.com',
'InvoiceID' => '123-ABCDEF',
'PaymentType' => 'SERVICE',
'PaymentSubType' => '',
'Phone' => array('CountryCode' => '', 'PhoneNumber' => '', 'Extension' => ''),
'Primary' => 'true'
);
array_push($Receivers,$Receiver);
这就是它在payReceipt.php库中的样子(数据被处理,然后通过我无法找到的许多脚本发送到paypal ..
for($i=0; $i<count($_POST['receiverEmail']); $i++) {
$receiver[$i] = new Receiver();
$receiver[$i]->email = $_POST['receiverEmail'][$i];
/*
* Amount to be credited to the receiver's account
*/
$receiver[$i]->amount = $_POST['receiverAmount'][$i];
/*
* Set to true to indicate a chained payment; only one receiver can be a primary receiver. Omit this field, or set it to false for simple and parallel payments.
*/
$receiver[$i]->primary = $_POST['primaryReceiver'][$i];
/*
* (Optional) The invoice number for the payment. This data in this field shows on the Transaction Details report. Maximum length: 127 characters
*/
if($_POST['invoiceId'][$i] != "") {
$receiver[$i]->invoiceId = $_POST['invoiceId'][$i];
}
另一个例子
if($_POST['paymentType'][$i] != "" && $_POST['paymentType'][$i] != DEFAULT_SELECT) {
$receiver[$i]->paymentType = $_POST['paymentType'][$i];
}
/*
* (Optional) The transaction subtype for the payment.
*/
if($_POST['paymentSubType'][$i] != "") {
$receiver[$i]->paymentSubType = $_POST['paymentSubType'][$i];
}
if($_POST['phoneCountry'][$i] != "" && $_POST['phoneNumber'][$i]) {
$receiver[$i]->phone = new PhoneNumberType($_POST['phoneCountry'][$i], $_POST['phoneNumber'][$i]);
if($_POST['phoneExtn'][$i] != "") {
$receiver[$i]->phone->extension = $_POST['phoneExtn'][$i];
}
}
}
$receiverList = new ReceiverList($receiver);
}
如果你需要潜伏在那里,我很乐意寄给你。