Resolved: PayPal Adaptive Payments Authentication failed - php

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!

Related

WHMCS api call "DomainWhois" response status =>"error" instead of "available/unavailable"

I want to check the availability of domain through API. Other api is working perfectly but the "DomainWhois" api is not working as expected.
I have tried the following code which was available at WHMCS.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/includes/api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query(
array(
'action' => 'DomainWhois',
// See https://developers.whmcs.com/api/authentication
'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
'password' => 'SECRET_OR_HASHED_PASSWORD',
'domain' => 'example.com',
'responsetype' => 'json',
)
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);```
I have use the above code with my credentials but got below response for every domain check.
{"result" => "success" "status" => "error" "whois" => ""}

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.

Bitshares API - Create an account under a registrar using PHP

I've been trying to create an account under a registrar account on Bitshares Test Net programatically using Graphene API and its blockchain. I read the API documentation and have concluded that the PHP code bellow is what I need to execute to be able to create a new account.
<?php
$url = 'https://testnet.bitshares.eu/';
$array = array(
'jsonrpc' => '2.0',
'method' => 'register_account',
'params' => array(
'name' => 'NEW_ACCOUNT_NAME',
'owner_key' => 'OWNER_KEY',
'active_key' => 'ACTIVE_KEY',
'registrar_account' => 'REGISTRAR_ACCOUNT',
'referrer_account' => 'REGISTRAR_ACCOUNT',
'referrer_percent' => 1,
'broadcast' => 1
),
'id' => 1
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'GraphenePHP/1.0');
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($array));
$response = curl_exec($ch);
curl_close($ch);
echo '<pre>';
print_r($response);
echo '</pre>';
The code above is not working. Also I am not getting any response. I have a feeling that I am missing something or the value of $url is incorrect.
Please help?
This Bitshares testnet link https://testnet.bitshares.eu/ sometimes does not work.
You can simply use real net or install testnet on your side for this.

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.

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

Categories