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

fix(payment): Fix handling of processing payment #2983

Merged
merged 1 commit into from
Dec 19, 2024
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
2 changes: 1 addition & 1 deletion app/services/invoices/payments/create_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def deliver_error_webhook(payment_result)

def processing_payment
@processing_payment ||= Payment.find_by(
payable_id: invoice,
payable: invoice,
payment_provider_id: current_payment_provider.id,
payment_provider_customer_id: current_payment_provider_customer.id,
amount_cents: invoice.total_amount_cents,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module PaymentProviders
module Adyen
module Payments
class CreateService < BaseService
PENDING_STATUSES = %w[AuthorisedPending Received].freeze
PROCESSING_STATUSES = %w[AuthorisedPending Received].freeze
SUCCESS_STATUSES = %w[Authorised SentForSettle SettleScheduled Settled Refunded].freeze
FAILED_STATUSES = %w[Cancelled CaptureFailed Error Expired Refused].freeze

Expand Down Expand Up @@ -107,7 +107,7 @@ def payment_params
end

def payment_status_mapping(payment_status)
return :pending if PENDING_STATUSES.include?(payment_status)
return :processing if PROCESSING_STATUSES.include?(payment_status)
return :succeeded if SUCCESS_STATUSES.include?(payment_status)
return :failed if FAILED_STATUSES.include?(payment_status)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def initialize(payment:)
super
end

PENDING_STATUSES = %w[pending_customer_approval pending_submission submitted confirmed]
PROCESSING_STATUSES = %w[pending_customer_approval pending_submission submitted confirmed]
.freeze
SUCCESS_STATUSES = %w[paid_out].freeze
FAILED_STATUSES = %w[cancelled customer_approval_denied failed charged_back].freeze
Expand Down Expand Up @@ -99,7 +99,7 @@ def create_gocardless_payment
end

def payment_status_mapping(payment_status)
return :pending if PENDING_STATUSES.include?(payment_status)
return :processing if PROCESSING_STATUSES.include?(payment_status)
return :succeeded if SUCCESS_STATUSES.include?(payment_status)
return :failed if FAILED_STATUSES.include?(payment_status)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module PaymentProviders
module Stripe
module Payments
class CreateService < BaseService
PENDING_STATUSES = %w[processing requires_capture requires_action requires_confirmation requires_payment_method]
PROCESSING_STATUSES = %w[processing requires_capture requires_action requires_confirmation requires_payment_method]
.freeze
SUCCESS_STATUSES = %w[succeeded].freeze
FAILED_STATUSES = %w[canceled].freeze
Expand Down Expand Up @@ -59,7 +59,7 @@ def call
delegate :payment_provider, to: :provider_customer

def payment_status_mapping(payment_status)
return :pending if PENDING_STATUSES.include?(payment_status)
return :processing if PROCESSING_STATUSES.include?(payment_status)
return :succeeded if SUCCESS_STATUSES.include?(payment_status)
return :failed if FAILED_STATUSES.include?(payment_status)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
expect(result.payment.amount_cents).to eq(invoice.total_amount_cents)
expect(result.payment.amount_currency).to eq(invoice.currency)
expect(result.payment.status).to eq("processing")
expect(result.payment.payable_payment_status).to eq("pending")
expect(result.payment.payable_payment_status).to eq("processing")

expect(Stripe::PaymentIntent).to have_received(:create)
end
Expand Down
Loading