How to get canceled payments detail - paypal

I am using PayPal classic API and fetching all PayPal transaction detail using following code.
$info = 'USER=api_username&PWD=api_password&SIGNATURE=api_sgnature&VERSION=94&METHOD=GetTransactionDetails&TRANSACTIONID='.$value;
$curl = curl_init('https://api-3t.paypal.com/nvp');
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, $info);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_POST, 1);
$result = curl_exec($curl);
$str = $result;
parse_str($result, $result);
foreach($result as $key => $value){
echo $key.' => '.$value."<BR>";
}
Following output, I am getting for created and canceled payments or transactions.
ADDRESSOWNER => PayPal
ADDRESSSTATUS => None
TIMESTAMP => 2015-06-26T05:10:54Z
CORRELATIONID => 4dad1aa370757
ACK => Failure
VERSION => 94
BUILD => 17103657
L_ERRORCODE0 => 10004
L_SHORTMESSAGE0 => Transaction refused because of an invalid argument. See additional error messages for details.
L_LONGMESSAGE0 => The transaction id is not valid
L_SEVERITYCODE0 => Error
PENDINGREASON => None
REASONCODE => None
L_TAXABLE0 => true
As you can see from response that neither I am getting transaction id nor email of cancelled transaction so there is no way to recognize this transaction.
What can be the error or is there any alternative?

Related

How to access data from onesignal additional data object in cordova ionic app

I want to access data i have assigned to the data variable of feilds array to be sent in onesignal message.
function sendMessage($received)
{
$content = array(
"en" => 'Current Data'
);
$data = $received;
$fields = array(
'app_id' => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
'included_segments' => array('All'),
'contents' => $content,
'data' => $data, // => This is the data i want to access on
client side.
);
$response['feilds'] = $fields;
$fields = json_encode($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
"https://onesignal.com/api/v1/notifications");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:
application/json; charset=utf-8',
'Authorization:Basic
Nzg0YmM2NzUtZWYyMC00NDZmLWE1ODItZDExZTU3OTXXXXXX'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response['resp'] = curl_exec($ch);
curl_close($ch);
return $response;
}
I need help that how i can access the data variable there on client side in ionic app.
Below is what i am trying.
this.oneSignal.startInit('XXXXXXX-32ae-4025-b26b-
XXXXXXXXXX','XXXXXXXXX');
this.oneSignal.handleNotificationReceived().subscribe((jsonData) => {
if(jsonData.payload.additionalData)
{
this.myService.NotirefreshData(jsonData.payload.additionalData);
let ten = JSON.stringify(jsonData.payload.additionalData);
this.storage.set('current',ten);
this.presentAlert('From Server',ten);
this.storage.get('past').then((pri) => {
this.presentAlert('From Storage',JSON.parse(pri));
});
}
How should be the below statement to access the data variable to array feild received from server?
(jsonData.payload.additionalData.??????????????)
I have tried
(jsonData.payload.additionalData.feilds)
(jsonData.payload.additionalData.current) // as current is the name of an array
You don't need that subscribe() call. Simply pass in the handler into the function.
window.plugins.OneSignal
.startInit("YOUR_APP_ID")
.handleNotificationReceived(function(notificationData) {
alert("Notification Data Received:\n" + JSON.stringify(notificationData));
console.log('Notification Data Received: ' + JSON.stringify(notificationData));
})
.endInit();

Filling form using PUT method and cURL

I need to fill form and then send data to the server. To simulate form filling and button submit I'm trying to use PUT method and cURL but without any success.
I have no idea what im doing wrong becouse I'm not very experienced in using cURL. Thanks to all for any help.
These headers I can see when I submit form manualy: http://www.krafty.cz/headers.txt
and here is my code:
$data = array(
'authenticity_token' => 'uGjjg9Jv4E5s4FE9e6afza9v1ycIR9sdAAnvmjcGf8YeUl0+UzpsaT5p/I/LIFs/kbOb7g4TmWx5Pq+TGt7V1Q==',
'show_preview' => '1',
'product[international]' => '0',
// *** THERE IS MUCH MORE FIELDS IN ARRAY HERE, ACCORDING TO HEADERS
'product[auto_renewable]' => 'true',
'button' => ''
);
$curl = curl_init('http://en.dawanda.com/seller/products/new');
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded','authenticity_token: uGjjg9Jv4E5s4FE9e6afza9v1ycIR9sdAAnvmjcGf8YeUl0+UzpsaT5p/I/LIFs/kbOb7g4TmWx5Pq+TGt7V1Q=='));
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
$response = curl_exec($curl);

Paypal PDT - SSL connect error

I use this code to process Paypal payment data transfer (PDT):
$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$tx_token = $_GET['tx'];
$auth_token = "my_token";
$fields = array(
'cmd' => '_notify-synch',
'tx' => $tx_token,
'at' => $auth_token,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$res = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo 'Curl error: ' . curl_error($ch);
echo "status: " . $status;
curl_close($ch);
And I'm getting:
Curl error: SSL connect error
status: 0
I tried to make the API in Postman with the same URL: www.sandbox.paypal.com with the same parameters (cmd, at, tx) and I got success response. What I did wrong?
PayPal has upgraded to TLS 1.2 for its sandbox API endpoints. You can find out more about the upgrade and when it will affect production at the TLS 1.2 and HTTP/1.1 Upgrade Microsite.
You will need OpenSSL to be 1.0.1c or higher and a recent version of libcurl.
As far as your specific code, you probably want to do the following:
curl_setopt($ch, CURLOPT_SSLVERSION, 6); // CURL_SSLLVERSION_TLSv1_2 = 6
Also, you probably should leave the CURLOPT_SSL_VERIFYHOST to be 2 to verify the SSL certificate for the endpoint.
You can find out more at the PayPal TLS update repository for specific language environment requirements.

Recieve initial amount from paypal when creating recurring profile

Im trying to do a simple thing and it doesn't work properly:
Im trying to do initial payment when creating a profile, problem is, when user comes back (after his consent) from paypal, the status of the profile is pending (probably due to the initial payment that doesn't happen), and no initial amount is being paid, what could be the reason for that?
my code for excuting the recurring paypal:
$req = array(
'USER' => 'bennyrefaelov-facilitator_api1.gmail.com',
'PWD' => 'YWKQ3M3NXBTZQ78U',
'SIGNATURE' => 'AFcWxV21C7fd0v3bYYYRCpSSRl31AuVEFUpBu6N8yXkmFksuwwSiQOW8',
'VERSION' => '98.0',
'METHOD' => 'CreateRecurringPaymentsProfile',
'TOKEN'=>$token,
'payerid'=>$payerId,
'PROFILESTARTDATE' =>'2014-11-05T09:28:00Z',
'TOTALBILLINGCYCLES'=>'11',
'DESC'=>'Pay up',
'BILLINGPERIOD'=>'Day',
'BILLINGFREQUENCY'=>'1',
'AMT'=>'100.00',
'INITAMT' => '50.00',
'CURRENCYCODE'=>'USD',
'COUNTRYCODE'=>'US',
'MAXFAILEDPAYMENTS'=>'3'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api-3t.sandbox.paypal.com/nvp');
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_POSTFIELDS, http_build_query($req));
$return = curl_exec($ch);
In short, why doesn't initial payment occur?
You are using sandbox method. sandbox is slow sometimes it took a couple days for the profile to become active and send the IPN.Even live sometimes takes time.

Paypal NVP REFUND API getting Error 10007

I am trying to refund the amount using the paypal nvp. And I am getting the following error
[TIMESTAMP] => 2013 04 06T13 48 19
[CORRELATIONID] => aac23709cc94a
[ACK] => Failure [VERSION] => 51 0
[BUILD] => 5618210
[L_ERRORCODE0] => 10007
[L_SHORTMESSAGE0] => Permission denied
[L_LONGMESSAGE0] => You do not have permission to refund this transaction
[L_SEVERITYCODE0] => Error )
What is that I am doing wrong?
I have set the api keys of the emailid to which payment is made
Please let me know what is problem and how can I make refund work.
Code
$API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
$version = urlencode('51.0');
$API_UserName = 'example';
$API_Password = 'example';
$API_Signature = 'example';
$API_Endpoint = 'example';
$sandboxmode = 'example';
$methodName_ = 'RefundTransaction';
$transactionID = urlencode('example');
$refundType = urlencode('example');
if($partial) {
$amount = 'example';
$memo = 'Refunding the amount ';
$nvpStr_ = "&TRANSACTIONID=$transactionID&REFUNDTYPE=$refundType&CURRENCYCODE=$currencyID&AMT=$amount&NOTE=$memo";
} else {
$nvpStr_ = "&TRANSACTIONID=$transactionID&REFUNDTYPE=$refundType&CURRENCYCODE=$currencyID";
}
$currencyID = urlencode('CAD');
$API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
$version = urlencode('51.0');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
// Turn off the server and peer verification (TrustManager Concept).
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);
// Set the API operation, version, and API signature in the request.
$nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";
// Set the request as a POST FIELD for curl.
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
// Get response from the server.
$httpResponse = curl_exec($ch);