How to refund transaction via VBA with Authorize.net? - authorize.net

I'm using VBA in an Access application to pass credit card applications to Authorize.net.
In the Sandbox, when I issue a request and get a response, the response looks like:
1|1|1|This transaction has been approved.|MKCE58|Y|60138643909|06731|Company name|15.00|CC|auth_capture|||||||||||||||||||||||||||P|2|||||||||||XXXX1111|Visa|||||||1UMB1CSPUW5QIHHZIATBZCO||||||||||
Which element of this response string is the value that I must capture and use when issuing a refund of this transaction?
When I attempt to refund the transaction using either the "MKCE58" or "60138643909" as the TransactionID in:
post_string = post_string & "x_trans_id=" & URLEncode(strTransID) & "&"
I get a response of:
"The referenced transaction does not meet the criteria for issuing a credit."
I found a very old post here on SO that indicates that I need to change my account mode from Live to Test, and I did that. But that has not resolved this situation.

It looks like you are using the AIM API, so the seventh value in that pipe delimited field, 60138643909, is the transaction ID which is what you will use to request a refund.
To issue a refund the following criteria must all be met:
The transaction was originally processed and successfully settled through the payment gateway (Authorize.Net).
The transaction is submitted with the valid transaction ID (x_trans_id) of an original,
successfully settled transaction.
The amount being requested for refund is less than or equal to the original settled
amount.
The sum of multiple Credit transactions submitted against the original transaction is less than or equal to the original settled amount.
At least the last four digits of the credit card number (x_card_num) used for the original, successfully settled transaction are submitted. An expiration date is not required.
The transaction is submitted within 120 days of the settlement date of the original transaction.

Related

Stripe Webhooks: Invoice.paid vs Checkout.Session.Completed

I use Stripes' webhooks and want to get notified, if the customer successfully "paid the bill". I came across two webhooks, which in my opinion both could do the job:
Webhook "invoice.paid" - According to Stripe doc: Occurs whenever an invoice payment attempt succeeds or an invoice is marked as paid out-of-band.
Webhook "checkout.session.completed" - According to Stripe doc: Occurs when a Checkout Session has been successfully completed.
My questions are:
I don't understand the second part of the "invoice.paid" webhook: "invoice is marked as paid out-of-band" -> What does "out-of-band" mean? Is this to be considered a successful payment?
Regarding "checkout.session.complete" -> This can also occur, if payment fails - correct?
Which webhooks shall I consider (or are there other webhooks) to see the status "customer paid the bill successfully"?
What is more, I don't really know if disputes should be considered as successful payments or not: On one hand, I get a invoice.paid webhook, on the other hand, I get a charge.dispute.created webhook. geeezus...
I appreciate your help! Thanks.
I don't understand the second part of the "invoice.paid" webhook: "invoice is marked as paid out-of-band" -> What does "out-of-band" mean? Is this to be considered a successful payment?
This is specifically referring to marking an invoice paid out of band (ie, the customer paid you outside of Stripe and you want to mark the Stripe invoice paid without collecting a payment). This will not involve an actual payment, but does transition the invoice to status=paid so this event fires.
Regarding "checkout.session.complete" -> This can also occur, if payment fails - correct?
This event signals only that the Checkout session is complete. Depending on the mode use for Checkout, this may or may not involve a payment. If an immediate payment is expected, the session will only complete if that payment is successful. For example mode=setup or mode=subscription with a free trial will not involve an immediate payment. A subscription with trial, though, will create a $0 invoice and fire invoice.paid.
Which webhooks shall I consider (or are there other webhooks) to see
the status "customer paid the bill successfully"?
This depends on what you mean by "paid" and "bill". If you mean specifically for invoices (whether related to subscriptions or not), then invoice.paid is a good choice. You can then filter for amounts greater than $0 etc to further constrain was "paid" means.
What is more, I don't really know if disputes should be considered as
successful payments or not: On one hand, I get a invoice.paid webhook,
on the other hand, I get a charge.dispute.created webhook.
Disputes are not payments, and should be an entirely separate discussion. You can only have a dispute after a payment. Suggest starting by reading the docs on disputes.
To summarize: What are you really trying to do? These events are related and sometimes overlap, but not always. It highly depends on what you're doing.
What's going on?
When you create a checkout session it will have an id, which you'll store in your database next to the user who started the checkout session.
When you receive an invoice.paid webhook event, it does not have any link back to the checkout session! (so you'll know someone paid, but you won't know who paid!)
checkout.session.completed solves this because it contains the id of the checkout session and the stripe customer id, which allows you to link the two, so you basically have a mapping from your customer ids to stripe's customer ids.
So simply grab the customer id from the checkout.session.completed event and store it in your database next to the relevant user, that way you'll be able to tell which one of your users is paying you when you receive an invoice.paid event!
How can this be implemented?
When a checkout session is started, store the checkout session id next to the user who started the session so you can look it up later
When you see checkout.session.completed, look at the accompanying JSON and take the stripe customer number and store it in your database (e.g. a column like stripe_id in users table). To figure out which of your users it's for, use the checkout session id to look it up in your database (i.e. the data you stored in step 1)
Now that you have the stripe customer id stored in your users table, whenever you see invoice.paid, look at the accompanying JSON, take the stripe customer number, look it up in your users table to find who paid, and update the expiry date of their subscription to 1 month into the future.
That's it!
Also good to know
Both checkout.session.completed and invoice.paid events are triggered when someone new subscribes, and only invoice.paid is triggered each month thereafter (presuming the user had enough funds and didn't cancel)
You can get to the stripe customer number in both webhook events like so (this is ruby, but should be similar with js or python):
payload = request.body.read
data = JSON.parse(payload, symbolize_names: true)
data.object.customer
=> "cus_Lvyv721cJGpYB1"

unsettled transactions to settled transaction in authorize.net

I have successfully charge the customer payment profile. These transactions can be viewed in the unsettled transaction. I want to ask why these not settled automatically.
Because when a user pay the value through his credit card. I want to show that the amount has been deducted and the client has received the payment. Or i have to suppose that unsettled transaction is also a successful case?
Unsettled transactions are successful transactions. Unsettled just means the transactions have not been sent to the bank for settlement which is what starts the process of capturing those funds. This is to allow you the opportunity to void those transactions if necessary.
Settlement happens nightly so those transactions will show as settled within 24 hours of being processed.

How to get a transaction details using invoice number?

We are using authorize.net for payments in our checkout but in some cases we are not getting any response from authorize.net so we are unable to store transaction details in our database and also customers are being charged more than once. So to resolve this we are planning to get the transaction details before sending the payment but we don't have transaction id in our side, so we need a API to get the transaction details using invoice number.
I have searched lot in the API documentation but couldn't able to find it, so any reference might be helpful.
You cannot retrieve transaction information through their API with an invoice number. If you know the dates, and other helpful information about these missing transactions, you can use their Transaction Reporting API to get those day's transaction and retrieve the necessary information that way.
One way to avoid this in the future is to use either Silent Post1 or their new Webhooks API to get notified whenever a payment is made (and any other event you specify).
1 I am the author of that article.

Authorize.net refund process without credit card number

How to refund the amount via authorize.net API using c# without credit card number.
I just want to post only transaction id for refund process.
Is that possible in code level?
When i try to refund without credit card number it shows value as "Credit card number is required.
Thanks in advance.
Use getTransactionDetails to get the payment object and then use it with the transaction id to issue a refund http://developer.authorize.net/api/reference/index.html#payment-transactions-refund-a-transaction
yes this is possible but in different way.
First get the transaction details from transaction id, then get the credit card and expiration date from that transaction details
then use this credit card number which will be 4 digits and expiration date(mask date) and setting the transcation id in refund.
It will works fine.
you can get more details here
http://developer.authorize.net/api/reference/index.html#payment-transactions-refund-a-transaction

How to get the transaction id of a duplicate transaction in authorize.net?

Some time I get duplicate transaction error (error code 11) in authorize.net. How can I get to know the duplicate transaction id so that I can verify it. Or, is there any way to get the transaction id by sending the invoice number or any other parameters? I am using AIM wrapper.
Unfortunately Authorize.Net does not report the ID of the duplicate transaction. The best you can do is get a transaction history and look for a very recent transaction that contains the same payment information. You can use their reporting API and make a call to getUnsettledTransactionListRequest.