PayPal Adaptive Payments - Error 520009 - Account is restricted - api

Apologies in advance if this is a silly question. I did try digging around, but couldn't find an answer.
I'm trying to set up a chained payment (at the sandbox environment), but am getting error 520009 (Account is restricted). Tried several email addresses, and they all give me this error. The email addresses are not registered with Paypal, but as far as I know this shouldn't be an issue as the adaptive payments module doesn't require the receivers to have Paypal accounts in advance (though they will need accounts to actually get the money, of course).
What am I doing wrong?
I did set the fee payer to EACHRECEIVER (as suggested on some threads), but the error remains.
This is what I get back:
ERROR Code: 520009
ERROR Message: Account someone1#gmail.com is restricted
Here's my code:
// Config
$endpoint = trim("https://svcs.sandbox.paypal.com/AdaptivePayments/Pay");
$API_UserName = "MY_USERNAME_FROM_SANDBOX";
$API_Password = "MY_PASSWORD_FROM_SANDBOX";
$API_Signature = "MY_SIGNATURE_FROM_SANDBOX";
$API_AppID = "APP-80W284485P519543T";
$API_RequestFormat = "NV";
$API_ResponseFormat = "NV";
// Create request payload with minimum required parameters
$bodyparams = array (
"requestEnvelope.errorLanguage" => "en_US",
"actionType" => "PAY_PRIMARY",
"cancelUrl" => 'http://www.beta.com/cancel',
"returnUrl" => 'http://www.beta.com/return',
"currencyCode" => 'USD',
"feesPayer" => "EACHRECEIVER",
"actionType" => "PAY_PRIMARY",
"receiverList.receiver[0].email" => 'someone1#gmail.com',
"receiverList.receiver[0].amount" => '10',
"receiverList.receiver[0].primary" => 'true',
"receiverList.receiver[1].email" => 'someone2#gmail.com',
"receiverList.receiver[1].amount" => '5',
"receiverList.receiver[1].primary" => 'false',
);
// Convert payload array into url encoded query string
$body_data = http_build_query($bodyparams, "", chr(38));
try
{
//create request and add headers
$params = array("http" => array(
"method" => "POST",
"content" => $body_data,
"header" =>
"X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
"X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
"X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
"X-PAYPAL-RESPONSE-DATA-FORMAT: " . $API_ResponseFormat . "\r\n"
));
//create stream context
$ctx = stream_context_create($params);
//open the stream and send request
$fp = #fopen($endpoint, "r", false, $ctx);
//get response
$response = stream_get_contents($fp);
//check to see if stream is open
if ($response === false) {
throw new Exception("php error message = " . "$php_errormsg");
}
//close the stream
fclose($fp);
//parse the ap key from the response
$keyArray = explode("&", $response);
foreach ($keyArray as $rVal){
list($qKey, $qVal) = explode ("=", $rVal);
$kArray[$qKey] = $qVal;
}
//print the response to screen for testing purposes
If ( $kArray["responseEnvelope.ack"] == "Success") {
foreach ($kArray as $key =>$value){
echo $key . ": " .$value . "<br/>";
}
}
else {
echo 'ERROR Code: ' . $kArray["error(0).errorId"] . " <br/>";
echo 'ERROR Message: ' . urldecode($kArray["error(0).message"]) . " <br/>";
}
}
catch(Exception $e) {
echo "Message: ||" .$e->getMessage()."||";
}
Thanks!

EDIT: I could solve the problem by removing the "feesPayer" param, which needs to be the default value (i.e., EACHRECEIVER) in case of a unilateral payment.
I'm stuck with this issue, too.
I wonder how I could achieve a "unilateral payment", which is described by PayPal as follows:
You can use the Pay API operation to make unilateral payments under
limited circumstances. A unilateral payment is a payment that is made
to a receiver who does not have a PayPal account. Unilateral payments
can be used with simple or parallel payments that are implicit or
preapproved. Unilateral payments are not designed to be used with
chained payments or payments that require manual approval through the
web flow. When you send a unilateral payment, you send a payment
request that includes an email address for a receiver, and this email
address is not linked to a registered PayPal account. The receiver
receives an email notifying the receiver to create an account and
claim the payment. PayPal holds a payment to a receiver whose email
address is not yet registered or confirmed until the receiver creates
a PayPal account and confirms the email address. If a refund specifies
a receiver whose email address is not yet registered or confirmed, the
payment to the receiver is canceled.
Anyone having an idea what parameter-setting using NVP is required to achieve this without getting ERROR Code: 520009 ERROR Message: Account someone1#gmail.com is restricted
Any hint is highly appreciated!

"but as far as I know this shouldn't be an issue as the adaptive
payments module doesn't require the receivers to have Paypal accounts
in advance "
That's incorrect. For Adaptive Chained Payments, all receivers must have an active and verified Personal, Premier or Business PayPal account.

Related

I want to get recipient_signing_uri from the Docusign API response but it returns null

Here is the code
public function send(Request $request): object
{
$apiClient = new ApiClient();
$apiClient->getOAuth()->setOAuthBasePath(env('DS_AUTH_SERVER'));
try {
$accessToken = $this->getToken($apiClient);
} catch (\Throwable $th) {
return back()->withError($th->getMessage())->withInput();
}
$userInfo = $apiClient->getUserInfo($accessToken);
$accountInfo = $userInfo[0]->getAccounts();
$apiClient->getConfig()->setHost($accountInfo[0]->getBaseUri() . env('DS_ESIGN_URI_SUFFIX'));
$envelopeDefenition = $this->buildEnvelope($request);
try {
$envelopeApi = new EnvelopesApi($apiClient);
$result = $envelopeApi->createEnvelope($accountInfo[0]->getAccountId(), $envelopeDefenition);
dd($result);
} catch (\Throwable $th) {
return back()->withError($th->getMessage())->withInput();
}
return view('backend.response')->with('result', $result);
}
When I print $result variable it returns a response like this
container: array:8 [
"bulk_envelope_status" => null
"envelope_id" => "b634f8c5-96c5-4a18-947f-59418d8c4e03"
"error_details" => null
"recipient_signing_uri" => null
"recipient_signing_uri_error" => null
"status" => "sent"
"status_date_time" => "2023-02-16T07:24:39.1570000Z"
"uri" => "/envelopes/b634f8`your text`c5-96c5-4a18-947f-59418d8c4e03"
]
I want to get the value of recipient signing uri in response but in my case it returns null
How I can achieve this? Will anyone suggests?
createEnvelope creates the envelope. It does not give you an URL for an embedded recipient view (signing ceremony). In order to get that URL, you need to make an additional call to
EnvelopeViews:createRecipient/
See this page for more info.
Also
$apiClient->getConfig()->setHost($accountInfo[0]->getBaseUri() . env('DS_ESIGN_URI_SUFFIX'));
You are using the first entry in the UserInfo returned data's accountInfo array. That's not a good idea. Instead, look for the entry that is the user's default account.
Or if your application is designed to work with a specific eSign account, then make sure the user has access to that account.
It is very common for DocuSign customers to have access to more than one account.

There are no available services for the countries you’ve selected" with CarrierService

I am integrating carrier service API for shopify store. I have partner account and also i have created development store. After installed my app in my store and subscribed carrier service. But in store shipping settings page i got an error
There are no available services for the countries you’ve selected
How to overcome this issue?
I have in the settings page:
My Carrier Service 5588680759
Rate adjustment: 0% + $0.00
There are no available services for the countries you’ve selected.
Automatically offering future shipping services when they become available
Screenshot:
how can i implement on Checkout Page?
I had the same problem and i solved it changing the callback url of the carrier service to public on my shopify application, you have to check if the url is accessible for everyone. (sorry for my english)
Shopify Documentation
You have to define Call url in shipment carries
"callback_url"=> base_url().'shipment/rates'
add these in controller or file which you add in call url
$filename = time();
$input = file_get_contents('php://input');
file_put_contents($filename.'-input', $input);
// parse the request
$rates = json_decode($input, true);
// log the array format for easier interpreting
file_put_contents($filename.'-debug', print_r($rates, true));
// total up the cart quantities for simple rate calculations
$quantity = 0;
foreach($rates['rate']['items'] as $item) {
$quantity =+ $item['quantity'];
}
// use number_format because shopify api expects the price to be "25.00" instead of just "25"
// overnight shipping is 5 per item
$overnight_cost = number_format(5, 2, '', '');
// overnight shipping is 1 to 2 days after today
$on_min_date = date('Y-m-d H:i:s O', strtotime('+1 day'));
$on_max_date = date('Y-m-d H:i:s O', strtotime('+2 days'));
// build the array of line items using the prior values
$output = array('rates' => array(
array(
'service_name' => 'Shipment Local',
'service_code' => 'SL',
'total_price' => $overnight_cost,
'currency' => 'PKR',
'min_delivery_date' => $on_min_date,
'max_delivery_date' => $on_max_date
)
));
// encode into a json response
$json_output = json_encode($output);
// log it so we can debug the response
file_put_contents($filename.'-output', $json_output);
// send it back to shopify
print $json_output;
Change According to you needs

Error Google_Service_BigQueryDataTransfer

I try to work with Google_Service_BigQueryDataTransfer.
I created service account and download json file.
I set GOOGLE_APPLICATION_CREDENTIALS with full path for json file.
I create GoogleClient and Google_Service_BigQueryDataTransfer
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->setScopes(array(
Google_Service_Bigquery::BIGQUERY
)
);
$this->service = new Google_Service_BigQueryDataTransfer($client);
I get list of source
$this->service->projects_dataSources->
listProjectsDataSources('projects/' . self::PROJECT_ID);
it works correctly.
I get list of transfers
$this->service->projects_locations_transferConfigs->
listProjectsLocationsTransferConfigs(
'projects/' . self::PROJECT_ID . '/locations/eu'
);
it also works correctly.
I get credentials
$this->service->projects_locations_dataSources->
checkValidCreds(
'projects/'.self::PROJECT_ID.'/locations/europe/dataSources/adwords',
new Google_Service_BigQueryDataTransfer_CheckValidCredsRequest()
);
or
$this->service->projects_dataSources->checkValidCreds(
'projects/'.self::PROJECT_ID.'/dataSources/adwords',
new Google_Service_BigQueryDataTransfer_CheckValidCredsRequest()
);
both requests return null
object(Google_Service_BigQueryDataTransfer_CheckValidCredsResponse)[174]
public 'hasValidCreds' => null
........
and last i try to create transfer
$params = new Google_Service_BigQueryDataTransfer_TransferConfig();
$params->setDestinationDatasetId('stat');
$params->setDisplayName('ID' . $adword_id);
$params->setDataSourceId(self::DATA_SOURCE_ID);
$params->setDataRefreshWindowDays(10);
$params->setDisabled(false);
$params->setParams( ['customer_id'=> (string)$adword_id]);
return $this->service->projects_locations_transferConfigs->create(
$this->getParent(). '/locations/europe',
$params
);
and have error
Google_Service_Exception: {
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"errors": [
{
"message": "Request contains an invalid argument.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
I had this error from page
https://cloud.google.com/bigquery/docs/reference/datatransfer/rest/v1/projects.transferConfigs/create
when hadn't access to bigquery.
Now i use service account and can list dataSource and transfers, but can't create datatransfer.
Can you say, what i do is wrong?
work code
$this->client = new Google_Client();
$this->client->useApplicationDefaultCredentials();
$this->client->setAuthConfig('client_secret.json');
$this->client->setAccessType("offline");
$this->client->setIncludeGrantedScopes(true);
$this->client->setScopes(array(
Google_Service_Bigquery::BIGQUERY,
ADWORDS_SCOPE
)
);
$this->client->setRedirectUri(self::REDIRECT_URI);
$url = $this->getAuthUrl();
header('Location: ' . filter_var($url, FILTER_SANITIZE_URL));
after i authorize in google and give access.
I redirect to code
$this->client = new Google_Client();
$this->client->useApplicationDefaultCredentials();
$this->client->setAuthConfig( MCC_DIR . 'protected/config/client_secret.json');
$this->client->setAccessType("offline");
$this->client->setIncludeGrantedScopes(true);
$this->client->setScopes(array(
Google_Service_Bigquery::BIGQUERY,
ADWORDS_SCOPE
)
);
$this->client->setRedirectUri(self::REDIRECT_URI);
$code = $_GET['code'];
$this->client->authenticate($code);
$tokken = $this->client->getAccessToken();
$this->client->setAccessToken($tokken);
$this->service = new Google_Service_BigQueryDataTransfer($this->client);
$this->service->projects_locations_dataSources->checkValidCreds(
'projects/1069829667403/locations/europe/dataSources/adwords',
new Google_Service_BigQueryDataTransfer_CheckValidCredsRequest()
);
and all works
The default application credentials are insufficient for using BugQuery TransferConfig service (note that unless $response->hasValidCreds is true, the creds are invalid).
Please consider Using OAuth 2.0 for Web Server Applications.
Right code.
You need create OAuth client ID with other type.
Download json credentials.
Get refresh token.
const BQ_API_SCOPE = Google_Service_Bigquery::BIGQUERY.' '.Google_Service_Bigquery::CLOUD_PLATFORM;
const REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
//....
$scopes = self::BQ_API_SCOPE;
$oauth2 = new OAuth2([
'authorizationUri' => self::AUTHORIZATION_URI,
'redirectUri' => self::REDIRECT_URI,
'tokenCredentialUri' => CredentialsLoader::TOKEN_CREDENTIAL_URI,
'clientId' => $clientId,
'clientSecret' => $clientSecret,
'scope' => $scopes
]);
echo $oauth2->buildFullAuthorizationUri();
$stdin = fopen('php://stdin', 'r');
print'After approving the application, enter the authorization code here: ';
$code = trim(fgets($stdin));
fclose($stdin);
print "\n";
$oauth2->setCode($code);
$authToken = $oauth2->fetchAuthToken();
printf("Your refresh token is: %s\n\n", $authToken['refresh_token']);
Create service with google client use REFRESH_TOKKEN from 3
$client = new Google_Client();
$client->setAuthConfig('client_secret.json');
$client->setAccessType('offline');
$client->setIncludeGrantedScopes(true);
$client->setScopes(array(
Google_Service_Bigquery::BIGQUERY,
Google_Service_Bigquery::CLOUD_PLATFORM,
Google_Service_Bigquery::CLOUD_PLATFORM_READ_ONLY
)
);
if (file_exists(self::ACCESS_TOKKEN_FILE)){
$tokken = file_get_contents(self::ACCESS_TOKKEN_FILE);
$client->setAccessToken($tokken);
if ($client->isAccessTokenExpired()) {
$tokken = $client->fetchAccessTokenWithRefreshToken(REFRESH_TOKKEN);
file_put_contents(self::ACCESS_TOKKEN_FILE, json_encode($tokken));
}
}else{
$tokken = $client->fetchAccessTokenWithRefreshToken(REFRESH_TOKKEN);
file_put_contents(self::ACCESS_TOKKEN_FILE, json_encode($tokken));
}
$this->service = new Google_Service_BigQueryDataTransfer($client);

How to get top 10 videos from your channel with the views count included in the response

So I have a ouath web app that connects to youtube. I use the youtube analytics calls to get information like number of subscribers from my channel. But right now I try to make a top 10 videos from my channel with the views count for every video included in the response. I use this documentation:
Top videos for subscribed or unsubscribed viewers
My call looks like this:
$command = 'curl -H "Authorization: Bearer ' . $access_token . '" "https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DMINE&start-date=' . date('Y-m-d', strtotime('-31 days')) . '&end-date=' . date('Y-m-d', strtotime('today')). '&metrics=views&dimensions=video&sort=views"';
But I get an error message as a response:
"The query is not supported. Check the documentation at https://developers.google.com/youtube/analytics/v1/available_reports for a list of supported queries."
I also tried this call with YoTube data API:
$videos_url = 'https://www.googleapis.com/youtube/v3/search?part=snippet&forMine=true&order=viewCount&type=video&access_token=' . $access_token;
But it provides this response:
["kind"]=>
string(26) "youtube#searchListResponse"
["etag"]=>
string(57) ""######""
["nextPageToken"]=>
string(112) "#######"
["pageInfo"]=>
object(stdClass)#267 (2) {
["totalResults"]=>
int(1)
["resultsPerPage"]=>
int(5)
}
["items"]=>
array(1) {
[0]=>
object(stdClass)#270 (4) {
["kind"]=>
string(20) "youtube#searchResult"
["etag"]=>
string(57) ""#####""
["id"]=>
object(stdClass)#269 (2) {
["kind"]=>
string(13) "youtube#video"
["videoId"]=>
string(11) "####"
}
["snippet"]=>
object(stdClass)#273 (6) {
["publishedAt"]=>
string(24) "2016-09-14T14:49:49.000Z"
["channelId"]=>
string(24) "#####"
["title"]=>
string(12) "My Slideshow"
["description"]=>
string(87) "I created this video with the YouTube Slideshow Creator (http://www.youtube.com/upload)"
This response provides no views count. I need for every video to get the views count as well.
Any ideas on how to accomplish this? Any help is welcomed! Thank you all for your time!
The issue with your youtube analytics api request is sort parameter. Try using value -views instead of views. You can double check the API link you provided. Also set the max-results
Example URL :
https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3Dmine&start-date=2016-05-01&end-date=2016-09-01&metrics=views&dimensions=video&max-results=10&sort=-views&key={YOUR_API_KEY}

Issue with retrieving Magento Frontend Session

I am trying to retrieve the customer's login status from Flex application using AMF call to the Magento Customer API :
Mage::app('default');
$session = Mage::getSingleton('customer/session', array('name'=>'frontend') );
$sessId= $session->getSessionId();
if($session->isLoggedIn()) {
$name = "Hi ". Mage::getModel('customer/session')->getCustomer()->getName();
return 'true' . $name;
}
else{
return 'false ' . $sessId;
}
Only the PHP session ID is returned:
PHPSESSID=i5s1gcemc6r8uquadc4rsk9ou5
But the user is logged into the below ID
frontend=3qdcimcdp7nq4bi8jlovqmnq61
Let me know if I am missing something here.
Use the following code to get the customer ID
Mage::getSingleton('core/session', array('name' => 'frontend'));
$customer = Mage::getSingleton('customer/session',array('name' => 'frontend'));
echo $customerId = $customer->getCustomer()->getId();