Paypal Express checkout(PHP): Transaction id is invalid(DoAuthorization) - php

I'm using Paypal Express Checkout method for my shopping cart. the paypal payment is working correctly.
i used the correct TRANSACTIONID from my sandbox account after the transaction but the given code always returns the error Transaction id is invalid.
$request_params = array
(
'METHOD' => 'DoAuthorization',
'USER' => $api_username,
'PWD' => $api_password,
'VERSION' => $api_version,
'TRANSACTIONID'=>$payment['transaction_id'],
'AMT' => $order['sub_total'],
'CURRENCYCODE' => 'USD',
);
$nvp_string = '';
foreach ($request_params as $var => $val)
{
$nvp_string .= '&' . $var . '=' . urlencode($val);
}
$certFile = 'C:\xampp\htdocs\my_project\certificate\cert_key_pem.txt';
$curl = curl_init();
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_URL, $api_endpoint);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSLCERT, $certFile);
curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string
$result = curl_exec($curl);
curl_close($curl);
$result_array = $this->NVPToArray($result);
echo "<pre>"; print_r($result_array); die();
the array gives the value as below
Array
(
[TIMESTAMP] => 2015-08-10T07:45:36Z
[CORRELATIONID] => deb2f549572b0
[ACK] => Failure
[VERSION] => 85.0
[BUILD] => 000000
[L_ERRORCODE0] => 10609
[L_SHORTMESSAGE0] => Invalid transactionID.
[L_LONGMESSAGE0] => Transaction id is invalid.
[L_SEVERITYCODE0] => Error
)
if you have any idea about such type of errors on Paypal Express Checkout DoAuthorization then please help me. thanks

Related

PayPal DoDirectPayment working without cvv

Hi I implement PayPal DoDirectPayment in my website, I want to required expire date And CVV but payment taking without those with this warning "This transaction was approved. However, the Card Security Code provided had too few, too many, or invalid character types but, as per your account option settings, was not required in the approval process"
I'm using PHP.
My Code is
$api_endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
$request = array
(
'METHOD' => 'DoDirectPayment',
'USER' => 'sell3_api1.pay.com',
'PWD' => '75DQHCABLDFSDF',
'SIGNATURE' => 'AFcWxV21C7fd0asdasdCpasdsdAtxzafSFsaKZ3unSUBjX9r-',
'VERSION' => '55.0',
'PAYMENTACTION' => 'Sale',
'FIRSTNAME' => $current_user->user_login,
'LASTNAME' => '.',
'IPADDRESS' => $_SERVER['REMOTE_ADDR'],
'ACCT' => $acct,
'CREDITCARDTYPE'=>
'EXPDATE' => $month.$year,
'CVV2' => $cvv,
'AMT' => $amt,
'CURRENCYCODE' => 'USD',
);
$nvp_string = '';
foreach ($request as $key => $value) {
$nvp_string .= '&'.$key.'='.urlencode($value);
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_URL, $api_endpoint);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string);
$result = curl_exec($curl);
curl_close($curl);
parse_str($result);
How can I solve It.

sslv3 alert handshake failure under magento

I develop a paypal pro in magento.
my paypal code look below:
$api_username = 'sdk-three_api1.sdk.com';
$api_password = 'QFZCWN5HZM8VBG7Q';
$api_signature = 'A.d9eRKfd1yVkRrtmMfCFLTqa6M9AyodL0SJkhYztxUi8W9pCXF6.4NI';
$api_version = '57.0';
$api_endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
$request_params = array
(
'METHOD' => 'DoDirectPayment',
'USER' => $api_username,
'PWD' => $api_password,
'SIGNATURE' => $api_signature,
'VERSION' => $api_version,
'PAYMENTACTION' => 'Sale',
'IPADDRESS' => $_SERVER['REMOTE_ADDR'],
'CREDITCARDTYPE' => $params['creditCardType'],
'ACCT' => $params['creditCardNumber'],
'EXPDATE' => $params['expDateMonth'].$params['expDateYear'],
'CVV2' => $params['cvv2Number'],
'FIRSTNAME' => 'Tester',
'LASTNAME' => 'Testerson',
'STREET' => '707 W. Bay Drive',
'CITY' => 'Largo',
'STATE' => 'FL',
'COUNTRYCODE' => 'US',
'ZIP' => '33770',
'AMT' => $plan_data['amount'],
'CURRENCYCODE' => 'USD',
'DESC' => 'Testing Payments Pro'
);
$nvp_string = '';
foreach($request_params as $var=>$val)
{
$nvp_string .= '&'.$var.'='.urlencode($val);
}
//var_dump($nvp_string); die;
$curl = curl_init();
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_URL, $api_endpoint);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSLVERSION, 3);
curl_setopt($curl, CURLOPT_SSL_CIPHER_LIST, 'SSLv3');
//curl_setopt($curl, CURLOPT_SSL_CIPHER_LIST, 'TLSv1');
$result = curl_exec($curl);
if (curl_errno($curl))
{
echo "CURL send a error during perform operation: ".curl_error($curl);
}
else
{
curl_close($curl);
}
// Parse the API response
$nvp_response_array = parse_str($result);
var_dump($result);
But i getting an error like
error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake
failure
And if i not added this two line
curl_setopt($curl, CURLOPT_SSLVERSION, 3);
curl_setopt($curl, CURLOPT_SSL_CIPHER_LIST, 'SSLv3');
then give me an error like
error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
Any help?
There was some updates to Sandbox recently, updates that will need to be applied on Live at a later time, this post will help you

How t transfer money paypal to payment?

I am new in paypal API. I am trying to transfer money from one paypal account to another paypal account but I am getting error. so please check my code and tell me what is wrong error.Your suggestions are welcome.
This is the code I am trying :
$receiverList=array();
$receiverList["receiver"][$counter]["amount"]=50;
$receiverList["receiver"][$counter]["email"]='amandeep.singh########.com';
$receiverList["receiver"][$counter]["paymentType"]="PAY";
$receiverList["receiver"][$counter]["invoiceId"]=1548569;
$payLoad["actionType"]="PAY";
$payLoad["cancelUrl"]="";
$payLoad["currencyCode"]="EUR";
$payLoad["receiverList"]=$receiverList;
$payLoad["feesPayer"]="SENDER ";
$payLoad["sender"]["email"]='amandeep.singh########.com';
//run the call
$API_Endpoint = "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay";
$payLoad["requestEnvelope"]= array("errorLanguage"=>urlencode("en_US"),"detailLevel"=>urlencode("ReturnAll"));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-PAYPAL-REQUEST-DATA-FORMAT: JSON',
'X-PAYPAL-RESPONSE-DATA-FORMAT: JSON',
'X-PAYPAL-SECURITY-USERID: amandeep.singh-facilitator_api1.mobilyte.com',
'X-PAYPAL-SECURITY-PASSWORD: AZVMY9FZK2J#####',
'X-PAYPAL-SECURITY-SIGNATURE: AFcWxV21C7fd0v3bYYYRCpSSRl31AodeBybN3aK381NetHgWkUW1####',
'X-PAYPAL-APPLICATION-ID: APP-80W28##########3'));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payLoad));
$response = curl_exec($ch);
$response = json_decode($response, 1);
after call above curl, paypal return this error:-
Array ( [responseEnvelope] => Array ( [timestamp] => 2016-02-21T21:58:24.854-08:00 [ack] => Failure [correlationId] => 3693e36af347f [build] => 20367699 ) [error] => Array ( [0] => Array ( [errorId] => 560022 [domain] => PLATFORM [subdomain] => Application [severity] => Error [category] => Application [message] => The X-PAYPAL-APPLICATION-ID header contains an invalid value [parameter] => Array ( [0] => X-PAYPAL-APPLICATION-ID ) ) ) )
The APPID for the sand-box and live are different to one another.
The Sand box should be used with the following ID :
APP-80W284485P519543T
And the live is used with the ID which is similar to that of APP credentials.

PayPal RefundTransaction API (NVP) Issue

I'm trying the RefundTransaction API with nvp as [METHOD] => RefundTransaction
Only Common Response Fields returning as a response to PayPal RefundTransaction API Operation (NVP)
Here is the request
Array
(
[METHOD] => RefundTransaction
[VERSION] => 54.0
[USER] => abc***xyz.com
[PWD] => asd******asd
[SIGNATURE] => T535*****************************************qWE3
[CURRENCYCODE] => AUD
[TRANSACTIONID] => 1D4*******40913KKJ
)
Here is the respose I'm getting.
Array
(
[TIMESTAMP] => 2014-11-11T11:40:57Z
[CORRELATIONID] => 3dba******fce
[ACK] => Success
[VERSION] => 54.0
[BUILD] => 13***072
)
The thing is I'm getting the response as Success, but only the common fields are there. Please help
This is how my function looks like
private function nvpCall($transaction_id){
$params['TRANSACTIONID'] = $transaction_id;
$params['REFUNDTYPE'] = 'Full';
$nvpArr = $params ;
$nvpreq = array();
$nvpreq['METHOD'] = urlencode($methodName);
$nvpreq['VERSION'] = urlencode('54.0');
$nvpreq['USER'] = urlencode($this->pp_pro_username);
$nvpreq['PWD'] = urlencode($this->pp_pro_password);
$nvpreq['SIGNATURE'] = urlencode($this->pp_pro_signature);
$nvpreq['CURRENCYCODE'] = urlencode('AUD');
$nvpreq = array_merge($nvpreq, $nvpArr);
$strReq = '';
foreach($nvpreq as $key => $val){
if($strReq!='') {
$strReq.= '&';
}
$strReq.= $key.'='.urlencode($val);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->api_endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $strReq);
$response = curl_exec($ch);
curl_close($ch);
print_r($this->deformatNVP($response));
}
added notes
Now i found out that it wasn't the problem with code, it was working with another username,password and signature in sandbox account though! So what might be the problem?

Resolved: PayPal Adaptive Payments Authentication failed

I have registered on PayPal Sandbox, then I added Seller Preconfigured test account. As for ApplicationId, I used few ones found on Web. Finally, triggering Preapproval, I'm having error in response:
Array
(
[RESPONSEENVELOPE.TIMESTAMP] => 2011-12-26T19:39:54.500-08:00
[RESPONSEENVELOPE.ACK] => Failure
[RESPONSEENVELOPE.CORRELATIONID] => a052cd3abd4ea
[RESPONSEENVELOPE.BUILD] => 2279004
[ERROR(0).ERRORID] => 520003
[ERROR(0).DOMAIN] => PLATFORM
[ERROR(0).SUBDOMAIN] => Application
[ERROR(0).SEVERITY] => Error
[ERROR(0).CATEGORY] => Application
[ERROR(0).MESSAGE] => Authentication failed. API credentials are incorrect.
)
PHP code:
$URL = 'https://svcs.sandbox.paypal.com/AdaptivePayments/Preapproval'
.'?startingDate='.date('Y-m-d\Z')
.'&endingDate='.date('Y-m-d\Z', strtotime('+1 year'))
.'&currencyCode=USD'
.'&maxTotalAmountOfAllPayments=500.00'
.'&maxAmountPerPayment=200.00'
.'&maxNumberOfPayments=30'
.'&senderEmail=user#domain.com'
.'&cancelUrl=http://example.com/cancel'
.'&returnUrl=http://example.com'
.'&pinType=NOT_REQUIRED'
.'&requestEnvelope.errorLanguage=en_US';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER
, array(
'X-PAYPAL-SECURITY-USERID' => 'xxxx'
, 'X-PAYPAL-SECURITY-PASSWORD' => 'xxxx'
, 'X-PAYPAL-SECURITY-SIGNATURE' => 'xxxxxxxxxxxxxxxxxxxx'
, 'X-PAYPAL-APPLICATION-ID' => 'APP-80W284485P519543T'
, 'X-PAYPAL-REQUEST-DATA-FORMAT' => 'NV'
, 'X-PAYPAL-RESPONSE-DATA-FORMAT' => 'NV'
)
);
$response = curl_exec($ch);
$responseAr = explode('&', $response);
$parsedResponseAr = array();
foreach($responseAr as $i => $value) {
$tmpAr = explode('=', $value);
if(!empty($tmpAr))
$parsedResponseAr[strtoupper($tmpAr[0])] = urldecode($tmpAr[1]);
}
print_r($parsedResponseAr);
Could that be because of wrong App Ids? Do I have to register my App first to get App Id to use it in Sandbox?
Edit: I found the reason: the format of headers array was incorrect.
It should be:
array(
'X-PAYPAL-SECURITY-USERID: xxx'
, 'X-PAYPAL-SECURITY-PASSWORD: xxxx'
, 'X-PAYPAL-SECURITY-SIGNATURE: xxxxxxxx'
, 'X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T'
, 'X-PAYPAL-REQUEST-DATA-FORMAT: NV'
, 'X-PAYPAL-RESPONSE-DATA-FORMAT: NV'
)
[ERROR(0).MESSAGE] => Authentication failed. API credentials are incorrect.
bit of a give away!

Categories