How t transfer money paypal to payment? - php

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.

Related

Google + Domain API returns forbidden even on paid account

I have been trying to find the reason for this issue since a long time with no luck:
It was working fine on my paid gmail account #mydomain.com, until last week, when it stopped working without any changes in code files.
And now it has been displaying the following error:
[error] => stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[domain] => global
[reason] => forbidden
[message] => Forbidden
)
)
[code] => 403
[message] => Forbidden
)
Any reason for this?
How to resolve this issue?
Following is my current code:
$url = 'https://www.googleapis.com/plusDomains/v1/people/' . $resultUserData['google_id'] . '/activities';
$headers = array(
'Authorization : Bearer ' . $resultUserData['google_access_token'],
'Content-Type : application/json',
);
$message = Mage::getStoreConfig('tab1/general/module_choose_upload_1');
$postImage = SITE_URL.'/media/system/'.Mage::getStoreConfig('tab1/general/upload_1');
$body = array(
"object" => array(
"originalContent" => $message.$productUrl,
"attachments"=> array(
array(
"url"=>$postImage,
)
),
),
"access" => array(
"items" => array(
array("type" => "domain")
),
"domainRestricted" => true
)
);
$data_string = json_encode($body);
$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$file_result = curl_exec($ch);
curl_close($ch);
$file_result = json_decode($file_result);
Please Help!
This is now fixed. The issue was that the email ids that I was using were not having their Google plus profile.
Just created a Google plus profile and then tried the above code and it worked as expected.

Firebase Api Key is not working for iOS only

I want to send push notification using firebase in php. My code is working fine for android but not working for ios device.
And I am getting success:1 for both cases.
Here is my code
<?php
$path_to_firebase_cm = 'https://fcm.googleapis.com/fcm/send';
$fields = array('registration_ids' => $token,
'data' => array('title'=>'Title',
'body'=>$message['message'],
'image'=>$imagepath,
'priority'=>'high'
)
);
$headers = array(
'Authorization:key=AIzaSyBiOCXbU7roG59_**********vWa4Xc' ,
'Content-Type:application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $path_to_firebase_cm);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
curl_close($ch);
return $result;
?>
And response is
stdClass Object
(
[multicast_id] => 8.5168949472892E+18
[success] => 1
[failure] => 0
[canonical_ids] => 0
[results] => Array
(
[0] => stdClass Object
(
[message_id] => 0:1493801065120413%2d69fd2bf9fd7ecd
)
)
)
Delete app from iphone and install again, After that you will get new firebase token try to send push again.
Debug this first from php side they are sending push on newer device token.

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

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

Goo.gl URL Shortener Stopped Working (php/curl)

For some reason my script stopped working today. When I look in the API control panel says I still have 100% left of usage. Any ideas? Did they change the auth way?
function url_small($url)
{
//This is the URL you want to shorten
$longUrl = $url;
$apiKey = '#####HIDDEN######';
//Get API key from : http://code.google.com/apis/console/
$postData = array('longUrl' => $longUrl, 'key' => $apiKey);
$jsonData = json_encode($postData);
$curlObj = curl_init();
curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url');
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlObj, CURLOPT_HEADER, 0);
curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
curl_setopt($curlObj, CURLOPT_POST, 1);
curl_setopt($curlObj, CURLOPT_POSTFIELDS, $jsonData);
$response = curl_exec($curlObj);
//change the response json string to object
$json = json_decode($response);
curl_close($curlObj);
return $json->id;
}
Response
stdClass Object
(
[error] => stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[domain] => usageLimits
[reason] => dailyLimitExceededUnreg
[message] => Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.
[extendedHelp] => https://code.google.com/apis/console
)
)
[code] => 403
[message] => Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.
)
)
My below answer is no longer valid. Google now makes you use Firebase for URL Shortening. Easy to setup.
https://firebase.google.com/docs/dynamic-links/rest
So it turns out this old function that is displayed in multiple websites now needs the api key to be displayed in the URL section too for google to register the request to your account.
curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url');
switched to this
curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url?key='.$apiKey);

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?

Categories