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.
Related
I am trying to find a flag to determine whether a QuickBooks Customer has new invoices. I am syncing the invoices, and next time when I try to sync I want to check whether there are any new Invoices OR updated once.
There is a syncToken in Customer record but it only shows the updates for the Customer object.
Is there a way to check for the updated Invoices OR New onces, other than syncing all?
The way we handled this is by storing the last sync time. Add the last sync time as a filter to the QuickBooks SDK query object. First time, ALL invoices are synced. During the next sync, the ones that have been created or modified after the last sync time are synced. Here's a C# code sample from a Windows service that we are using:
using QBXMLRP2Lib;
using Interop.QBFC13;
public void SyncTransactions(QBSessionManager sessionMgr, DateTime? fromModifiedDate)
{
IMsgSetRequest msgset = sessionMgr.CreateMsgSetRequest("US", 13, 0);
IInvoiceQuery invoiceQuery = msgset.AppendInvoiceQueryRq();
invoiceQuery.IncludeLineItems.SetValue(true); // true if line items from a transaction have to included in the result set
if (fromModifiedDate != null)
{
invoiceQuery.ORInvoiceQuery.InvoiceFilter.ORDateRangeFilter.ModifiedDateRangeFilter.FromModifiedDate.SetValue(fromModifiedDate.Value, false);
invoiceQuery.ORInvoiceQuery.InvoiceFilter.ORDateRangeFilter.ModifiedDateRangeFilter.FromModifiedDate.SetTimeZone(0, 0); // UTC, since we keep the last sync time in UTC
IMsgSetResponse msgRes = sessionMgr.DoRequests(msgset);
IResponseList responseList = msgRes.ResponseList;
if (responseList.Count > 0)
{
// process the results here
}
}
}
Hope this helps.
I figure it out after #Naveen's Answer.
Basically the syncToken is good to use when we deal with single record at a time. We can keep syncToken in our database and check it against QuickBooks next time.
But when it comes to bulk record fetching its good to use LastUpdatedTime.
To filter invoices what I did was query QuickBooks as below,
$InvoiceService = new QuickBooks_IPP_Service_Invoice();
$invoices = $InvoiceService->query($Context, $realm, "SELECT * FROM Invoice where MetaData.LastUpdatedTime > <date>";
Note: <date> should be in long date format. Ex: 2004-02-12T15:19:21+00:00. We can get this date format by date('c', mySql date);
Cheers..!!! Thanks again #Naveen for your tip
So I'm creating an application that allows users to record a message through Twilio and I'm attempting to store the RecordingSID, the date it was created, and the duration of the recording in a MySQLi database right after the recording has been made. I've managed to get the RecordingSID by taking the last 34 digits off the RecordingURL using the substr() function and am simply getting whatever today's date is for the date created field in my database table. However, seemingly regardless of how long the actual recording is, I'm continually getting a value of 8 when attempting to get the recording duration. Here's what I've got right now (with database inserts omitted since they work):
<?php
$recordingURL = $_REQUEST['RecordingUrl'];
$recordingSID = substr($recordingURL, -34);
date_default_timezone_set('EST');
$dateCreated = date("Y-m-d");
$duration = $_REQUEST['RecordingDuration'];
?>
Any help with this matter would be fantastic! Thanks!
Edit: I've also tried the following solution in place of the last line in my previous code snippet:
<?php
$recordings = $client->account->recordings->getIterator(0, 50, array('Sid' => $recordingSID,));
foreach ($recordings as $recording)
{
$duration = $recording->duration;
}
?>
Based on that code sample you've pasted in, you could be doing a couple of things incorrectly. Correct me if I'm wrong, but I believe you are trying to request a Recording resource back from the Twilio API after you've submitted one with the Twilio js and their TwiML?
If so, twilio actually has a nice little demo of exactly your use case.
You shouldn't see anything in the $_REQUEST['RecordingDuration'], I'm not sure why you are even getting a value of 8 returned. Basically what you want to do is find the users recordings by using the Twilio REST API.
here is an example snippet:
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACda6f132a3c49700934481addd5ce1659";
$token = "{{ auth_token }}";
$client = new Services_Twilio($sid, $token);
// Loop over the list of recordings and echo a property for each one
foreach ($client->account->recordings as $recording) {
echo $recording->duration;
}
The response from the API call will return a Recording resource.
Here is some more examples from their docs
Apologies, since I may not know the terminologies for the salesforce API. I just started programming a connector to interact with salesforce and I am stuck.
I have a requirement, where each time a new entry is added to the Leads section, I will have to retrieve a couple of fields (Firstname and Product Code) and pass it to a different software that makes use of PHP.
<?php
require "conf/config_cleverbridge_connector.inc.php";
require "include/lc_connector.inc.php";
// Start of Main program
// Read basic parameters
if ($LC_Username === "")
{
$LC_Username = readParam("USER");
}
if ($LC_Password === "")
{
$LC_Password = readParam("PASSWORD");
}
$orderID = "";
$customerID = substr(readParam("PURCHASE_ID"), 0, 10);
$comment = readParam("EMAIL")."-".readParam("PURCHASE_ID");
// Create product array
$products = array();
$itemID = readParam("INTERNAL_PRODUCT_ID");
$quantity = 1;
if (!ONCE_PER_PURCHASED_QUANTITY)
{
$quantity = readParam("QUANTITY");
}
// Add product to the product array
$products[] = array (
"itemIdentification" => $itemID,
"quantity" => $quantity,
);
// Create the order
$order = array(
"orderIdentification" => $orderID,
"customerIdentification" => $customerID,
"comment" => $comment,
"product" => $products,
);
// Calling webservice
$ticket = doOrder($LC_Username, $LC_Password, $order);
if ($ticket)
{
Header("HTTP/1.1 200 Ok");
Header("Content-Type: text/plain");
print TICKET_URL.$result->order->ticketIdentification;
exit;
}
else
{
$error = "No result from WSConnector_doOrder";
trigger_error($error, E_USER_WARNING);
printError(500, "Internal Error.");
exit;
}
// End of Main program
?>
Now this is the code that I got and have to work with. And this is hosted on a different remote server.
I am very very new to salesforce and I am not really sure how to trigger calling this php file over a remote site.
The basic idea is:
1. New entry in Lead is created.
2. Immediately 2 fields (custID and prodID) are sent to this PHP file I have pasted above (some of the variables are different)
3. This does its processing and sends 2 fields back to salesforce.
Any help or guidance is appreciated. Even links to read up on is okay as I am completely clueless.
PS: I have another example where it makes use of JSON Messages if that may make any difference.
Thanks
I'll repost the links from my comment :)
https://salesforce.stackexchange.com/questions/23977/is-it-possible-to-get-the-record-id
Web hook in salesforce?
If your PHP endpoint is visible on the open web (not a part of some intranet or just your own localhost) then simplest thing to do would be to send an Outbound Message from Salesforce. No coding required, just some XML document you'll have to parse on the PHP side. Plus it will automatically attempt to resend the messages if the host is unreachable...
If your app can't be accessed from SF servers then I think your PHP app will have to be the "actor". Querying SF every X minutes for new Leads or maybe subscribing to Streaming API... This will mean you'd have to store credentials to SF on your PHP app and remember to either change the password periodically or set on the "integration user"'s profile the "password never expires" checkbox.
So you're getting the notification, you generate your tickets, time to send them back. Will you want to pretend the update of Lead was done by the person that created it or will you want to see "last modified by: Integration User"? Outbound message can contain session id which you can use to act as the person who initiated the action (created the lead and fired the workflow) - at least until they log out or the session timeouts.
For message back you can use SOAP or REST salesforce apis - read the docs to figure out how to send an update command (and if you want to make it clear it was done by special user associated with this PHP app - how to log in to the APIs). I think the user's profile must have "API enabled" ticked before you could reuse somebody's session so maybe it's better to have a dedicated account for integrations like that...
Another thing to keep in mind if it'd be outbound messages is to ignore the messages sent from sandboxes so if somebody makes a test environment you will not call your "production" database of tickets. You can also remember to modify the outbound message and remote site setting every time a sandbox is made so you'll have "prod talking to prod, test talking to test". I know you can include user's session id in the OM - so maybe you can also add organization's id (for production it'll stay the same, every new sandbox will have new id).
The problem with this approach is that it might not scale. If 1000 leads is inserted in one batch (for example with Data Loader) - you'll get spammed with 1000 outbound messages. Your server must be able to handle such load... but it will also mean you're using 1 API request to send every single update back. You can check the limit of API requests in Setup -> Company Information. Developer Edition will have this limit very low, sandboxes are better, production is best (it also depends how many user licenses have you bought). That's why I've asked about some batching them up.
More coding but also more reliable would be to ask SF for changes every X minutes (Streaming API? Normal query? check the "web hook" answer) and send an update of all these records in one go. SELECT Id, Name FROM Lead WHERE Ticket__c = null (note there's nothing about AND LastModifiedDate >= :lastTimeIChecked)...
I am developing a desktop software where it charge user per execution the main action. For example say it will charge user 0.1$ for per PDF print.
and my software provide multithreading. .
so, if it run single thread it works fine :)
but the problem is if user run multiple thread at one (say 10/20 threads)
it (php) also continues user to allow the server/execution even balance get below zero..
though my php script check whether balance is positive ..
but after user run multiple threads balance become like -5.95$ or -25.75$ etc
and that is a big security/financial issue..
here is the code I am using:
<?php
$strSQL = "Select * from users where Email = '$strUser'";
$return = mysql_query($strSQL, $strDBConn);
$strDBData = mysql_fetch_array($return, MYSQL_ASSOC);
//checking balance
$strBalance = $strDBData['Balance'];
if($strBalance < 0)
{
// if balance 0 then exit so, my software/thread will not process further
mysql_close($strDBConn);
exit('Balance Exceed');
}
//rest of the codes that realted to service executaion
// code that substract the balnce
$dblCost = 0.25;
$strSQL = "Update users set Balance = Balance - '$dblCost' where Email = '$strUser'";
$return = mysql_query($strSQL, $strDBConn);
//rest finising codes
?>
any help/suggestion would be highly appreciated..
thanks in advance.
best regards
I think, this is a quite similar question:
What is equivalent of the C# lock statement in PHP?
First, try to switch away from the old "mysql" to somethin new, maybe some PDO like DB access ;).
Then, for getting around with multi-thread in php, it can be a good idea, to write a file for every userid (!) and lock this file, when there's a request. When file is locked in another thread, wait for x seconds for the file to be unlocked by the locker-thread. If it is not unlocked within time, something went wrong. When in locked-thread all went good, unlock the file after every operation needed.
Theoraticaly you will be good with then till there's a multi-thread soloution in PHP ;)
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