Skip to content

Commit

Permalink
KRED-1648 add new cc error charge not found in find CC charge
Browse files Browse the repository at this point in the history
  • Loading branch information
TjandraD committed Jan 13, 2025
1 parent 2d69a47 commit 3e34f0c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/xendit_api/errors/credit_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module CreditCard
class ResponseError < XenditApi::Errors::ResponseError; end

class ChargeError < ResponseError; end
class CreditCardChargeNotFoundError < ResponseError; end

class CardDeclined < ResponseError
def message
Expand Down
2 changes: 2 additions & 0 deletions lib/xendit_api/middleware/handle_response_exception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def validate_response(response, env)
# credit cards
when 'INVALID_TOKEN_ID_ERROR'
raise XenditApi::Errors::CreditCard::ChargeError.new(error_message, json_response)
when 'CREDIT_CARD_CHARGE_NOT_FOUND_ERROR'
raise XenditApi::Errors::CreditCard::CreditCardChargeNotFoundError.new(error_message, json_response)
# disbursements
when 'DISBURSEMENT_DESCRIPTION_NOT_FOUND_ERROR'
raise XenditApi::Errors::Disbursement::DescriptionNotFound.new(error_message, json_response)
Expand Down
6 changes: 6 additions & 0 deletions spec/xendit_api/errors/credit_card_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,10 @@
expect(described_class::InvalidCvn.superclass).to eq(XenditApi::Errors::CreditCard::ResponseError)
end
end

describe 'CreditCardChargeNotFoundError' do
it 'is expected parent class' do
expect(described_class::CreditCardChargeNotFoundError.superclass).to eq(XenditApi::Errors::CreditCard::ResponseError)
end
end
end

0 comments on commit 3e34f0c

Please sign in to comment.