我想将PayPal的单支付方式集成在我的系统中,因为当我要求提款时,我想向卖方汇款。我为此生成了一个"访问令牌密钥",并从PHP脚本中进行了卷曲调用。但是响应是一个空白的字符串。我尝试过curl_error($curl);
,但这也没有做任何事情。以下是我的代码
// data to be sent
$data = [
'sender_batch_header' => [
'email_subject' => "You have a payment",
'sender_batch_id' => "125458268"
],
'items' => [
[
'recipient_type' => "EMAIL",
'amount' => [
'value' => "12.00",
'currency' => "USD"
],
'receiver' => 'myselle@gmail.com',
'note' => 'A trial for single payout',
'sender_item_id' => "2014031400456"
],
],
];
//curl link for single payout with sync off
$curl = curl_init("https://api.sandbox.paypal.com/v1/payments/payouts?sync_mode=true");
$header = array(
"Content-Type: application/json",
"Authorization: Bearer ".$access_token ,
);
$options = array(
CURLOPT_HTTPHEADER => $header,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_POSTFIELDS => json_encode($values),
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_TIMEOUT => 10
);
curl_setopt_array($curl, $options);
$rep = curl_exec($curl);
$response = json_decode($rep, true);
curl_close($curl);
但是这里我的$ rep是一个空白的字符串,也尝试获取单个支付的详细信息,但这也返回空白字符串...请帮助..提前thanx。
搜索2天后,我找到了一个答案,这很容易。我没有使用贝宝(Paypal(的单一支付,而不是我使用的是付费API的隐性付款操作。以下是它的代码..
$receiver[] = array(
'amount' => '125.00',//amount to be transferred
'email' => 'seller@gmail.com',// paypal email id to which you want to send money
);
$result = $paypal->call(
array(
'actionType' => 'PAY',
'currencyCode' => 'USD',
'feesPayer' => 'EACHRECEIVER',
'memo' => 'Withdrawal request no. 356',
'cancelUrl' => '/cancel.php',
'returnUrl' => '/success.php',
'senderEmail' => 'admin.business@gmail.com', // email id of admin's business account, from which amount will be transferred.
'receiverList' => array(
'receiver'=>$receiver
)
), 'Pay'
);
function call($values,$type)
{
$header = array(
"X-PAYPAL-SECURITY-USERID: ".$config['userid'],
"X-PAYPAL-SECURITY-PASSWORD: ".$config['password'],
"X-PAYPAL-SECURITY-SIGNATURE: ".$config['signature'],
"X-PAYPAL-REQUEST-DATA-FORMAT: JSON",
"X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
"X-PAYPAL-APPLICATION-ID: ".$config['appid'];
);
$curl = curl_init("https://svcs.sandbox.paypal.com/AdaptivePayments/");
$options = array(
CURLOPT_HTTPHEADER => $header,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_POSTFIELDS => json_encode($values),
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_TIMEOUT => 10
);
curl_setopt_array($curl, $options);
$rep = curl_exec($curl);
$response = json_decode($rep, true);
curl_close($curl);
return $response;
}
如果您是API呼叫者,并且在" Senderemail"字段中指定您的电子邮件地址,则PayPal将付款设置为隐式批准,而无需重定向PayPal。(或者,您可以使用sender.accountid。(