public async Task ProcessPayment_DataStoreError() { PaymentResult paymentResult = new PaymentResult() { ExternalPaymentReference = Guid.NewGuid().ToString(), PaymentStatus = PaymentStatus.Approved, PaymentId = Guid.NewGuid().ToString() }; PaymentItem payment = CreateValidPaymentItem(); _mockBank.Setup(x => x.ProcessPaymentAsync(It.IsAny <PaymentItem>())).ReturnsAsync(paymentResult); _mockDataAccess.Setup(x => x.SavePaymentItemAsync(It.IsAny <PaymentItem>())).ReturnsAsync((PaymentItem)null); MerchantId merchantId = new MerchantId() { UUID = Guid.NewGuid().ToString() }; PaymentHelper paymentHelper = new PaymentHelper(_mockLogger.Object, _mockBank.Object, _mockDataAccess.Object); await Assert.ThrowsAsync <ArgumentOutOfRangeException>(() => paymentHelper.ProcessPaymentAsync(merchantId, payment)).ConfigureAwait(false); }
public InventoryMerchantPane(MerchantId id) { var slotSpans = new IUiElement[InventoryHeight]; for (int j = 0; j < InventoryHeight; j++) { var slotsInRow = new IUiElement[InventoryWidth]; for (int i = 0; i < InventoryWidth; i++) { int index = j * InventoryWidth + i; slotsInRow[i] = new LogicalInventorySlot(new InventorySlotId( InventoryType.Merchant, (ushort)id, (ItemSlotId)((int)ItemSlotId.Slot0 + index))); } slotSpans[j] = new HorizontalStack(slotsInRow); } var slotStack = new VerticalStack(slotSpans); var slotHalfFrame = new ButtonFrame(slotStack) { Theme = ButtonTheme.InventoryOuterFrame, Padding = -1 }; var header = new Header(new StringId(AssetType.SystemText, 0, (int)SystemTextId.Shop_Merchant)); var stack = new VerticalStack(header, slotHalfFrame) { Greedy = false }; AttachChild(stack); }
private async Task MakePayment(string orderId, MerchantId merchantId) { _idGenerator.NextPaymentId($"PAY-{orderId}"); Money amount = new Money(1000, Currency.EUR); var paymentRequest = new PaymentRequest(_card, merchantId, amount, orderId); await _paymentGateway.ProcessPaymentRequestAsync(paymentRequest); }
public async Task ProcessPayment_HappyPath() { PaymentResult paymentResult = new PaymentResult() { ExternalPaymentReference = Guid.NewGuid().ToString(), PaymentStatus = PaymentStatus.Approved, PaymentId = Guid.NewGuid().ToString() }; PaymentItem payment = CreateValidPaymentItem(); _mockBank.Setup(x => x.ProcessPaymentAsync(It.IsAny <PaymentItem>())).ReturnsAsync(paymentResult); _mockDataAccess.Setup(x => x.SavePaymentItemAsync(It.IsAny <PaymentItem>())).ReturnsAsync(payment); MerchantId merchantId = new MerchantId() { UUID = Guid.NewGuid().ToString() }; PaymentHelper paymentHelper = new PaymentHelper(_mockLogger.Object, _mockBank.Object, _mockDataAccess.Object); PaymentResult result = await paymentHelper.ProcessPaymentAsync(merchantId, payment).ConfigureAwait(false); Assert.NotNull(result); }
public override int GetHashCode() { int hashCode = 1546864389; if (ClientId != null) { hashCode += ClientId.GetHashCode(); } if (AccessToken != null) { hashCode += AccessToken.GetHashCode(); } if (MerchantId != null) { hashCode += MerchantId.GetHashCode(); } if (RevokeOnlyAccessToken != null) { hashCode += RevokeOnlyAccessToken.GetHashCode(); } return(hashCode); }
public override int GetHashCode() { int hash = 1; if (entityId_ != null) { hash ^= EntityId.GetHashCode(); } if (merchantId_ != null) { hash ^= MerchantId.GetHashCode(); } if (stationId_ != null) { hash ^= StationId.GetHashCode(); } if (Name.Length != 0) { hash ^= Name.GetHashCode(); } if (IpAddress.Length != 0) { hash ^= IpAddress.GetHashCode(); } if (Port != 0) { hash ^= Port.GetHashCode(); } return(hash); }
public PaymentRequest(Card card, MerchantId merchantId, Money amountToCharge, MerchantReference merchantReference = default) { Card = card; MerchantId = merchantId; AmountToCharge = amountToCharge; MerchantReference = merchantReference == default(MerchantReference) ? Option <MerchantReference> .None : Optional(merchantReference); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is V1Refund other && ((Context == null && other.Context == null) || (Context?.Equals(other.Context) == true)) && ((Type == null && other.Type == null) || (Type?.Equals(other.Type) == true)) && ((Reason == null && other.Reason == null) || (Reason?.Equals(other.Reason) == true)) && ((RefundedMoney == null && other.RefundedMoney == null) || (RefundedMoney?.Equals(other.RefundedMoney) == true)) && ((RefundedProcessingFeeMoney == null && other.RefundedProcessingFeeMoney == null) || (RefundedProcessingFeeMoney?.Equals(other.RefundedProcessingFeeMoney) == true)) && ((RefundedTaxMoney == null && other.RefundedTaxMoney == null) || (RefundedTaxMoney?.Equals(other.RefundedTaxMoney) == true)) && ((RefundedAdditiveTaxMoney == null && other.RefundedAdditiveTaxMoney == null) || (RefundedAdditiveTaxMoney?.Equals(other.RefundedAdditiveTaxMoney) == true)) && ((RefundedAdditiveTax == null && other.RefundedAdditiveTax == null) || (RefundedAdditiveTax?.Equals(other.RefundedAdditiveTax) == true)) && ((RefundedInclusiveTaxMoney == null && other.RefundedInclusiveTaxMoney == null) || (RefundedInclusiveTaxMoney?.Equals(other.RefundedInclusiveTaxMoney) == true)) && ((RefundedInclusiveTax == null && other.RefundedInclusiveTax == null) || (RefundedInclusiveTax?.Equals(other.RefundedInclusiveTax) == true)) && ((RefundedTipMoney == null && other.RefundedTipMoney == null) || (RefundedTipMoney?.Equals(other.RefundedTipMoney) == true)) && ((RefundedDiscountMoney == null && other.RefundedDiscountMoney == null) || (RefundedDiscountMoney?.Equals(other.RefundedDiscountMoney) == true)) && ((RefundedSurchargeMoney == null && other.RefundedSurchargeMoney == null) || (RefundedSurchargeMoney?.Equals(other.RefundedSurchargeMoney) == true)) && ((RefundedSurcharges == null && other.RefundedSurcharges == null) || (RefundedSurcharges?.Equals(other.RefundedSurcharges) == true)) && ((CreatedAt == null && other.CreatedAt == null) || (CreatedAt?.Equals(other.CreatedAt) == true)) && ((ProcessedAt == null && other.ProcessedAt == null) || (ProcessedAt?.Equals(other.ProcessedAt) == true)) && ((PaymentId == null && other.PaymentId == null) || (PaymentId?.Equals(other.PaymentId) == true)) && ((MerchantId == null && other.MerchantId == null) || (MerchantId?.Equals(other.MerchantId) == true)) && ((IsExchange == null && other.IsExchange == null) || (IsExchange?.Equals(other.IsExchange) == true))); }
public void MergeFrom(PaymentCardRefund other) { if (other == null) { return; } if (other.entityId_ != null) { if (entityId_ == null) { entityId_ = new global::HOLMS.Types.Money.Cards.Transactions.PaymentCardRefundIndicator(); } EntityId.MergeFrom(other.EntityId); } if (other.merchantId_ != null) { if (merchantId_ == null) { merchantId_ = new global::HOLMS.Types.Money.Cards.CardMerchantIndicator(); } MerchantId.MergeFrom(other.MerchantId); } if (other.refundedAmount_ != null) { if (refundedAmount_ == null) { refundedAmount_ = new global::HOLMS.Types.Primitive.MonetaryAmount(); } RefundedAmount.MergeFrom(other.RefundedAmount); } if (other.HostReferenceNumber.Length != 0) { HostReferenceNumber = other.HostReferenceNumber; } if (other.FolioBookingNumber.Length != 0) { FolioBookingNumber = other.FolioBookingNumber; } if (other.paymentCard_ != null) { if (paymentCard_ == null) { paymentCard_ = new global::HOLMS.Types.Money.Cards.GuestPaymentCard(); } PaymentCard.MergeFrom(other.PaymentCard); } if (other.postedAt_ != null) { if (postedAt_ == null) { postedAt_ = new global::Google.Protobuf.WellKnownTypes.Timestamp(); } PostedAt.MergeFrom(other.PostedAt); } if (other.State != 0) { State = other.State; } }
/// <summary> /// Gets the details of a merchant /// </summary> /// <param name="merchantId">The merchant id</param> /// <returns>merchant object</returns> public async Task <Merchant> GetMerchantByIdAsync(MerchantId merchantId) { await using PaymentControllerDbContext context = DbContextProvider.Create(); Model.Merchant merchant = await context.Merchant.Where(x => x.MerchantId.Equals(merchantId.UUID)).SingleOrDefaultAsync(); return(merchant.ToDto()); }
public void MergeFrom(ClosedMerchantBatch other) { if (other == null) { return; } if (other.entityId_ != null) { if (entityId_ == null) { entityId_ = new global::HOLMS.Types.Money.Cards.Transactions.ClosedMerchantBatchIndicator(); } EntityId.MergeFrom(other.EntityId); } if (other.merchantId_ != null) { if (merchantId_ == null) { merchantId_ = new global::HOLMS.Types.Money.Cards.CardMerchantIndicator(); } MerchantId.MergeFrom(other.MerchantId); } if (other.MerchantName.Length != 0) { MerchantName = other.MerchantName; } if (other.Result != 0) { Result = other.Result; } if (other.ProcessorBatchId != 0) { ProcessorBatchId = other.ProcessorBatchId; } if (other.TransactionCount != 0) { TransactionCount = other.TransactionCount; } if (other.totalAmount_ != null) { if (totalAmount_ == null) { totalAmount_ = new global::HOLMS.Types.Primitive.MonetaryAmount(); } TotalAmount.MergeFrom(other.TotalAmount); } if (other.createdAt_ != null) { if (createdAt_ == null) { createdAt_ = new global::Google.Protobuf.WellKnownTypes.Timestamp(); } CreatedAt.MergeFrom(other.CreatedAt); } captures_.Add(other.captures_); refunds_.Add(other.refunds_); }
/// <summary> /// Gets the details of an individual payment /// </summary> /// <param name="merchantId">The merchant id</param> /// <param name="paymentId">The payment id</param> /// <returns>A paymentItem object</returns> public async Task <PaymentItem> GetPaymentByPaymentId(MerchantId merchantId, PaymentId paymentId) { PaymentItem payment = await DataAccess.GetPaymentByPaymentId(merchantId, paymentId).ConfigureAwait(false); payment.PaymentCard.CardNumber = "**** **** **** ****"; payment.PaymentCard.Cvv = 000; return(payment); }
public override int GetHashCode() { var hashCode = 71857844; hashCode = hashCode * -1521134295 + MerchantId.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <Guid> .Default.GetHashCode(PaymentId); return(hashCode); }
public FormUrlEncodedContent MakePostContent() { var keyValues = new List <KeyValuePair <string, string> >(); keyValues.Add(new KeyValuePair <string, string>("merchant_id", MerchantId.ToString())); keyValues.Add(new KeyValuePair <string, string>("token", Token)); keyValues.Add(new KeyValuePair <string, string>("checksum", Checksum)); return(new FormUrlEncodedContent(keyValues)); }
private async Task <Merchant> CheckMerchantAsync(string id) { MerchantId merchantId = new MerchantId() { UUID = id }; return(await _merchantHelper.GetMerchantByIdAsync(merchantId).ConfigureAwait(false)); }
public override int GetHashCode() { int hashCode = 1685690023; if (Context != null) { hashCode += Context.GetHashCode(); } if (AccessToken != null) { hashCode += AccessToken.GetHashCode(); } if (TokenType != null) { hashCode += TokenType.GetHashCode(); } if (ExpiresAt != null) { hashCode += ExpiresAt.GetHashCode(); } if (MerchantId != null) { hashCode += MerchantId.GetHashCode(); } if (SubscriptionId != null) { hashCode += SubscriptionId.GetHashCode(); } if (PlanId != null) { hashCode += PlanId.GetHashCode(); } if (IdToken != null) { hashCode += IdToken.GetHashCode(); } if (RefreshToken != null) { hashCode += RefreshToken.GetHashCode(); } if (ShortLived != null) { hashCode += ShortLived.GetHashCode(); } return(hashCode); }
public override int GetHashCode() { int hash = 1; if (entityId_ != null) { hash ^= EntityId.GetHashCode(); } if (merchantId_ != null) { hash ^= MerchantId.GetHashCode(); } if (capturedAmount_ != null) { hash ^= CapturedAmount.GetHashCode(); } if (HostReferenceNumber.Length != 0) { hash ^= HostReferenceNumber.GetHashCode(); } if (FolioBookingNumber.Length != 0) { hash ^= FolioBookingNumber.GetHashCode(); } if (paymentCard_ != null) { hash ^= PaymentCard.GetHashCode(); } if (AuthorizationApprovalCode.Length != 0) { hash ^= AuthorizationApprovalCode.GetHashCode(); } if (AuthorizationHostReferenceNumber.Length != 0) { hash ^= AuthorizationHostReferenceNumber.GetHashCode(); } if (authorizationAmount_ != null) { hash ^= AuthorizationAmount.GetHashCode(); } if (postedAt_ != null) { hash ^= PostedAt.GetHashCode(); } if (sale_ != null) { hash ^= Sale.GetHashCode(); } if (SaleState != 0) { hash ^= SaleState.GetHashCode(); } return(hash); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var paymentProvider = (IPaymentProvider)validationContext .GetService(typeof(IPaymentProvider)); var expectedSignature = paymentProvider.GetSignature(MerchantId.ToString(), ReferenceCode, TotalValue, Currency, TransactionState.ToString()); if (!expectedSignature.Equals(Signature, StringComparison.OrdinalIgnoreCase)) { yield return(ValidationResult.Success); //yield return new ValidationResult("This request is not verified by the payment provider"); } }
/// <summary> /// Gets the details of all payments made to a merchant. /// </summary> /// <param name="merchantId">The merchant id</param> /// <returns>List of PaymentItems</returns> public async Task <List <PaymentItem> > GetPaymentsByMerchantIdAsync(MerchantId merchantId) { await using PaymentControllerDbContext context = DbContextProvider.Create(); List <Model.PaymentItem> payments = await context.Payments.Include(c => c.PaymentCard).Include(p => p.PaymentCustomer).Where( p => p.PaymentMerchant.Equals(new Model.Merchant() { MerchantId = merchantId.UUID })).ToListAsync().ConfigureAwait(false); return(payments.ToDto()); }
public override int GetHashCode() { int hashCode = 1120695913; hashCode = hashCode * -1521134295 + Id.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(TypeName); hashCode = hashCode * -1521134295 + EqualityComparer <List <Cuisine> > .Default.GetHashCode(Cuisines); hashCode = hashCode * -1521134295 + MerchantId.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <Merchant> .Default.GetHashCode(Merchant); return(hashCode); }
public override int GetHashCode() { int hash = 1; if (entityId_ != null) { hash ^= EntityId.GetHashCode(); } if (merchantId_ != null) { hash ^= MerchantId.GetHashCode(); } if (paymentCard_ != null) { hash ^= PaymentCard.GetHashCode(); } if (authorizedAmount_ != null) { hash ^= AuthorizedAmount.GetHashCode(); } if (capturedAmount_ != null) { hash ^= CapturedAmount.GetHashCode(); } if (HostReferenceNumber.Length != 0) { hash ^= HostReferenceNumber.GetHashCode(); } if (EntryMethod != 0) { hash ^= EntryMethod.GetHashCode(); } if (authorization_ != null) { hash ^= Authorization.GetHashCode(); } if (State != 0) { hash ^= State.GetHashCode(); } hash ^= increases_.GetHashCode(); hash ^= reversals_.GetHashCode(); hash ^= captures_.GetHashCode(); hash ^= voids_.GetHashCode(); if (FolioBookingNumber.Length != 0) { hash ^= FolioBookingNumber.GetHashCode(); } return(hash); }
public async Task <OptionAsync <Payment> > GetAsync(MerchantId merchantId, PaymentId paymentId) { if (!Databag.ContainsKey(paymentId)) { return(OptionAsync <Payment> .None); } Payment payment = Databag[paymentId]; if (payment.MerchantId != merchantId) { return(OptionAsync <Payment> .None); } return(await Task.FromResult(OptionAsync <Payment> .Some(payment))); }
public async Task <OptionAsync <Payment> > GetByMerchantReferenceAsync(MerchantId merchantId, Option <MerchantReference> merchantReference) { return(await merchantReference.Match(async mr => { Payment payment = Databag.Values.SingleOrDefault(p => p.MerchantReference == mr && p.MerchantId == merchantId); if (payment == null) { return await Task.FromResult(OptionAsync <Payment> .None); } return await Task.FromResult(OptionAsync <Payment> .Some(payment)); }, async() => await Task.FromResult(OptionAsync <Payment> .None))); }
/// <summary> /// Gets the details of all payments made to a merchant /// </summary> /// <param name="merchantId">The merchant Id</param> /// <returns>List of payment items</returns> public async Task <List <PaymentItem> > GetPaymentsByMerchantIdAsync(MerchantId merchantId) { List <PaymentItem> paymentItems = await DataAccess.GetPaymentsByMerchantIdAsync(merchantId).ConfigureAwait(false); if (paymentItems.Any()) { foreach (PaymentItem payment in paymentItems) { payment.PaymentCard.CardNumber = "**** **** **** ****"; payment.PaymentCard.Cvv = 000; } } return(paymentItems); }
public async Task ProcessPayment_BankError() { PaymentItem payment = CreateValidPaymentItem(); _mockBank.Setup(x => x.ProcessPaymentAsync(It.IsAny <PaymentItem>())).ReturnsAsync((PaymentResult)null); MerchantId merchantId = new MerchantId() { UUID = Guid.NewGuid().ToString() }; PaymentHelper paymentHelper = new PaymentHelper(_mockLogger.Object, _mockBank.Object, _mockDataAccess.Object); await Assert.ThrowsAsync <ArgumentOutOfRangeException>(() => paymentHelper.ProcessPaymentAsync(merchantId, payment)).ConfigureAwait(false); }
/// <summary> /// Gets the details of a payment by Id /// </summary> /// <param name="merchantId"></param> /// <param name="paymentId"></param> /// <returns></returns> public async Task <PaymentItem> GetPaymentByPaymentId(MerchantId merchantId, PaymentId paymentId) { await using PaymentControllerDbContext context = DbContextProvider.Create(); Model.PaymentItem payment = await context.Payments.Include(c => c.PaymentCard) .Include(p => p.PaymentCustomer).FirstOrDefaultAsync( p => p.PaymentMerchant.Equals(new Model.Merchant() { MerchantId = merchantId.UUID }) && p.PaymentId.Equals(paymentId.UUID) ).ConfigureAwait(false); return(payment.ToDto()); }
public override int GetHashCode() { int hash = 1; if (MerchantId != 0L) { hash ^= MerchantId.GetHashCode(); } if (HasFeedLabel) { hash ^= FeedLabel.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public async Task GetMerchant_HappyPath() { MerchantHelper merchantHelper = new MerchantHelper(_mockLogger.Object, _mockDataAccess.Object); MerchantId merchantId = new MerchantId() { UUID = Guid.NewGuid().ToString() }; Merchant merchant = new Merchant() { MerchantId = merchantId }; _mockDataAccess.Setup(x => x.GetMerchantByIdAsync(It.IsAny <MerchantId>())).ReturnsAsync(merchant); Merchant result = await merchantHelper.GetMerchantByIdAsync(merchantId).ConfigureAwait(false); Assert.Equal(merchant, result); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is RevokeTokenRequest other && ((ClientId == null && other.ClientId == null) || (ClientId?.Equals(other.ClientId) == true)) && ((AccessToken == null && other.AccessToken == null) || (AccessToken?.Equals(other.AccessToken) == true)) && ((MerchantId == null && other.MerchantId == null) || (MerchantId?.Equals(other.MerchantId) == true)) && ((RevokeOnlyAccessToken == null && other.RevokeOnlyAccessToken == null) || (RevokeOnlyAccessToken?.Equals(other.RevokeOnlyAccessToken) == true))); }
public override int GetHashCode() { int hash = 1; if (entityId_ != null) { hash ^= EntityId.GetHashCode(); } if (merchantId_ != null) { hash ^= MerchantId.GetHashCode(); } if (MerchantName.Length != 0) { hash ^= MerchantName.GetHashCode(); } if (Result != 0) { hash ^= Result.GetHashCode(); } if (ProcessorBatchId != 0) { hash ^= ProcessorBatchId.GetHashCode(); } if (TransactionCount != 0) { hash ^= TransactionCount.GetHashCode(); } if (totalAmount_ != null) { hash ^= TotalAmount.GetHashCode(); } if (createdAt_ != null) { hash ^= CreatedAt.GetHashCode(); } hash ^= captures_.GetHashCode(); hash ^= refunds_.GetHashCode(); if (SequenceNumber != 0) { hash ^= SequenceNumber.GetHashCode(); } return(hash); }