PayPal Adaptive Payment 后不执行任何操作
No action is performed after PayPal Adaptive Payment
我正在尝试此 (Method) 用于 Paypal 自适应支付,第一部分进展顺利,但在完成第二部分后没有任何反应,也没有错误可查看。我知道这已经发布了,但我查看了所有其他答案,但都是徒劳的。
我试图寻找其他选项来执行此功能,但它主要在“Ruby”或其他框架上可用,但我在 PHP 中需要它
这是PHP代码
class PaypalTest{
public $app_id = "APP-80W284485P519543T";
public $apiUrl = 'https://svcs.sandbox.paypal.com/AdaptivePayments/';
public $paypalUrl="https://www.paypal.com/webscr?cmd=_ap-payment&paykey=";
public $headers;
function __construct(){
$this->headers = array(
"X-PAYPAL-SECURITY-USERID: ".$this->api_user,
"X-PAYPAL-SECURITY-PASSWORD: ".$this->api_pass,
"X-PAYPAL-SECURITY-SIGNATURE: ".$this->api_sig,
"X-PAYPAL-REQUEST-DATA-FORMAT: JSON",
"X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
"X-PAYPAL-APPLICATION-ID: ".$this->app_id,
);
$this->envelope = array(
"errorLanguage" => "en_US",
"detailLevel" => "ReturnAll"
);
}
function getPaymentOptions($paykey){
$packet = array(
"requestEnvelope" => $this->envelope,
"paykey" => $paykey
);
return $this->_paypalSend($packet,"getPaymentOptions");
}
function setPaymentOptions(){
}
function _paypalSend($data,$call){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->apiUrl.$call);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
$response = json_decode(curl_exec($ch),true);
return $response;
}
function splitPay(){
// create the pay request
$createPacket = array(
"actionType" =>"PAY",
"currencyCode" => "USD",
"receiverList" => array(
"receiver" => array(
array(
"amount"=> "200.00",
"email"=>"sb-3oe0y636987@personal.example.com"
)
)
),
"returnUrl" => "http://test.local/payments/confirm",
"cancelUrl" => "http://test.local/payments/cancel",
"requestEnvelope" => $this->envelope
);
$response = $this->_paypalSend($createPacket,"Pay");
print_r($response);
$payKey = $response['payKey'];
$detailPacket = array(
"requestEnvelope" => $this->envelope,
"payKey" => $payKey,
"receiverOptions" => array(
array(
"receiver" => array("email"=>"sb-3oe0y636987@personal.example.com"),
"invoiceData" => array(
"item" => array(
array(
"name" => "Product 1",
"price" => "100.00",
"identifier" => "p1"
),
array(
"name" => "Product 2",
"price" => "100.00",
"identifier" => "p1"
)
)
)
)
)
);
$response = $this->_paypalSend($detailPacket,"setPaymentOptions");
echo $response;
print_r($response);
$dets = $this->getPaymentOptions($payKey);
print_r($dets);
}
}
$payment = new PaypalTest();
$payment->splitPay();
新集成不再支持自适应支付,不应使用。
而是切换到受支持的集成,例如 PayPal Checkout。
(还有更专业的 PayPal Commerce Platform,仅适用于获得批准的 PayPal 合作伙伴。)
我正在尝试此 (Method) 用于 Paypal 自适应支付,第一部分进展顺利,但在完成第二部分后没有任何反应,也没有错误可查看。我知道这已经发布了,但我查看了所有其他答案,但都是徒劳的。 我试图寻找其他选项来执行此功能,但它主要在“Ruby”或其他框架上可用,但我在 PHP 中需要它
这是PHP代码
class PaypalTest{
public $app_id = "APP-80W284485P519543T";
public $apiUrl = 'https://svcs.sandbox.paypal.com/AdaptivePayments/';
public $paypalUrl="https://www.paypal.com/webscr?cmd=_ap-payment&paykey=";
public $headers;
function __construct(){
$this->headers = array(
"X-PAYPAL-SECURITY-USERID: ".$this->api_user,
"X-PAYPAL-SECURITY-PASSWORD: ".$this->api_pass,
"X-PAYPAL-SECURITY-SIGNATURE: ".$this->api_sig,
"X-PAYPAL-REQUEST-DATA-FORMAT: JSON",
"X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
"X-PAYPAL-APPLICATION-ID: ".$this->app_id,
);
$this->envelope = array(
"errorLanguage" => "en_US",
"detailLevel" => "ReturnAll"
);
}
function getPaymentOptions($paykey){
$packet = array(
"requestEnvelope" => $this->envelope,
"paykey" => $paykey
);
return $this->_paypalSend($packet,"getPaymentOptions");
}
function setPaymentOptions(){
}
function _paypalSend($data,$call){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->apiUrl.$call);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
$response = json_decode(curl_exec($ch),true);
return $response;
}
function splitPay(){
// create the pay request
$createPacket = array(
"actionType" =>"PAY",
"currencyCode" => "USD",
"receiverList" => array(
"receiver" => array(
array(
"amount"=> "200.00",
"email"=>"sb-3oe0y636987@personal.example.com"
)
)
),
"returnUrl" => "http://test.local/payments/confirm",
"cancelUrl" => "http://test.local/payments/cancel",
"requestEnvelope" => $this->envelope
);
$response = $this->_paypalSend($createPacket,"Pay");
print_r($response);
$payKey = $response['payKey'];
$detailPacket = array(
"requestEnvelope" => $this->envelope,
"payKey" => $payKey,
"receiverOptions" => array(
array(
"receiver" => array("email"=>"sb-3oe0y636987@personal.example.com"),
"invoiceData" => array(
"item" => array(
array(
"name" => "Product 1",
"price" => "100.00",
"identifier" => "p1"
),
array(
"name" => "Product 2",
"price" => "100.00",
"identifier" => "p1"
)
)
)
)
)
);
$response = $this->_paypalSend($detailPacket,"setPaymentOptions");
echo $response;
print_r($response);
$dets = $this->getPaymentOptions($payKey);
print_r($dets);
}
}
$payment = new PaypalTest();
$payment->splitPay();
新集成不再支持自适应支付,不应使用。
而是切换到受支持的集成,例如 PayPal Checkout。
(还有更专业的 PayPal Commerce Platform,仅适用于获得批准的 PayPal 合作伙伴。)