DoExpresscheckout not woking. it gives ACK failure - php

i am creating Expresscheckout API using PAYPAL. Set expresscheckout and get expresscheckout is working properly. i get a tocken and payerid from these two steps. but when i goto DoExpresscheckout it gives me ACK failure.
DoExpressCheckoutPaymentResponseType Object
(
[DoExpressCheckoutPaymentResponseDetails] =>
[FMFDetails] =>
[Timestamp] => 2013-06-10T12:15:02Z
[Ack] => Failure
[CorrelationID] => a88b9b744676a
[Errors] => Array
(
[0] => ErrorType Object
(
[ShortMessage] => This Express Checkout session has expired.
[LongMessage] => This Express Checkout session has expired. Token value is no longer valid.
[ErrorCode] => 10411
[SeverityCode] => Error
[ErrorParameters] =>
)
)
[Version] => 98.0
[Build] => 6341744
)
Does any one have correct code for DoExpresscheckout and what fields are require for make it Sucessful ??

well paypal SDK is extremely simple. first if i were you i would install their example code and make sure it work on your server, from my previous experience there are rare cases where the SDK wont work and have php version issues.
Secondly after you're sure it works on your server, the chart flow is:
step 1.) SetExpressCheckout - with all the required fields like:billing address, products cart total etc...
if that was done correct you'll get a token,
step 2.) GetExpressCheckout - With the previously acquired token you'll do GetExpressCheckout passing the token, if that done correct you'll get:Ack, Token, PayerID, value, currencyID and basically an object that has all the purchase details.
step 3.) DoExpressCheckout - use the acquired fields from 2 to do a DoExpressCheckout as follows:
$path = $pluginfolder.'paypal/lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once('services/PayPalAPIInterfaceService/PayPalAPIInterfaceServiceService.php');
require_once('PPLoggingManager.php');
$logger = new PPLoggingManager('DoExpressCheckout');
$token = urlencode( $getToken );
$payerId = urlencode( $getPayerID);
$paymentAction = urlencode( $paymentType);
$orderTotal = new BasicAmountType();
$orderTotal->currencyID = $getCurrencyID;
$orderTotal->value = $getOrderTotal;
$paymentDetails= new PaymentDetailsType();
$paymentDetails->OrderTotal = $orderTotal;
if(isset($notifyURL))
{
$paymentDetails->NotifyURL = $notifyURL;
}
$DoECRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
$DoECRequestDetails->PayerID = $payerId;
$DoECRequestDetails->Token = $token;
$DoECRequestDetails->PaymentAction = $paymentAction;
$DoECRequestDetails->PaymentDetails[0] = $paymentDetails;
$DoECRequest = new DoExpressCheckoutPaymentRequestType();
$DoECRequest->DoExpressCheckoutPaymentRequestDetails = $DoECRequestDetails;
$DoECReq = new DoExpressCheckoutPaymentReq();
$DoECReq->DoExpressCheckoutPaymentRequest = $DoECRequest;
/*
* Trying to go a head with the payment and catching errors that might occure.
*/
try {
/* wrap API method calls on the service object with a try catch */
$DoECResponse = $paypalService->DoExpressCheckoutPayment($DoECReq);
} catch (Exception $ex) {
if(isset($ex)) {
$ex_message = $ex->getMessage();
$ex_type = get_class($ex);
if($ex instanceof PPConnectionException) {
$error[] = "Error connecting to " . $ex->getUrl();
$errorCheck = true;
} else if($ex instanceof PPMissingCredentialException || $ex instanceof PPInvalidCredentialException) {
$error[] = $ex->errorMessage();
$errorCheck = true;
} else if($ex instanceof PPConfigurationException) {
$error[] = "Invalid configuration. Please check your configuration file";
$errorCheck = true;
}
}
}
i hope that helps.

Related

Sending bitcoin outside using coinbase php library returns 422::Invalid amount

I was trying to send 0.0001 bitcoins to external BTC address using coinbase php library. I have CodeIgniter based website and generating bitcoin addresses, retrieving balances are working fine. but somehow I cant seem to make coin withdrawal work. Below is my code.
$configuration = \Coinbase\Wallet\Configuration::apiKey($apiKey, $apiSecret);
$client = Coinbase\Wallet\Client::create($configuration);
$accountId = $this->getCoinbaseAccountid($coinid);
$account = $client->getAccount($accountId);
$coinsymbol = $this->CI->common_library->getCoinSymbol($coinid);//returns BTC
$withdrawAmount = new Coinbase\Wallet\Value\Money($amountTosend, $coinsymbol);
$transaction = Coinbase\Wallet\Resource\Transaction::send([
'toBitcoinAddress' => $sendtoAddress,
'amount' => $withdrawAmount,
'description' => $comment,
'fee' => '0.00005' // only required for transactions under BTC0.0001
]);
try {
$response = $client->createAccountTransaction($account, $transaction);
} catch (Coinbase\Wallet\Exception\HttpException $ex) {
$error = $ex->getResponse()->getStatusCode() . '::' . $ex->getError();
$errorcase = 1;
$this->log_ipn_results(FALSE, $error);
}
In my log file, I get below error. I still unable to find this error even after searching.
422::Invalid amount
The minimum withdrawal amount is higher than 0.0001 BTC.

Authorize PHP API Charge Credit Card Example returns empty response

I am using the php example from the authorize.net website, but cannot get it to work. I have already downloaded all of the vendor software and updated composer.
In the phplog I keep getting the same error:
<code>E00045</code>
<text>The root node does not reference a valid XML namespace.</text>
</message></messages></ErrorResponse>
After updating composer errors are no longer being logged.
My php:
require("anetsdkphp/autoload.php");
$logName = "MYAUTHKEY";
$transKey = "MYTRANSKEY";
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
define("AUTHORIZENET_LOG_FILE", "phplog");
function chargeCreditCard($amount){
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName($logName);
$merchantAuthentication->setTransactionKey($transKey);
$refId = 'ref' . time();
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber(4111111111111111);
$creditCard->setExpirationDate(1238);
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
//create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType( "authCaptureTransaction");
$transactionRequestType->setAmount($amount);
$transactionRequestType->setPayment($paymentOne);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$request->setTransactionRequest($transactionRequestType);
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
#$result = str_replace(' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"',
'', $result);
if ($response != null)
{
$tresponse = $response->getTransactionResponse();
if (($tresponse != null) && ($tresponse->getResponseCode()=="1") )
{
echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n";
echo "Charge Credit Card TRANS ID : " . $tresponse->getTransId() . "\n";
echo $tresponse->getResponseCode();
}
else
{
echo "Charge Credit Card ERROR : Invalid response\n";
var_dump("$tresponse");
}
}
else
{
echo "Charge Credit card Null response returned";
}
}
chargeCreditCard(55.00);
Response: Charge Credit Card ERROR : Invalid response(0)
Response after updating composer: Charge Credit Card ERROR : Invalid response
Thanks very much in advance!
Your message is a bit old, and I am sure has been resolved. However, the problem is almost definitely your input data. This answer is pretty vague and will not necessarily provide a solution, but it will help you identify the cause.
print_r($response)
You will see the following object representations:
[messages:net\authorize\api\contract\v1\ANetApiResponseType:private] => net\authorize\api\contract\v1\MessagesType Object
(
[resultCode:net\authorize\api\contract\v1\MessagesType:private] => Error
[message:net\authorize\api\contract\v1\MessagesType:private] => Array
(
[0] => net\authorize\api\contract\v1\MessagesType\MessageAType Object
(
[code:net\authorize\api\contract\v1\MessagesType\MessageAType:private] => ERROR_CODE_IS_HERE
[text:net\authorize\api\contract\v1\MessagesType\MessageAType:private] => ERROR_MESSAGE_IS_HERE)

PHP MusicBrainz get the first release date

i am trying to get the first release date of a song using Musicbrainz. To get this i am using the mikealmond musicBrainz library.
The problem i have is that when i try to execute exactly the same code as in this example (https://github.com/mikealmond/MusicBrainz/blob/master/examples/first-recording-search.php) i always get an authentication error.
Client error response [status code] 401 [reason phrase] Unauthorized [url] http://musicbrainz.org/ws/2/artist/0383dadf-2a4e-4d10-a46a-e9e041da8eb3?inc=releases+recordings+release-groups+user-ratings&fmt=json
Therefore i tried to add my username and password to the request:
$brainz = new MusicBrainz(new GuzzleHttpAdapter(new Client()),'myusername','mypassword');
$brainz->setUserAgent('myapplicationname', '0.2', 'http://localhost:443/');
If i call the url in the error message manually and enter my username and password i get the array i expect.
I just had a discovery: If I removed -"+ user - ratings"- it does not require authentication.
Therefore i commented the lines with "user - ratings" in my project
Now i think it works, but the performance of the query is very bad and often i get Error 503 // The MusicBrainz web server is currently busy. Please try again later. //
It takes a few seconds just for one song. Does someone know if this is normal or if i still have some kind of mistake?
My code....
//Create new MusicBrainz object
$brainz = new MusicBrainz(new GuzzleHttpAdapter(new Client()), 'username', 'password');
$brainz->setUserAgent('applicationname', '0.2', 'http://localhost:443/');
// set defaults
$artistId = null;
$songId = null;
$lastScore = null;
$firstRecording = array(
'releaseDate' => new DateTime()
);
// Set the search arguments to pass into the RecordingFilter
$args = array(
"recording" => 'we will rock you',
"artist" => 'Queen',
);
try {
// Find all the recordings that match the search and loop through them
$recordings = $brainz->search(new RecordingFilter($args));
$recorings i can print and in the loop i can print each $recording, but the error comes when i extract the informations
/** #var $recording \MusicBrainz\Recording */
foreach ($recordings as $recording) {
// if the recording has a lower score than the previous recording, stop the loop.
// This is because scores less than 100 usually don't match the search well
if (null != $lastScore && $recording->getScore() < $lastScore) {
break;
}
$lastScore = $recording->getScore();
$releaseDates = $recording->getReleaseDates();
$oldestReleaseKey = key($releaseDates);
if (strtoupper($recording->getArtist()->getName()) == strtoupper($args['artist'])
&& $releaseDates[$oldestReleaseKey] < $firstRecording['releaseDate']
) {
$firstRecording = array(
'releaseDate' => $recording->releases[$oldestReleaseKey]->getReleaseDate()
);
}
}
pr($firstRecording);
} catch (Exception $e) {
pr($e->getMessage());
}
$brainz = new MusicBrainz(new GuzzleHttpAdapter(new Client()), 'username', 'password');
You must set your MusicBrainz account credentials. Replace 'username' with your account username, and 'password' with the password used to login to MusicBrainz.org

How to send lead via API to Getresponse

I have a html form where name and email address are getting collected. I try to submit these informations to a GetResponse list using this script:
<?php
function mytheme_save_to_getresponse($form)
{
require_once 'jsonRPCClient.php';
$api_key = 'myAPIkey';
$api_url = 'http://api2.getresponse.com';
$client = new jsonRPCClient($api_url);
$result = NULL;
try {
$result = $client->get_campaigns(
$api_key,
array (
# find by name literally
'name' => array ( 'EQUALS' => 'testlist' )
)
);
}
catch (Exception $e) {
# check for communication and response errors
# implement handling if needed
die($e->getMessage());
}
$campaigns = array_keys($result);
$CAMPAIGN_ID = array_pop($campaigns);
$subscriberEmail = $_GET['email'];
try {
$result = $client->add_contact(
$api_key,
array (
'campaign' => $CAMPAIGN_ID,
'name' => $subscriberName,
'email' => $subscriberEmail,
'cycle_day' => '0'
)
);
}
catch (Exception $e) {
# check for communication and response errors
# implement handling if needed
die($e->getMessage());
}
}
?>
The script doesn't show any errors but GetResponse is not saving the lead to my list. Am I doing something wrong?
Thanks
James
If u are getting a response as [queued]=>1 then your script is working fine..
It will be added to your contact only after a validation/confirmation of entered email
$subscriberEmail will recieve a confirmation email...after the user click on the link contact will get added
This line is wrong:
'name' => $subscriberName,
because you have undefined variable and post it to then GetResponse API 'name' params without value so GetResponse API return Invalid params.
Change to:
$subscriberName => "Some_test_name", // for test only
In this line:
$subscriberEmail = $_GET['email'];
you should set some email in GET table maybe for test just change to:
$subscriberEmail = "test#domain.com"; // or sth like this.
Last idea is var_dump $result variable then you see response from GetResponse API
$result = null; // before try {
var_dump($result); // before end of function } ?>
Your code is looks good and You have to set the call back url for error handling

Update Twitter Status Error

I am updating twitter status using my application and facing a problem.
stdClass Object ( [request] => /1/statuses/update.json [error] => Could not authenticate you. )
But i have authenticate just 2 minutes ago and again its showing same error using code given bellow.
if(strlen($status)>=140)
{
$status = substr($status,0,139);
}
if($E_oauth_token != "" && $E_oauth_token_secret != "")
{
try
{
$twitteroauth = new TwitterOAuth(YOUR_CONSUMER_KEY, YOUR_CONSUMER_SECRET, $E_oauth_token, $E_oauth_token_secret);
$access_token = $twitteroauth->getAccessToken($tweet_verifier);
$params = array('status' => $status);
print_r($twitteroauth->post('statuses/update', $params));
}
catch(exception $e)
{
echo $e;
}
I have found solution for this and explain on this site you can easily check.
There is two types of oauth tokens one is temporary and with that temporary we have to get permanent token explained here Twitter OAuth in PHP.

Categories