Esempio n. 1
0
        public InvoicePaymentRequest BuildInvoiceRequest()
        {
            var req = new InvoicePaymentRequest(this.operation, this.intent, this.currency, this.prices, this.description, this.userAgent, this.language, this.urls, this.payeeInfo, this.invoiceType);

            req.Payment.Metadata = this.metadata;

            return(req);
        }
        public async Task <IInvoicePaymentResponse> CreateInvoicePayment()
        {
            var totalAmount = this.cartService.CalculateTotal();
            var vatAmount   = new Amount(0);

            try
            {
                var invoiceRequest = new InvoicePaymentRequest(Operation.FinancingConsumer,
                                                               PaymentIntent.Authorization,
                                                               new Currency("SEK"),
                                                               new List <IPrice>(),
                                                               "Test Purchase",
                                                               "useragent",
                                                               new Language("sv-SE"),
                                                               new Urls(this.urls.HostUrls.ToList(), this.urls.CompleteUrl, this.urls.TermsOfServiceUrl)
                {
                    CancelUrl = this.urls.CancelUrl, PaymentUrl = this.urls.PaymentUrl, CallbackUrl = this.urls.CallbackUrl, LogoUrl = this.urls.LogoUrl
                },
                                                               new PayeeInfo(this.payeeInfoOptions.PayeeId, this.payeeInfoOptions.PayeeReference),
                                                               InvoiceType.PayExFinancingSe);
                invoiceRequest.Payment.Prices.Add(new Price(new Amount(totalAmount), PriceType.Invoice, vatAmount));

                var invoicePayment = await this.swedbankPayClient.Payments.InvoicePayments.Create(invoiceRequest);

                this.cartService.PaymentLink      = invoicePayment.Payment.Id.OriginalString;
                this.cartService.Instrument       = PaymentInstrument.Swish;
                this.cartService.PaymentOrderLink = null;
                this.cartService.Update();

                return(invoicePayment);
            }
            catch (Exception ex)
            {
                Debug.Write(ex.Message);
                return(null);
            }
        }
Esempio n. 3
0
 public InvoicePaymentRequestDto(InvoicePaymentRequest paymentRequest)
 {
     Payment = new PaymentRequestDetailsDto(paymentRequest.Payment);
     Invoice = new InvoiceDetailsDto(paymentRequest.Invoice);
 }