AuthorizeNet / sdk-php

PHP SDK for Authorize.Net API
Other
430 stars 403 forks source link

Refund Unsettled Transactions #354

Open suneel11 opened 5 years ago

suneel11 commented 5 years ago

Hello, can anyone help me with the issue for how can I refund the unsettled transactions which are not currently refundable. Or the void can help me to refund back the amount charged for particular transaction. Please help me with that as I am making the payment from the card and I want to refund the amount even when the transaction is unsettled.

Thanks.

gnongsie commented 5 years ago

Hi @suneel11 ,

Thanks for reaching out to us.

After you've made a transaction, the transaction can be in Unsettled or Settled state.

For canceling an Unsettled transaction, you can void it. This can be done in one of three ways:

For canceling a Settled transaction, you can refund it. This can be done in one of three ways:

Kindly let us know if you need further information.

suneel11 commented 5 years ago

I am getting an issue with the settled transactions for the refund while sending the transaction id in refTransID, please check and help me with the issue:

[0] => net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType Object (

   [errorCode:net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType:private] => 54                      
   [errorText:net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType:private] => The referenced transaction does not meet the criteria for issuing a credit.

)

Thanks.

gnongsie commented 5 years ago

Hi @suneel11 ,

Well, error code 54 can have different reasons (Error Response 54). Are you sure the transaction ID you placed in the refTransId is the same transaction ID you got from our servers?

Or maybe the transaction has not been settled yet? I would need to understand the timeline for your requests to check if the transaction has settled or not.

suneel11 commented 5 years ago

The status for the transaction is settled payment and its money has been settled. And the transaction is generated from your servers only i.e: 11 digit number. Everything is good just the refund api is creating the problem while refunding settled transaction.

gnongsie commented 5 years ago

Is it possible to share the request sent for RefundTransaction API ? You can hide all sensitive information, like credit card information, dates, keys, etc.

suneel11 commented 5 years ago

Here it is, I am working with the laravel framework

$merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(env("ANET_LOGIN_KEY")); $merchantAuthentication->setTransactionKey(env("ANET_TRANSACTION_KEY"));

$refId = 'ref' . time();

$creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber($cardNo); $creditCard->setExpirationDate($expDate); $payOne = new AnetAPI\PaymentType(); $payOne->setCreditCard($creditCard);

$tranRequest = new AnetAPI\TransactionRequestType(); $tranRequest->setTransactionType( "refundTransaction"); $tranRequest->setAmount('5.00'); $tranRequest->setPayment($payOne); $tranRequest->setRefTransId($t_tranId);

$req = new AnetAPI\CreateTransactionRequest(); $req->setMerchantAuthentication($merchantAuthentication); $req->setRefId($refId); $req->setTransactionRequest( $tranRequest); $contr = new AnetController\CreateTransactionController($req); $respo = $contr->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::PRODUCTION);

Thanks

gnongsie commented 5 years ago

This seems correct. Perhaps there's something wrong with the original transaction. Is it possible to share the transaction details of the original transaction? If you want a secure way of sending, please feel free to send it to my personal email: jus4me2009@gmail.com.

ashtru commented 5 years ago

Hi @suneel11

Can you help me with a few questions:

  1. How are you getting the value of $cardNo and $expDate
    • For card number, is it the last 4 digits, or the entire card number?
    • What is the format for the expiration date YYMM or YYYY-MM?
suneel11 commented 5 years ago

Hello @ashtru

I am using the values in this format: $cardNo = '4242424242424242' $expDate = YYYY-MM format (2022-11)

Even if I am using the 4 digits card number and date with YYMM format then also it is providing me the same issue.

Thanks.

gnongsie commented 5 years ago

Hi @suneel11 ,

From the information you shared, I see that you are using v1.9.6 of the SDK.

The latest stable version is v1.9.9. Is it possible for you to test this out with the latest version?

suneel11 commented 5 years ago

Does the old version do not support the refund api and if so then how it can be done in the older version.

suneel11 commented 5 years ago

hello there is there any help for me regarding that.

kikmak42 commented 5 years ago

Hi @suneel11

If a transaction is in unsettled state you need to do a Void Transaction API request. And if the transaction is in settled state you need to do a Refund Transaction API request.

As per your original issue you were trying to do a refund of a unsettled transaction, hence you were getting Transaction Response Code 54 (the transaction does not meet the criteria). Now the next day the transaction state changed to settled as per your comment, so you will not be able to void it anymore, but you can now call the Refund API till 120 days from the date of settlement.

Hope this resolves your issue.

Kaushik

suneel11 commented 5 years ago

hello But why i am not able to refund the settled transaction whose payment has been done

suneel11 commented 5 years ago

hello @kikmak42

I am still waiting for your reply that why I am not able to refund the transaction whose payment has beed confirmed or has been settled.