-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be2422e
commit 2d6c703
Showing
43 changed files
with
1,445 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mutations | ||
module PaymentProviders | ||
module Cashfree | ||
class Base < BaseMutation | ||
include AuthenticableApiUser | ||
include RequiredOrganization | ||
|
||
def resolve(**args) | ||
result = ::PaymentProviders::CashfreeService | ||
.new(context[:current_user]) | ||
.create_or_update(**args.merge(organization: current_organization)) | ||
|
||
result.success? ? result.cashfree_provider : result_error(result) | ||
end | ||
end | ||
end | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
app/graphql/mutations/payment_providers/cashfree/create.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,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mutations | ||
module PaymentProviders | ||
module Cashfree | ||
class Create < Base | ||
REQUIRED_PERMISSION = 'organization:integrations:create' | ||
|
||
graphql_name 'AddCashfreePaymentProvider' | ||
description 'Add or update Cashfree payment provider' | ||
|
||
input_object_class Types::PaymentProviders::CashfreeInput | ||
|
||
type Types::PaymentProviders::Cashfree | ||
end | ||
end | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
app/graphql/mutations/payment_providers/cashfree/update.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,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mutations | ||
module PaymentProviders | ||
module Cashfree | ||
class Update < Base | ||
REQUIRED_PERMISSION = 'organization:integrations:update' | ||
|
||
graphql_name 'UpdateCashfreePaymentProvider' | ||
description 'Update Cashfree payment provider' | ||
|
||
input_object_class Types::PaymentProviders::UpdateInput | ||
|
||
type Types::PaymentProviders::Cashfree | ||
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
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,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module Types | ||
module PaymentProviders | ||
class Cashfree < Types::BaseObject | ||
graphql_name 'CashfreeProvider' | ||
|
||
field :code, String, null: false | ||
field :id, ID, null: false | ||
field :name, String, null: false | ||
|
||
field :client_id, String, null: true, permission: 'organization:integrations:view' | ||
field :client_secret, String, null: true, permission: 'organization:integrations:view' | ||
field :success_redirect_url, String, null: true, permission: 'organization:integrations:view' | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module Types | ||
module PaymentProviders | ||
class CashfreeInput < BaseInputObject | ||
description 'Cashfree input arguments' | ||
|
||
argument :client_id, String, required: true | ||
argument :client_secret, String, required: true | ||
argument :code, String, required: true | ||
argument :name, String, required: true | ||
argument :success_redirect_url, String, required: false | ||
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,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module Invoices | ||
module Payments | ||
class CashfreeCreateJob < ApplicationJob | ||
queue_as 'providers' | ||
|
||
unique :until_executed | ||
|
||
def perform(invoice) | ||
result = Invoices::Payments::CashfreeService.new(invoice).create | ||
result.raise_if_error! | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module PaymentProviders | ||
module Cashfree | ||
class HandleEventJob < ApplicationJob | ||
queue_as 'providers' | ||
|
||
def perform(event_json:) | ||
result = PaymentProviders::CashfreeService.new.handle_event(event_json:) | ||
result.raise_if_error! | ||
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
31 changes: 31 additions & 0 deletions
31
app/models/payment_provider_customers/cashfree_customer.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 | ||
|
||
module PaymentProviderCustomers | ||
class CashfreeCustomer < BaseCustomer | ||
end | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: payment_provider_customers | ||
# | ||
# id :uuid not null, primary key | ||
# settings :jsonb not null | ||
# type :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# customer_id :uuid not null | ||
# payment_provider_id :uuid | ||
# provider_customer_id :string | ||
# | ||
# Indexes | ||
# | ||
# index_payment_provider_customers_on_customer_id_and_type (customer_id,type) UNIQUE | ||
# index_payment_provider_customers_on_payment_provider_id (payment_provider_id) | ||
# index_payment_provider_customers_on_provider_customer_id (provider_customer_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (customer_id => customers.id) | ||
# fk_rails_... (payment_provider_id => payment_providers.id) | ||
# |
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,39 @@ | ||
# frozen_string_literal: true | ||
|
||
module PaymentProviders | ||
class CashfreeProvider < BaseProvider | ||
SUCCESS_REDIRECT_URL = 'https://cashfree.com/' | ||
API_VERSION = "2023-08-01" | ||
BASE_URL = (Rails.env.production? ? 'https://api.cashfree.com/pg/links' : 'https://sandbox.cashfree.com/pg/links') | ||
|
||
validates :client_id, presence: true | ||
validates :client_secret, presence: true | ||
validates :success_redirect_url, url: true, allow_nil: true, length: {maximum: 1024} | ||
|
||
secrets_accessors :client_id, :client_secret | ||
end | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: payment_providers | ||
# | ||
# id :uuid not null, primary key | ||
# code :string not null | ||
# name :string not null | ||
# secrets :string | ||
# settings :jsonb not null | ||
# type :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# organization_id :uuid not null | ||
# | ||
# Indexes | ||
# | ||
# index_payment_providers_on_code_and_organization_id (code,organization_id) UNIQUE | ||
# index_payment_providers_on_organization_id (organization_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (organization_id => organizations.id) | ||
# |
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
Oops, something went wrong.