我想在我的系统中整合paypal的单一支付方式,因为我想在他们请求提款时向我的卖家汇款。我已经生成了一个"访问令牌密钥"为此,并从PHP脚本进行curl调用。但响应是一个空白字符串。我试过了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是一个空白字符串,尝试获得单个支付详细信息,但这也返回空白字符串...请提前帮助..谢谢。
答案 0 :(得分:0)
经过2天的搜索,我找到了答案,这很容易。我没有使用paypal的单笔付款,而是使用它的PAY API的Implicit Payments操作。以下是它的代码..
$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。)