-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stripe): Improve support of Indian card (#2690)
- Add new logic for payment from Indian card to support 3DS auth - Send a new webhook when a payment requires a 3DS auth - All Indian payments are done with `off_session: false` - Add a new `provider_payment_data` to support extra informations from providers about the payment
- Loading branch information
Showing
14 changed files
with
303 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module V1 | ||
module Payments | ||
class RequiresActionSerializer < ModelSerializer | ||
def serialize | ||
{ | ||
lago_payable_id: model.payable.id, | ||
lago_customer_id: model.payable.customer.id, | ||
status: model.status, | ||
external_customer_id: model.payable.customer.external_id, | ||
provider_customer_id: options[:provider_customer_id], | ||
payment_provider_code: model.payment_provider.code, | ||
payment_provider_type: model.payment_provider.type, | ||
provider_payment_id: model.provider_payment_id, | ||
next_action: model.provider_payment_data | ||
} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module Webhooks | ||
module Payments | ||
class RequiresActionService < Webhooks::BaseService | ||
private | ||
|
||
def current_organization | ||
@current_organization ||= object.payable.organization | ||
end | ||
|
||
def object_serializer | ||
::V1::Payments::RequiresActionSerializer.new( | ||
object, | ||
root_name: object_type, | ||
provider_customer_id: options[:provider_customer_id] | ||
) | ||
end | ||
|
||
def webhook_type | ||
'payment.requires_action' | ||
end | ||
|
||
def object_type | ||
'payment' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
db/migrate/20241014000100_add_provider_payment_data_to_payments.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddProviderPaymentDataToPayments < ActiveRecord::Migration[7.1] | ||
def change | ||
add_column :payments, :provider_payment_data, :jsonb, default: {} | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
spec/serializers/v1/payments/requires_action_serializer_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe ::V1::Payments::RequiresActionSerializer do | ||
subject(:serializer) { described_class.new(payment, params) } | ||
|
||
let(:payment) { create(:payment, :requires_action) } | ||
let(:params) do | ||
{ | ||
root_name: 'payment', | ||
provider_customer_id: payment.payment_provider_customer.id | ||
} | ||
end | ||
|
||
it 'serializes the object' do | ||
result = JSON.parse(serializer.to_json) | ||
|
||
aggregate_failures do | ||
expect(result['payment']['lago_payable_id']).to eq(payment.payable.id) | ||
expect(result['payment']['lago_customer_id']).to eq(payment.payable.customer.id) | ||
expect(result['payment']['status']).to eq(payment.status) | ||
expect(result['payment']['external_customer_id']).to eq(payment.payable.customer.external_id) | ||
expect(result['payment']['provider_customer_id']).to eq(payment.payment_provider_customer.id) | ||
expect(result['payment']['payment_provider_code']).to eq(payment.payment_provider.code) | ||
expect(result['payment']['payment_provider_type']).to eq(payment.payment_provider.type) | ||
expect(result['payment']['provider_payment_id']).to eq(payment.provider_payment_id) | ||
expect(result['payment']['next_action']).to eq(payment.provider_payment_data) | ||
end | ||
end | ||
end |
Oops, something went wrong.