public MobilePayPaymentOperations(IOperationList operations, HttpClient client)
        {
            foreach (var httpOperation in operations)
            {
                switch (httpOperation.Rel.Value)
                {
                case PaymentResourceOperations.UpdatePaymentAbort:
                    Abort = async payload => {
                        var requestDto  = new PaymentAbortRequestDto(payload);
                        var responseDto = await client.SendAsJsonAsync <MobilePayPaymentResponseDto>(httpOperation.Method, httpOperation.Href, requestDto);

                        return(new MobilePayPaymentResponse(responseDto, client));
                    };
                    break;

                case PaymentResourceOperations.RedirectAuthorization:
                    RedirectAuthorization = httpOperation;
                    break;

                case PaymentResourceOperations.ViewAuthorization:
                    ViewAuthorization = httpOperation;
                    break;

                case PaymentResourceOperations.CreateCapture:
                    Capture = async payload => {
                        var requestDto  = new MobilePayPaymentCaptureRequestDto(payload);
                        var responseDto = await client.SendAsJsonAsync <CaptureResponseDto>(httpOperation.Method, httpOperation.Href, requestDto);

                        return(new CaptureResponse(responseDto));
                    };
                    break;

                case PaymentResourceOperations.CreateCancellation:
                    Cancel = async payload => {
                        var requestDto = new MobilePayPaymentCancelRequestDto(payload);
                        return(await client.SendAsJsonAsync <CancellationResponse>(httpOperation.Method, httpOperation.Href, requestDto));
                    };
                    break;

                case PaymentResourceOperations.CreateReversal:
                    Reverse = async payload => {
                        var requestDto = new MobilePayPaymentReversalRequestDto(payload);
                        return(await client.SendAsJsonAsync <ReversalResponse>(httpOperation.Method, httpOperation.Href, requestDto));
                    };
                    break;
                }
                Add(httpOperation.Rel, httpOperation);
            }
        }
Пример #2
0
        public SwishPaymentOperations(IOperationList operations, HttpClient client)
        {
            foreach (var httpOperation in operations)
            {
                switch (httpOperation.Rel.Value)
                {
                case PaymentResourceOperations.UpdatePaymentAbort:
                    Abort = async payload => {
                        var payloadDto = new PaymentAbortRequestDto(payload);
                        var dto        = await client.SendAsJsonAsync <SwishPaymentResponseDto>(httpOperation.Method, httpOperation.Href, payloadDto);

                        return(new SwishPaymentResponse(dto, client));
                    };
                    break;

                case PaymentResourceOperations.CreateSale:
                    Sale = async payload => {
                        var payloadDto = new SwishPaymentSaleRequestDto(payload);
                        var dto        = await client.SendAsJsonAsync <SwishPaymentSaleResponseDto>(httpOperation.Method, httpOperation.Href, payloadDto);

                        return(new SwishPaymentSaleResponse(dto.Payment, dto.Sale.Map()));
                    };
                    break;

                case PaymentResourceOperations.RedirectSale:
                    RedirectSale = httpOperation;
                    break;

                case PaymentResourceOperations.ViewSales:
                    ViewSales = httpOperation;
                    break;

                case PaymentResourceOperations.CreateReversal:
                    Reverse = async payload => {
                        var payloadDto = new SwishPaymentReversalRequestDto(payload);
                        var dto        = await client.SendAsJsonAsync <ReversalResponseDto>(httpOperation.Method, httpOperation.Href, payloadDto);

                        return(new ReversalResponse(dto.Payment, dto.Reversal.Map()));
                    };
                    break;

                case PaymentResourceOperations.PaidPayment:
                    PaidPayment = httpOperation;
                    break;
                }
                Add(httpOperation.Rel, httpOperation);
            }
        }
Пример #3
0
        public TrustlyPaymentOperations(IOperationList operations, HttpClient client)
        {
            foreach (var httpOperation in operations)
            {
                switch (httpOperation.Rel.Value)
                {
                case PaymentResourceOperations.RedirectSale:
                    RedirectSale = httpOperation;
                    break;

                case PaymentResourceOperations.ViewSale:
                    ViewSale = httpOperation;
                    break;

                case PaymentResourceOperations.UpdatePaymentAbort:
                    Abort = async payload => {
                        var requestDto = new PaymentAbortRequestDto(payload);
                        var dto        = await client.SendAsJsonAsync <TrustlyPaymentResonseDto>(httpOperation.Method, httpOperation.Href, requestDto);

                        return(new TrustlyPayment(dto.Payment));
                    };
                    break;

                case PaymentResourceOperations.CreateReversal:
                    Reverse = async payload => {
                        var requestDto = new TrustlyPaymentReversalRequestDto(payload);
                        var dto        = await client.SendAsJsonAsync <ReversalResponseDto>(httpOperation.Method, httpOperation.Href, requestDto);

                        return(new ReversalResponse(dto.Payment, dto.Reversal.Map()));
                    };
                    break;

                case PaymentResourceOperations.CreateCancellation:
                    Cancel = async payload => {
                        var requestDto = new TrustlyPaymentCancelRequestDto(payload);
                        var dto        = await client.SendAsJsonAsync <CancellationResponseDto>(httpOperation.Method, httpOperation.Href, requestDto);

                        return(new CancellationResponse(dto.Payment, dto.Cancellation.Map()));
                    };
                    break;
                }
                Add(httpOperation.Rel, httpOperation);
            }
        }
        public InvoicePaymentOperations(IOperationList operations, HttpClient client)
        {
            foreach (var httpOperation in operations)
            {
                switch (httpOperation.Rel.Value)
                {
                case PaymentResourceOperations.UpdatePaymentAbort:
                    Abort = async payload => {
                        var requestDto = new PaymentAbortRequestDto(payload);
                        var dto        = await client.SendAsJsonAsync <InvoicePaymentResponseDto>(httpOperation.Method, httpOperation.Href, requestDto);

                        return(new InvoicePaymentResponse(dto, client));
                    };
                    break;

                case PaymentResourceOperations.RedirectAuthorization:
                    RedirectAuthorization = httpOperation;
                    break;

                case PaymentResourceOperations.ViewAuthorization:
                    ViewAuthorization = httpOperation;
                    break;

                case PaymentResourceOperations.CreateCapture:
                    Capture = async payload => {
                        var requestDto = new InvoicePaymentCaptureRequestDto(payload);
                        var dto        = await client.SendAsJsonAsync <CaptureResponseDto>(httpOperation.Method, httpOperation.Href, requestDto);

                        return(new CaptureResponse(dto));
                    };
                    break;

                case PaymentResourceOperations.CreateCancellation:
                    Cancel = async payload => {
                        var requestDto = new InvoicePaymentCancelRequestDto(payload);
                        var dto        = await client.SendAsJsonAsync <CancellationResponseDto>(httpOperation.Method, httpOperation.Href, requestDto);

                        return(new CancellationResponse(dto.Payment, dto.Cancellation.Map()));
                    };
                    break;

                case PaymentResourceOperations.CreateReversal:
                    Reversal = async payload => {
                        var requestDto = new InvoicePaymentReversalRequestDto(payload);
                        var dto        = await client.SendAsJsonAsync <ReversalResponseDto>(httpOperation.Method, httpOperation.Href, requestDto);

                        return(new ReversalResponse(dto.Payment, dto.Reversal.Map()));
                    };
                    break;

                case PaymentResourceOperations.CreateApprovedLegalAddress:
                    ApprovedLegalAddress = async payload => {
                        var requestDto = new InvoiceApprovedLegalAddressRequestDto(payload);
                        var dto        = await client.SendAsJsonAsync <ApprovedLegalAddressResponseDto>(httpOperation.Method, httpOperation.Href, requestDto);

                        return(new ApprovedLegalAddressResponse(dto.Payment, dto.ApprovedLegalAddress.Map()));
                    };
                    break;

                case PaymentResourceOperations.DirectAuthorization:
                    DirectAuthorization = async payload => {
                        var requestDto = new InvoicePaymentAuthorizationRequestDto(payload);
                        var dto        = await client.SendAsJsonAsync <InvoicePaymentAuthorizationResponseDto>(httpOperation.Method, httpOperation.Href, requestDto);

                        return(new InvoicePaymentAuthorizationResponse(dto.Payment, dto.Map()));
                    };
                    break;
                }
                Add(httpOperation.Rel, httpOperation);
            }
        }