Skip to content

Commit

Permalink
Knet Updates. Workflow updates (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko authored Sep 26, 2024
1 parent 2d8116e commit 2d8218f
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 5 deletions.
17 changes: 17 additions & 0 deletions lib/checkout_sdk/payments/payment_method_details.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module CheckoutSdk
module Payments
# @!attribute display_name
# @return [String]
# @!attribute type
# @return [String]
# @!attribute network
# @return [String]
class PaymentMethodDetails
attr_accessor :display_name,
:type,
:network
end
end
end
1 change: 1 addition & 0 deletions lib/checkout_sdk/payments/payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
require 'checkout_sdk/payments/authorization_type'
require 'checkout_sdk/payments/os_type'
require 'checkout_sdk/payments/payment_instruction'
require 'checkout_sdk/payments/payment_method_details'
require 'checkout_sdk/payments/refund_request'
require 'checkout_sdk/payments/product'
require 'checkout_sdk/payments/capture_type'
Expand Down
11 changes: 10 additions & 1 deletion lib/checkout_sdk/payments/previous/source/apm/knet_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ module Payments
# @return [String]
# @!attribute ptlf
# @return [String]
# @!attribute token_type
# @return [String]
# @!attribute token_data
# @return [ApplePayTokenData]
# @!attribute payment_method_details
# @return [PaymentMethodDetails]
class KnetSource < PaymentSource
attr_accessor :language,
:user_defined_field1,
Expand All @@ -27,7 +33,10 @@ class KnetSource < PaymentSource
:user_defined_field4,
:user_defined_field5,
:card_token,
:ptlf
:ptlf,
:token_type,
:token_data,
:payment_method_details

def initialize
super CheckoutSdk::Common::PaymentSourceType::KNET
Expand Down
11 changes: 10 additions & 1 deletion lib/checkout_sdk/payments/source/apm/knet_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ module Payments
# @return [String]
# @!attribute ptlf
# @return [String]
# @!attribute token_type
# @return [String]
# @!attribute token_data
# @return [ApplePayTokenData]
# @!attribute payment_method_details
# @return [PaymentMethodDetails]
class KnetSource < PaymentSource
attr_accessor :language,
:user_defined_field1,
Expand All @@ -26,7 +32,10 @@ class KnetSource < PaymentSource
:user_defined_field4,
:user_defined_field5,
:card_token,
:ptlf
:ptlf,
:token_type,
:token_data,
:payment_method_details

def initialize
super CheckoutSdk::Common::PaymentSourceType::KNET
Expand Down
8 changes: 7 additions & 1 deletion lib/checkout_sdk/workflows/patch_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ module Workflows
# @return [String]
# @!attribute active
# @return [TrueClass, FalseClass]
# @!attribute conditions
# @return [Array(WorkflowCondition)]
# @!attribute actions
# @return [Array(WorkflowAction)]
class PatchWorkflow
attr_accessor :name,
:active
:active,
:conditions,
:actions
end
end
end
9 changes: 8 additions & 1 deletion lib/checkout_sdk/workflows/workflows_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ class WorkflowsClient < Client
REFLOW = 'reflow'
SUBJECT = 'subject'
WORKFLOW_ID = 'workflowId'
TEST = 'test'
private_constant :WORKFLOWS, :WORKFLOW, :ACTIONS, :CONDITIONS, :EVENT_TYPES, :EVENTS, :REFLOW,
:SUBJECT, :WORKFLOW_ID
:SUBJECT, :WORKFLOW_ID, :TEST

# @param [ApiClient] api_client
# @param [CheckoutConfiguration] configuration
Expand Down Expand Up @@ -86,6 +87,12 @@ def remove_workflow_condition(workflow_id, condition_id)
api_client.invoke_delete(build_path(WORKFLOWS, workflow_id, CONDITIONS, condition_id), sdk_authorization)
end

# @param [String] workflow_id
# @param [Hash] event_types_request
def test_workflow(workflow_id, event_types_request)
api_client.invoke_post(build_path(WORKFLOWS, workflow_id, TEST), sdk_authorization, event_types_request)
end

def retrieve_event_types
api_client.invoke_get(build_path(WORKFLOWS, EVENT_TYPES), sdk_authorization)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,14 @@

context 'when requesting Knet source payment' do
it 'requests payment correctly' do
payment_method_details = CheckoutSdk::Payments::PaymentMethodDetails.new
payment_method_details.display_name = "name"
payment_method_details.type = "type"
payment_method_details.network = "card_network"

source = CheckoutSdk::Previous::Payments::KnetSource.new
source.language = 'en'
source.payment_method_details = payment_method_details

request = CheckoutSdk::Previous::Payments::PaymentRequest.new
request.source = source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,14 @@

context 'when requesting Knet source payment' do
it 'raises an error (payee_not_onboarded)' do
payment_method_details = CheckoutSdk::Payments::PaymentMethodDetails.new
payment_method_details.display_name = "name"
payment_method_details.type = "type"
payment_method_details.network = "card_network"

source = CheckoutSdk::Payments::KnetSource.new
source.language = 'en'
source.payment_method_details = payment_method_details

request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
Expand Down
16 changes: 15 additions & 1 deletion spec/checkout_sdk/workflows/workflows_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
end

after(:all) do
#delete_workflow @workflow.id
# delete_workflow @workflow.id
end

describe '.retrieve_workflows' do
Expand Down Expand Up @@ -124,4 +124,18 @@
end
end
end

describe '.test_workflow' do
context 'when having a workflow' do
it 'should test workflow' do
event_types_request = {
"event_types": %w[payment_approved payment_declined card_verification_declined card_verified payment_authorization_incremented payment_authorization_increment_declined payment_capture_declined payment_captured payment_refund_declined payment_refunded payment_void_declined payment_voided dispute_canceled dispute_evidence_required dispute_expired dispute_lost dispute_resolved dispute_won]
}

workflow_response = default_sdk.workflows.test_workflow(@workflow.id, event_types_request)

expect(workflow_response).not_to be_nil
end
end
end
end

0 comments on commit 2d8218f

Please sign in to comment.