Пример #1
0
        public async Task ShouldCreateWorkflow()
        {
            CreateWorkflowRequest  createWorkflowRequest  = new CreateWorkflowRequest();
            CreateWorkflowResponse createWorkflowResponse = new CreateWorkflowResponse();

            _apiClient.Setup(apiClient =>
                             apiClient.Post <CreateWorkflowResponse>("workflows", _authorization,
                                                                     createWorkflowRequest, CancellationToken.None, null))
            .ReturnsAsync(() => createWorkflowResponse);

            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            var response = await workflowsClient.CreateWorkflow(createWorkflowRequest);

            response.ShouldNotBeNull();
        }
Пример #2
0
        public async Task ShouldFailCreateWorkflow_InvalidParams()
        {
            CreateWorkflowRequest  createWorkflowRequest  = new CreateWorkflowRequest();
            CreateWorkflowResponse createWorkflowResponse = new CreateWorkflowResponse();

            _apiClient.Setup(apiClient =>
                             apiClient.Post <CreateWorkflowResponse>("workflows", _authorization,
                                                                     createWorkflowRequest, CancellationToken.None, null))
            .ReturnsAsync(() => createWorkflowResponse);

            IWorkflowsClient workflowsClient = new WorkflowsClient(_apiClient.Object, _configuration.Object);

            try
            {
                await workflowsClient.CreateWorkflow(null);

                throw new XunitException();
            }
            catch (Exception ex)
            {
                ex.ShouldBeOfType(typeof(CheckoutArgumentException));
                ex.Message.ShouldBe("createWorkflowRequest cannot be null");
            }
        }
Пример #3
0
 public Task <CreateWorkflowResponse> CreateWorkflow(CreateWorkflowRequest createWorkflowRequest)
 {
     CheckoutUtils.ValidateParams("createWorkflowRequest", createWorkflowRequest);
     return(ApiClient.Post <CreateWorkflowResponse>(WorkflowsPath, SdkAuthorization(), createWorkflowRequest));
 }
Пример #4
0
        protected async Task <CreateWorkflowResponse> CreateWorkflow()
        {
            CreateWorkflowRequest createWorkflowRequest = new CreateWorkflowRequest
            {
                Actions =
                    new List <WorkflowActionRequest>
                {
                    new WebhookWorkflowActionRequest
                    {
                        Url       = "https://google.com/fail",
                        Headers   = new Dictionary <string, string>(),
                        Signature = new WebhookSignature
                        {
                            Key = "8V8x0dLK%AyD*DNS8JJr", Method = "HMACSHA256"
                        }
                    }
                },
                Conditions = new List <WorkflowConditionRequest>
                {
                    new EntityWorkflowConditionRequest {
                        Entities = new List <string> {
                            WorkflowEntityId
                        }
                    },
                    new EventWorkflowConditionRequest
                    {
                        Events = new Dictionary <string, ISet <string> >
                        {
                            {
                                "gateway",
                                new HashSet <string>
                                {
                                    "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",
                                new HashSet <string>
                                {
                                    "dispute_canceled",
                                    "dispute_evidence_required",
                                    "dispute_expired",
                                    "dispute_lost",
                                    "dispute_resolved",
                                    "dispute_won"
                                }
                            }
                        }
                    },
                    new ProcessingChannelWorkflowConditionRequest
                    {
                        ProcessingChannels = new List <string> {
                            ProcessingChannelId
                        }
                    }
                },
                Name   = "testing",
                Active = true
            };

            CreateWorkflowResponse response = await DefaultApi.WorkflowsClient().CreateWorkflow(createWorkflowRequest);

            response.ShouldNotBeNull();
            response.Id.ShouldNotBeNull();
            _workflows.Add(response.Id);
            return(response);
        }