public async Task CanGetMultiplePaymentActions()
        {
            PaymentRequest <CardSource> paymentRequest  = TestHelper.CreateCardPaymentRequest();
            PaymentResponse             paymentResponse = await _api.Payments.RequestAsync(paymentRequest);

            var captureRequest = new CaptureRequest
            {
                Reference = Guid.NewGuid().ToString()
            };
            CaptureResponse captureResponse = await _api.Payments.CaptureAsync(paymentResponse.Payment.Id, captureRequest);

            IEnumerable <PaymentAction> actionsResponse = await _api.Payments.GetActionsAsync(paymentResponse.Payment.Id);

            actionsResponse.ShouldNotBeNull();

            PaymentAction authorizationPaymentAction = actionsResponse.SingleOrDefault(a => a.Type == ActionType.Authorization);

            authorizationPaymentAction.ShouldNotBeNull();
            authorizationPaymentAction.Id.ShouldBe(paymentResponse.Payment.ActionId);

            PaymentAction capturePaymentAction = actionsResponse.SingleOrDefault(a => a.Type == ActionType.Capture);

            capturePaymentAction.ShouldNotBeNull();
            capturePaymentAction.Id.ShouldBe(captureResponse.ActionId);
            capturePaymentAction.Reference.ShouldBe(captureResponse.Reference);
            capturePaymentAction.Links.ShouldNotBeNull();
        }
        public async Task CanGetPaymentAction()
        {
            PaymentRequest <CardSource> paymentRequest  = TestHelper.CreateCardPaymentRequest();
            PaymentResponse             paymentResponse = await _api.Payments.RequestAsync(paymentRequest);

            IEnumerable <PaymentAction> actionsResponse = await _api.Payments.GetActionsAsync(paymentResponse.Payment.Id);

            actionsResponse.ShouldNotBeNull();
            actionsResponse.ShouldHaveSingleItem();

            PaymentProcessed payment       = paymentResponse.Payment;
            PaymentAction    paymentAction = actionsResponse.SingleOrDefault();

            paymentAction.ShouldNotBeNull();
            paymentAction.Id.ShouldBe(payment.ActionId);
            paymentAction.ProcessedOn.ShouldBeGreaterThanOrEqualTo(payment.ProcessedOn);
            paymentAction.Approved.ShouldBeTrue();
            paymentAction.Approved.ShouldBe(payment.Approved);
            paymentAction.ResponseCode.ShouldBe(payment.ResponseCode);
            paymentAction.ResponseSummary.ShouldBe(payment.ResponseSummary);
            paymentAction.Reference.ShouldBe(payment.Reference);
            paymentAction.AuthCode.ShouldBe(payment.AuthCode);
            paymentAction.Type.ShouldBe(ActionType.Authorization);
            paymentAction.Links.ShouldNotBeNull();
        }
        public async Task CanGetPaymentActionMetadata()
        {
            PaymentRequest <CardSource> paymentRequest = TestHelper.CreateCardPaymentRequest();
            var metadata = new KeyValuePair <string, object>("test", "1234");

            paymentRequest.Metadata.Add(metadata.Key, metadata.Value);
            PaymentResponse paymentResponse = await _api.Payments.RequestAsync(paymentRequest);

            IEnumerable <PaymentAction> actionsResponse = await _api.Payments.GetActionsAsync(paymentResponse.Payment.Id);

            actionsResponse.ShouldNotBeNull();

            PaymentAction paymentAction = actionsResponse.FirstOrDefault();

            paymentAction.ShouldNotBeNull();
            paymentAction.Metadata.ShouldNotBeNull();
            paymentAction.Metadata.ShouldNotBeEmpty();
            paymentAction.Metadata.ShouldHaveSingleItem();
            paymentAction.Metadata.ShouldContain(d => d.Key == metadata.Key && d.Value.Equals(metadata.Value));
        }