Reply
Member
Posts: 3
Registered: ‎01-17-2014
Accepted Solution

How to refund?

We are moving from using Paypal to Autherorize.net and I am looking at the sampel AMI code using the developer account.


<?php
require_once 'AuthorizeNet.php'; // Make sure this path is correct.
$transaction = new AuthorizeNetAIM('xxxxx', 'xxxxxxxxxxxxxxxxxxxx');

$transaction->amount = '5.29';
$transaction->cust_id = '05041234';
$transaction->first_name = 'Jack';
$transaction->last_name = 'Jackson';
$transaction->address = '1234 Main St.';
$transaction->city = 'Fremont';
$transaction->state = 'CA';
$transaction->zip = '94538';
$transaction->card_num = '4007000000027';
$transaction->exp_date = '10/16';

$response = $transaction->authorizeAndCapture();

if ($response->approved) {
  echo "<h1>Success! The test credit card has been charged!</h1>";
  echo "Transaction ID: " . $response->transaction_id;
} else {
  echo $response->error_message;
}

?>

 

Everything works, but how do I do a full or partial refund?

 

I have tried insert

$transaction->type = 'CREDIT'

$transaction->trans_id = 'xxxxxxxxxxxxx'

 

But it just created another transaction.


Accepted Solutions
Solution
Accepted by RichardH (Administrator)
‎08-21-2015 01:58 AM
Member
Posts: 3
Registered: ‎01-17-2014

Re: How to refund?

Ok, I figured out that I also need to include original transaction code as reference and the transaction need to be in 'settledSuccessfully' status in developer account or else it would not work.

View solution in original post


All Replies
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: How to refund?

anet_php_sdk-1.1.8.zip\anet_php_sdk\doc\AIM.markdown

 

there a credit() method

Member
Posts: 3
Registered: ‎01-17-2014

Re: How to refund?

Why I am getting the following error?

I have called $response = $transaction->credit();

and set $transaction->card_num = "0027"; // dummy account

 

AuthorizeNet Error:
                Response Code: 3
                Response Subcode: 1
                Response Reason Code: 6
                Response Reason Text: The credit card number is invalid.

 

But if I change to

 

$transaction->card_num = "4007000000027";

then it works.

 

Will this happend in production environment with readl CC number?

 

 

Solution
Accepted by RichardH (Administrator)
‎08-21-2015 01:58 AM
Member
Posts: 3
Registered: ‎01-17-2014

Re: How to refund?

Ok, I figured out that I also need to include original transaction code as reference and the transaction need to be in 'settledSuccessfully' status in developer account or else it would not work.

Member
Posts: 5
Registered: ‎07-14-2020

Re: How to refund?

Thanks Mate, It also help me Alot :D

Member
Posts: 5
Registered: ‎07-14-2020

Re: How to refund?

Thanks Mate, It also help me Al


@cyang126 wrote:

Ok, I figured out that I also need to include original transaction code as reference and the transaction need to be in 'settledSuccessfully' status in developer account or else it would not work.



ot
:D