public async Task ShouldReflowBySubjectAndWorkflow()
        {
            CreateWorkflowResponse createWorkflowResponse = await CreateWorkflow();

            PaymentResponse payment = await MakeCardPayment();

            ReflowResponse reflowResponse = await Retriable(async() => await DefaultApi.WorkflowsClient()
                                                            .ReflowBySubjectAndWorkflow(payment.Id, createWorkflowResponse.Id));

            reflowResponse.ShouldNotBeNull();
        }
        public async Task ShouldReflowByEventAndWorkflow()
        {
            CreateWorkflowResponse createWorkflowResponse = await CreateWorkflow();

            PaymentResponse payment = await MakeCardPayment();

            SubjectEvent paymentApprovedEvent = await Retriable(async() => await GetSubjectEvent(payment.Id));

            ReflowResponse reflowResponse = await Retriable(async() => await DefaultApi.WorkflowsClient()
                                                            .ReflowByEventAndWorkflow(paymentApprovedEvent.Id, createWorkflowResponse.Id));

            reflowResponse.ShouldNotBeNull();
            reflowResponse.HttpStatusCode.ShouldNotBeNull();
            reflowResponse.ResponseHeaders.ShouldNotBeNull();
        }
Пример #3
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();
        }
        public async Task ShouldReflowSubjects()
        {
            CreateWorkflowResponse createWorkflowResponse = await CreateWorkflow();

            PaymentResponse payment = await MakeCardPayment();

            ReflowBySubjectsRequest request = new ReflowBySubjectsRequest
            {
                Subjects = new List <string> {
                    payment.Id
                }, Workflows = new List <string> {
                    createWorkflowResponse.Id
                }
            };

            ReflowResponse reflowResponse =
                await Retriable(async() => await DefaultApi.WorkflowsClient().Reflow(request));

            reflowResponse.ShouldNotBeNull();
            reflowResponse.HttpStatusCode.ShouldNotBeNull();
            reflowResponse.ResponseHeaders.ShouldNotBeNull();
        }
Пример #5
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");
            }
        }
Пример #6
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);
        }