使用权限API获取reponseToken和TokenSecret后处理付款。以下是用于处理付款的代码。我使用了responseToken和TokenSecret创建了签名。
$apiCred_user = $user_id;
$apiCred_pass = $passwd;
$accessToken = 'h4TZXQ-YTSRU1v.3xkH29I536CulbrLtC52FX468BepI5PEI9uYasQ';
$tokenSecret = 'boppIESaQJsdoSFjhjwjhfNHiiQ';
$url1 = "https://api.sandbox.paypal.com/nvp";
$auth = new AuthSignature();
$response = $auth->genSign($apiCred_user,$apiCred_pass,$accessToken,$tokenSecret,'POST',$url1);
$authString =
"token=".$accessToken.
",signature=".$response['oauth_signature'].
",timestamp=".$response['oauth_timestamp'];
$headers_arr = array(
"X-PAYPAL-REQUEST-DATA-FORMAT:NV",
"X-PP-AUTHORIZATION:".$authString,
"X-PAYPAL-RESPONSE-DATA-FORMAT:json",
"X-PAYPAL-APPLICATION-ID:APP-80W284485P519543T"
);
$params = array(
"METHOD"=> "DoDirectPayment",
"PAYMENTACTION"=> "Sale",
"AMT"=> "22.00",
"ACCT"=> "4111111111111111",
"CVV2"=> "111",
"FIRSTNAME"=> "Jane",
"LASTNAME"=> "Smith",
"EXPDATE"=> "012018",
"IPADDRESS"=> "127.0.0.1",
"STREET"=> "123 Street Way",
"CITY"=> "Englewood",
"STATE"=> "CO",
"ZIP"=> "80112",
"VERSION"=> "86",
"SIGNATURE"=> $signature,
"USER"=> $user_id,
"PWD"=> $passwd,
"SUBJECT"=> "thirdparty@mail.com"
);
try{
$curl_session = curl_init();
curl_setopt($curl_session, CURLOPT_URL,$url1);
curl_setopt($curl_session, CURLOPT_HTTPHEADER, $headers_arr);
curl_setopt($curl_session, CURLOPT_POST, 1);
curl_setopt($curl_session, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($curl_session, CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($curl_session, CURLOPT_TIMEOUT, 10);
//curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($curl_session, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 0);
$response = json_decode(curl_exec($curl_session));
我没有结果......
我正在做这个正确的方法吗?处理付款?