I have successful CIM transactions using profileTransAuthCapture, however
I cannot find in the docs if it returns a transaction id. I printed out the response, but I did not see one. In the direct Response there is a long string with random strings in, I'm not sure if one of those is it. Anyone know?
It's the seventh field in that string. To get it just do the following:
$response = explode(',', '1,1,1,This transaction has been approved.,S7GS9X,Y,2195560752,INV000001,description of transaction,10.95,CC,auth_capture,876571,John,Smith,,123 Main Street,Townsville,NJ,12345,,800-555-1234,,user#example.com,John,Smith,,123 Main Street,Townsville,NJ,12345,,1.00,,2.00,FALSE,PONUM000001,209D159CA9DB7377279D33A6A9E9678E,P,2,,,,,,,,,,,XXXX1111,Visa,,,,,,,,,,,,,,,,,18272830,100.0.0.1');
$transactionID = $response[6];
echo $transactionID;
See it in action
Related
hello my bot continue sending message to me.
my code is:
while(true)
{
header('Content-Type: text/html; charset=utf-8');
$token= "MY-TOKEN";
$url= "https://api.telegram.org/bot".$token."/getUpdates";
$update = file_get_contents($url);
$arrayUpdate= json_decode($update, true);
foreach ($arrayUpdate['result'] as $key) {
$chat_id = $key['message']['from']['id'];
$command = $key['message']['text'];
}
if($command == "/start"){
$text= "starting...";
$url= "https://api.telegram.org/bot".$token."/sendMessage?chat_id=".$chat_id."&text=".$text;
file_get_contents($url);
}
}
my bot send me message infinity i want my bot to send me message when i use it then stop and wait for next request.
Your problem is that you put your code that checks for updates in a infinite while loop. So you get infinite messages. To fix that:
Manage "offsets" of updates. Every update has a unique id number called update_id. Every time an update gets received, its update_id equals update_id of the last messages + 1 (Every time an update arrives, its update_id gets increased by one). You can ask bot api to get only updates that has a update_id bigger than or equal what you specify, by passing offset when executing getUpdates:
This is one example, using GET:
api.telegram.org/bot<TOKEN>/getUpdates?offset=<UPDATE_ID>
Save the update_id of the last message you received. Add it by 1. Next time when you ask for updates via getUpdates, pass this new update_id as offset as shown above (or via POST). And api will bring you the next message received. Also, when you use offset to get new messages, old messages get deleted. They can't be obtained using getUpdates.
Process only the last message you receive, not all of them. Currently, you are processing all messages received in one request. But this way you would process old message more than once. So just process the last one and let the api delete the last message for you in each request.
Messages saved in getUpdates queue will eventually get empty as every old message gets deleted in each request. Don't forget to take care about such situation.
More info about getUpdates: API Documentation
The API docs say to set createProfile to true. I can't find an example of this so after searching around I found the setCreateProfile method. I'm using it like this. I get no errors.
$this->custpaymentprofile = new AnetAPI\CustomerProfilePaymentType();
$this->custpaymentprofile->setCreateProfile(true);
What I can't figure out is how to send this setting through the transaction so that a customer profile gets created.
All the other data is sent through AnetAPI\TransactionRequestType()
IE: $this->transactionRequestType->setOrder($this->order);
Everything else works, I can run a successful transaction, just need to get it to create a profile.
Found it:
$profile = new AnetAPI\CustomerProfilePaymentType();
$profile->setCreateProfile(true);
$transactionRequestType->setProfile($profile);
I am successfully using the LinkedIn People Profile API to access for a user, and after the user grants permission, and after exchanging the authentication code for a 60 day access token I can make POST requests and return various profile data.
I'm using PHP based on the sample code at https://developer.linkedin.com/documents/code-samples.
Until now, all my requests have worked. For example, this one works:
$user = fetch('GET', '/v1/people/~:(first-name,last-name,num-connections,headline,industry,specialties,summary,public-profile-url,email-address,interests,publications,languages,skills,three-current-positions,phone-numbers,main-address,twitter-accounts,primary-twitter-account,educations,num-recommenders)');
The fetch function (from the sample code mentioned above) builds the POST request, makes the request and returns the $user object filled with all the data.
However, if I add the following two fields, which are defined as field selectors:
location:(name),location:(country:(code))
so the above statement becomes:
$user = fetch('GET', '/v1/people/~:(first-name,last-name,location:(name),location:(country:(code)),num-connections,headline,industry,specialties,summary,public-profile-url,email-address,interests,publications,languages,skills,three-current-positions,phone-numbers,main-address,twitter-accounts,primary-twitter-account,educations,num-recommenders)');
nothing at all is returned from fetch.
To test, in the fetch function, immediately after the:
$response = file_get_contents($url, false, $context);
statement I added the statement:
print 'response: ' . print_r($response, true);
and in the returned page it just shows "response: " with an empty value - not even an error message.
But if I remove the two field selector fields the request works fine and all the information is returned.
I'm guessing I need to specify those two fields in some different format, but I can't figure out from the docs and examples what that format might be, so I'm hoping somebody here can give me a hint.
I'm also curious why no error is returned - just a blank value. An error message would be useful for debugging.
Thanks,
doug
Sub-fields should be aggregated, e.g.:
location:(name,country:(code))
There should be only one occurrence of location in your query.
If in doubt check your query in LinkedIn REST-console, for your query I got:
<?xml version="1.0" encoding="UTF-8"?>
<error>
<status>400</status>
<timestamp>1422276799156</timestamp>
<request-id>XMQPA0BXDC</request-id>
<error-code>0</error-code>
<message>Duplicate field {location} in inline filter {(first-name,last-name,location:(name),location:(country:(code)),num-connections,headline,industry,specialties,summary,public-profile-url,email-address,interests,publications,languages,skills,three-current-positions,phone-numbers,main-address,twitter-accounts,primary-twitter-account,educations,num-recommenders))}</message>
</error>
which clearly indicates problem.
I have a variable that contains post data:
$ttransid = $_POST["t_transid"];
I then connect to a database and pull info from the row that corresponds with $ttransid.
This works fine.
A paypal transaction is then made, if the payment is successful the database is updated with the payment info - This works.
Now my code tries to update the database and remove stock based on the original $ttransid variable at the beginning.
$querysub = "UPDATE ibn_table SET iname = iname - 1 WHERE itransaction_id='$ttransid'";
if(!mysql_query($querysub))
{
//mysql error..!
}
The database is updated, but only where itransaction_id is blank, suggesting $ttransid is empty. Although it was called and used correctly at the beginning of the code.
Any ideas?
This is because next time your page is hit, the $_POST is empty so there is no $_POST["t_transid"]. So when you assign
$ttransid = $_POST["t_transid"];
It gets empty and update empty string. I suggest you to save that post variable value in your database or in session so you can use that latter.
At starting point before going to the paypal payment page just keep the $transid [Availabe in POST data] in to the session then after payment success, update db with session transid.
After this process just destroy the transid from the session.
Sure it will work.
How Can I find whether the transaction made by user is settled or Unsettled in the authorize.net.I am using AIM.
I want to get through coding.When the transaction is completed and I cant find transaction status.But I want to get whether it goes for settled or unsettled transaction.
Thanks in advance.
You cannot get this information through coding as no API Authorize.Net offers allows for this. It can only be done through the control panel. When you process a transaction and it is approved you can assume the transaction is unsettled. Transactions are settled once per day usually around midnight Pacific Time. After that you can assume a transaction is settled.
As of 03-16-2011 authorize.net has released two new calls to the Transaction Details API, getUnsettledTransactionList and getBatchStatistics.
getUnsettledTransactionList returns up to 1,000 unsettled transactions per call, returning the most recent transactions. The information returned in the response will be the same as what's returned in getTransactionList call.
getBatchStatistics returns the batch stats for a single batch like settlement state and time, charge count, decline count, etc.
For more info, check out the XML guide and the SOAP guide.
At the time of writing the PHP SDK is at version 1.1.6 and does not have this function built into the TD api, however if you look at the documentation provided above, as well as this example page, you will see that getting a list of unsettled transactions is in fact possible.
from this page
I've followed this link http://developer.authorize.net/api/transaction_details/ and get this code from there,
<?php
require_once "anet_php_sdk/AuthorizeNet.php";
define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
// Get Settled Batch List
$request = new AuthorizeNetTD;
$response = $request->getSettledBatchList();
echo count($response->xml->batchList->batch) . " batches\n";
foreach ($response->xml->batchList->batch as $batch) {
echo "Batch ID: " . $batch->batchId . "\n";
}
// Get Transaction Details
$transactionId = "12345";
$response = $request->getTransactionDetails($transactionId);
echo $response->xml->transaction->transactionStatus;
but I m getting this error message.
User authentication failed due to invalid authentication values.
As suggested in #cwd's answer, the most reliable way to know if a transaction is settled is to call getUnsettledTransactionList or getBatchStatistics, but you can also just check what your Transaction Cut-off Time is set to.
Log in to your Authorize.net admin, click Account > Transaction Cut-Off Time
My account is set to 4:00 PM PDT so you can just compare your transaction time to the cut off time. Something like:
$createdTime = new DateTime($charge['createdTime']);
// starting point for settle time
$settleTime = new DateTime($createdTime->format('Y-m-d') . ' 16:00:00');
$now = new DateTime();
// if card was charged after settle time for
// that day, move settle time to the next day
if ($createdTime > $settleTime) {
$settleTime->add(new DateInterval('P1D'));
}
if ($now > $settleTime) $settled = true;
http://developer.authorize.net/api/transaction_details/ is the API you are looking for.