Skip to content

Commit

Permalink
Merge pull request #737 from recurly/BB-392
Browse files Browse the repository at this point in the history
Added decline code to transaction error
  • Loading branch information
douglasmiller committed Jan 24, 2023
2 parents ab21659 + 747f298 commit 876113a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Tests/Recurly/Transaction_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function testGetFailedTransaction() {
$this->assertInstanceOf('Recurly_Transaction', $transaction);
$this->assertInstanceOf('Recurly_TransactionError', $transaction->transaction_error);
$this->assertEquals('invalid_card_number', $transaction->transaction_error->error_code);
$this->assertEquals('invalid_number', $transaction->transaction_error->decline_code);
$this->assertEquals('hard', $transaction->transaction_error->error_category);
$this->assertEquals('The credit card number is not valid. The customer needs to try a different number.', $transaction->transaction_error->merchant_message);
$this->assertEquals('Your card number is not valid. Please update your card number.', $transaction->transaction_error->customer_message);
Expand Down
1 change: 1 addition & 0 deletions Tests/fixtures/transactions/show-200-error.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Content-Type: application/xml; charset=utf-8
<refundable type="boolean">true</refundable>
<transaction_error>
<error_code>invalid_card_number</error_code>
<decline_code>invalid_number</decline_code>
<error_category>hard</error_category>
<merchant_message>The credit card number is not valid. The customer needs to try a different number.</merchant_message>
<customer_message>Your card number is not valid. Please update your card number.</customer_message>
Expand Down
7 changes: 6 additions & 1 deletion lib/recurly/transaction_error.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ class Recurly_TransactionError
*/
var $error_code;

/**
* Decline code
*/
var $decline_code;

/**
* Error category
*/
Expand All @@ -33,6 +38,6 @@ class Recurly_TransactionError
var $three_d_secure_action_token_id;

public function __toString() {
return "<Recurly_TransactionError error_code=\"{$this->error_code}\" error_category=\"{$this->error_category}\" customer_message=\"{$this->customer_message}\" transaction_error=\"{$this->merchant_message}\" gateway_error_code=\"{$this->gateway_error_code}\">";
return "<Recurly_TransactionError error_code=\"{$this->error_code}\" decline_code=\"{$this->decline_code}\" error_category=\"{$this->error_category}\" customer_message=\"{$this->customer_message}\" transaction_error=\"{$this->merchant_message}\" gateway_error_code=\"{$this->gateway_error_code}\">";
}
}

0 comments on commit 876113a

Please sign in to comment.