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)); }
public async Task <Result> AddAsync(PaymentSource paymentSource, CancellationToken cancellationToken) { var model = DbPaymentSource.From(paymentSource); context.PaymentSources.Add(model); return(await context.SaveChangesWithResultAsync(cancellationToken)); }
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()); }
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"); }
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"); }
private PaymentSource BuildPaymentSource() { var paymentSource = new PaymentSource(); paymentSource.Id = 1; paymentSource.Description = "test description"; paymentSource.Notes = "notes for doctype"; return(paymentSource); }
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; }
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)); }
/// <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); }
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 }
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"); }
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; } }
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; } }
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); }
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); }
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; } }
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); }
public InternalPaymentSource(PaymentSource paymentSource) : this() { Id = paymentSource.Id; Name = paymentSource.Name; }
public void SetMaxmimumTrasactionAmountEligibleForOffer(PaymentSource paymentSource, int amount) { _storage.SetMaxmimumTrasactionAmountEligibleForOffer(paymentSource, amount); }
public int GetMaxmimumTrasactionAmountEligibleForOffer(PaymentSource paymentSource) { return(_storage.GetMaxmimumTrasactionAmountEligibleForOffer(paymentSource)); }
public async Task <Result> Handle(AddPaymentSource request, CancellationToken cancellationToken) { var paymentSource = new PaymentSource(request.Id, request.Name); return(await paymentSourceRepository.AddAsync(paymentSource, cancellationToken)); }
public IEcommerceService this[PaymentSource source] => _services?.FirstOrDefault(x => x.Source == source);
public static SomeMoneyIncomeEventArgs Create(PaymentSource source, MoneyNaturalized money) => new SomeMoneyIncomeEventArgs { SomeMoneyIncome = money, Source = source };
public void UpdatePaymentSource(PaymentSource paymentSource) { _paymentSourceRepository.Update(paymentSource); }
public void AddPaymentSource(PaymentSource paymentSource) { _paymentSourceRepository.Add(paymentSource); }