Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added decline code to transaction error #737

Merged
merged 1 commit into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}\">";
}
}