コード例 #1
0
        public async Task <Result> UpdateAsync(PaymentSource paymentSource, CancellationToken cancellationToken)
        {
            var model = await context.PaymentSources.FindAsync(new object[] { paymentSource.Id }, cancellationToken);

            model.UpdateFrom(paymentSource);
            return(await context.SaveChangesWithResultAsync(cancellationToken));
        }
コード例 #2
0
        public async Task <Result> AddAsync(PaymentSource paymentSource, CancellationToken cancellationToken)
        {
            var model = DbPaymentSource.From(paymentSource);

            context.PaymentSources.Add(model);
            return(await context.SaveChangesWithResultAsync(cancellationToken));
        }
コード例 #3
0
        public string RecordLine()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(recordType); // (2) - static length
            sb.Append(SduBatchId.PadLeft(20, '0'));
            sb.Append(SduTranId);  //(20) - static length
            sb.Append(ReceiptNumber.PadLeft(7, '0'));
            sb.Append(StrRetransmittalIndicator.PadRight(1));
            sb.Append(PayorID.PadRight(13));
            sb.Append(PayorSSN.PadRight(9));
            sb.Append(PaidBy.PadRight(15));
            sb.Append(PayorLastName.PadRight(25));
            sb.Append(PayorFirstName.PadRight(20));
            sb.Append(PayorMiddleName.PadRight(20));
            sb.Append(PayorSuffix.PadRight(3));
            sb.Append(StrAmount.PadLeft(15, '0'));
            sb.Append(StrOfcAmount.PadLeft(15, '0'));
            sb.Append(PaymentMode.PadRight(2));
            sb.Append(PaymentSource.PadRight(4));
            sb.Append(ReceiptReceivedDate.PadRight(8));
            sb.Append(ReceiptEffectiveDate.PadRight(8));
            sb.Append(CheckNumber.PadRight(18));
            sb.Append(ComplianceExemptionReason.PadRight(1));
            sb.Append(TargetedPaymentIndicator.PadRight(1, '0'));
            sb.Append(Fips.PadRight(7));
            sb.Append(CourtCaseNumber.PadRight(25));
            sb.Append(CourtJudgementNumber.PadLeft(3, '0'));
            sb.Append(CourtGuidelineNumber.PadLeft(3, '0'));
            sb.Append(ReasonCode.PadRight(3));
            sb.Append(filler.PadRight(32));

            return(sb.ToString());
        }
コード例 #4
0
ファイル: Test.cs プロジェクト: SaulMunoz/conekta-.net
        public void deletePaymentSource()
        {
            conekta.Api.apiKey  = "key_eYvWV7gSDkNYXsmr";
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
			    ""name"": ""Emiliano Cabrera"",
			    ""phone"": ""+5215544443333"",
			    ""email"": ""*****@*****.**""
			}"            );

            PaymentSource payment_source = customer.createPaymentSource(@"{
			    ""token_id"": ""tok_test_visa_4242"",
			    ""type"": ""card""
			}"            );

            payment_source = payment_source.update(@"{
				""name"": ""Emiliano Suarez""
			}"            );

            Assert.AreEqual(payment_source.name, "Emiliano Suarez");

            payment_source = payment_source.destroy();

            Assert.AreEqual(payment_source.name, "Emiliano Suarez");
        }
コード例 #5
0
        public void createCustomerWithOfflineRecurrentReference()
        {
            getApiKey();
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
                  ""name"": ""Emiliano Cabrera"",
                  ""phone"": ""+5215544443333"",
                  ""email"": ""*****@*****.**"",
                  ""corporate"": true,
                  ""payment_sources"": [{
                    ""expires_at"": 1553273553,
                    ""type"": ""oxxo_recurrent""
                  }]
                  }");

            PaymentSource             paymentSource = customer.payment_sources[0];
            OfflineRecurrentReference reference     = paymentSource as OfflineRecurrentReference;

            Assert.IsNotNull(reference.reference);
            Assert.IsNotNull(reference.barcode);
            Assert.IsNotNull(reference.barcode_url);
            Assert.IsNotNull(reference.provider);
            Assert.AreEqual(reference.expires_at, "1553273553");
        }
コード例 #6
0
        private PaymentSource BuildPaymentSource()
        {
            var paymentSource = new PaymentSource();

            paymentSource.Id          = 1;
            paymentSource.Description = "test description";
            paymentSource.Notes       = "notes for doctype";

            return(paymentSource);
        }
コード例 #7
0
 private TicketPayment(YearId primaryKey, int ticketId, int registerDrawerId,
                       int employeeId, double amount, PaymentSource type, DateTime transactionTime,
                       byte[] serializedCardInfo)
 {
     PrimaryKey         = primaryKey;
     TicketId           = ticketId;
     RegisterDrawerId   = registerDrawerId;
     EmployeeId         = employeeId;
     Amount             = amount;
     PaymentType        = type;
     TransactionTime    = transactionTime;
     SerializedCardInfo = serializedCardInfo;
 }
コード例 #8
0
        public async Task <PaymentSummary> Pay(string reference, PaymentSource payment, FindBookingByReferenceDelegate findBookingByReference)
        {
            TBooking booking = await findBookingByReference(reference);

            if (null == booking)
            {
                throw new NotFoundException();
            }

            if (payment.Amount != 0)
            {
                await _paymentRepository.CreateAsync(booking, payment.Amount);
            }

            return(await _paymentRepository.GetSumOfPaymentsByBookingAsync(booking));
        }
コード例 #9
0
        /// <summary>
        /// Add a new entry to the TicketPayment table
        /// </summary>
        public static TicketPayment Add(YearId ticketPrimaryKey, int registerDrawerId,
                                        int employeeId, double amount, PaymentSource type, CreditCardInfo cardInfo = null)
        {
            TicketPayment result = null;
            DateTime      now    = DateTime.Now;

            byte[] encryptedCardInfo = null;
            if (cardInfo != null)
            {
#if !DEMO
                byte[] decryptedBytes = cardInfo.SerializeObject();
                encryptedCardInfo = AESHelper.Encrypt(decryptedBytes, "ThePriceIsRight");
#else
                encryptedCardInfo = cardInfo.SerializeObject();
#endif
            }

            SqlConnection cn  = GetConnection();
            string        cmd = "AddTicketPayment";
            using (SqlCommand sqlCmd = new SqlCommand(cmd, cn))
            {
                sqlCmd.CommandType = CommandType.StoredProcedure;
                BuildSqlParameter(sqlCmd, "@TicketPaymentYear", SqlDbType.Int, ticketPrimaryKey.Year);
                BuildSqlParameter(sqlCmd, "@TicketPaymentTicketId", SqlDbType.Int, ticketPrimaryKey.Id);
                BuildSqlParameter(sqlCmd, "@TicketPaymentRegisterDrawerId", SqlDbType.Int, registerDrawerId);
                BuildSqlParameter(sqlCmd, "@TicketPaymentEmployeeId", SqlDbType.Int, employeeId);
                BuildSqlParameter(sqlCmd, "@TicketPaymentAmount", SqlDbType.Float, amount);
                BuildSqlParameter(sqlCmd, "@TicketPaymentType", SqlDbType.TinyInt, type);
                BuildSqlParameter(sqlCmd, "@TicketPaymentTime", SqlDbType.DateTime, now);
                BuildSqlParameter(sqlCmd, "@TicketPaymentCardInfo", SqlDbType.VarBinary, encryptedCardInfo);
                BuildSqlParameter(sqlCmd, "@TicketPaymentId", SqlDbType.Int, ParameterDirection.ReturnValue);
                if (sqlCmd.ExecuteNonQuery() > 0)
                {
                    result = new TicketPayment(
                        new YearId(ticketPrimaryKey.Year,
                                   Convert.ToInt32(sqlCmd.Parameters["@TicketPaymentId"].Value)),
                        ticketPrimaryKey.Id, registerDrawerId, employeeId, amount,
                        type, now, encryptedCardInfo);
                }
            }
            FinishedWithConnection(cn);
            return(result);
        }
コード例 #10
0
        private PaymentResult GetMerchantApiResultWithCustomerAndSource(string shopOrderId, double amount, CustomerInfo customerInfo,
                                                                        PaymentSource source = PaymentSource.moto, Boolean callReservationOfFixedAmount = true)
        {
            var sixMonthsFromNowDate = DateTime.Now.AddMonths(6);
            var request = new ReserveRequest {
                Source       = source,
                ShopOrderId  = shopOrderId,
                Terminal     = _testTerminal,
                PaymentType  = AuthType.payment,
                Amount       = Amount.Get(amount, Currency.DKK),
                Pan          = "4111000011110002",
                ExpiryMonth  = sixMonthsFromNowDate.Month,
                ExpiryYear   = sixMonthsFromNowDate.Year,
                Cvc          = "123",
                CustomerInfo = customerInfo,
            };

            return(_api.ReserveAmount(request));            // reservation
        }
コード例 #11
0
ファイル: Test.cs プロジェクト: SaulMunoz/conekta-.net
        public void createPaymentSource()
        {
            conekta.Api.apiKey  = "key_eYvWV7gSDkNYXsmr";
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
			    ""name"": ""Emiliano Cabrera"",
			    ""phone"": ""+5215544443333"",
			    ""email"": ""*****@*****.**"",
			    ""corporate"": true,
			    ""payment_sources"": []
			}"            );

            PaymentSource payment_source = customer.createPaymentSource(@"{
			    ""token_id"": ""tok_test_visa_4242"",
			    ""type"": ""card""
			}"            );

            Assert.AreEqual(payment_source.type, "card");
            Assert.AreEqual(payment_source.name, "Jorge Lopez");
        }
コード例 #12
0
        public async Task <IHttpActionResult> Pay(string reference, PaymentSource payment)
        {
            try
            {
                PaymentSummary summary = await _paymentsController.Pay(reference, payment, _bookingRepository.FindByReferenceAsync);

                if (payment.Amount != 0)
                {
                    _log.Info($"Registered payment of {payment.Amount} kr for booking {reference}.");
                }

                return(Ok(summary));
            }
            catch (NotFoundException)
            {
                return(NotFound());
            }
            catch (Exception ex)
            {
                _log.Error(ex, $"An unexpected exception occurred while creating a payment for the booking with reference {reference}.");
                throw;
            }
        }
コード例 #13
0
        public async Task <IHttpActionResult> Discount(string reference, PaymentSource discount)
        {
            try
            {
                int?amount = await _paymentsController.Discount(reference, discount, _bookingRepository.FindByReferenceAsync, _bookingRepository.UpdateDiscountAsync);

                if (amount.HasValue)
                {
                    _log.Info($"Set discount to {amount.Value}% for booking {reference}.");
                }

                return(Ok());
            }
            catch (NotFoundException)
            {
                return(NotFound());
            }
            catch (Exception ex)
            {
                _log.Error(ex, $"An unexpected exception occurred while updating the discount for the booking with reference {reference}.");
                throw;
            }
        }
コード例 #14
0
        public async Task <int?> Discount(string reference, PaymentSource discount, FindBookingByReferenceDelegate findBookingByReference, UpdateDiscountDelegate updateDiscount)
        {
            TBooking booking = await findBookingByReference(reference);

            if (null == booking)
            {
                throw new NotFoundException();
            }

            int amount = Convert.ToInt32(discount.Amount);

            amount = Math.Max(Math.Min(amount, 100), 0);

            if (amount != booking.Discount)
            {
                booking.Discount = amount;
                await updateDiscount(booking);

                return(amount);
            }

            return(null);
        }
コード例 #15
0
        public void createCustomerWithCard()
        {
            getApiKey();
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
                  ""name"": ""Emiliano Cabrera"",
                  ""phone"": ""+5215544443333"",
                  ""email"": ""*****@*****.**"",
                  ""plan_id"": ""gold-plan"",
                  ""corporate"": true,
                  ""payment_sources"": [{
                      ""token_id"": ""tok_test_visa_4242"",
                      ""type"": ""card""
                  }]
                  }");

            PaymentSource paymentSource = customer.payment_sources[0];

            Card card = paymentSource as Card;

            Assert.AreEqual(customer.corporate, true);
        }
コード例 #16
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (numberEntryControl.FloatValue != null)
     {
         double amount = numberEntryControl.FloatValue.Value;
         if (amount > 0)
         {
             PaymentSource type         = GetPaymentType(sender);
             double        sum          = GetTotalPayments(TicketPayment.GetAll(SelectedTicket.PrimaryKey));
             double        total        = GetTicketTotal();
             double        due          = total - sum;
             double        actualAmount = amount;
             if (amount > due)
             {
                 amount = due;
             }
             TicketPayment.Add(SelectedTicket.PrimaryKey,
                               RegisterManager.ActiveRegisterDrawer.Id,
                               SessionManager.ActiveEmployee.Id, amount, type);
             InitializeTicket();
             if (IsTicketPayed)
             {
                 double amountPaid = sum + actualAmount;
                 double change     = actualAmount - amount;
                 labelAmountPayed.Content    = amountPaid.ToString("C2");
                 labelAmountDueLabel.Content = Types.Strings.ChangeDue;
                 labelAmountDue.Content      = change.ToString("C2");
                 RegisterManager.ActiveRegisterDrawer.AddToCurrentAmount(total);
                 SelectedTicket.SetCloseTime(DateTime.Now);
                 SelectedTicket.Update();
                 RegisterManager.OpenCashDrawer();
             }
         }
         numberEntryControl.FloatValue = null;
     }
 }
コード例 #17
0
        public void deletePaymentSource()
        {
            getApiKey();
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
                  ""name"": ""Emiliano Cabrera"",
                  ""phone"": ""+5215544443333"",
                  ""email"": ""*****@*****.**""
                  }");

            PaymentSource payment_source = customer.CreateCard(@"{
                ""token_id"": ""tok_test_visa_4242"",
                ""type"": ""card""
                }");

            payment_source.destroy();

            Customer customerReloaded = new Customer().find(customer.id);



            Assert.AreEqual(customerReloaded.payment_sources, null);
        }
コード例 #18
0
 public InternalPaymentSource(PaymentSource paymentSource) : this()
 {
     Id   = paymentSource.Id;
     Name = paymentSource.Name;
 }
コード例 #19
0
 public void SetMaxmimumTrasactionAmountEligibleForOffer(PaymentSource paymentSource, int amount)
 {
     _storage.SetMaxmimumTrasactionAmountEligibleForOffer(paymentSource, amount);
 }
コード例 #20
0
 public int GetMaxmimumTrasactionAmountEligibleForOffer(PaymentSource paymentSource)
 {
     return(_storage.GetMaxmimumTrasactionAmountEligibleForOffer(paymentSource));
 }
コード例 #21
0
        public async Task <Result> Handle(AddPaymentSource request, CancellationToken cancellationToken)
        {
            var paymentSource = new PaymentSource(request.Id, request.Name);

            return(await paymentSourceRepository.AddAsync(paymentSource, cancellationToken));
        }
コード例 #22
0
 public IEcommerceService this[PaymentSource source] => _services?.FirstOrDefault(x => x.Source == source);
コード例 #23
0
 public static SomeMoneyIncomeEventArgs Create(PaymentSource source, MoneyNaturalized money)
 => new SomeMoneyIncomeEventArgs
 {
     SomeMoneyIncome = money, Source = source
 };
コード例 #24
0
 public void UpdatePaymentSource(PaymentSource paymentSource)
 {
     _paymentSourceRepository.Update(paymentSource);
 }
コード例 #25
0
 public void AddPaymentSource(PaymentSource paymentSource)
 {
     _paymentSourceRepository.Add(paymentSource);
 }