Example #1
0
        protected static HostedPaymentRequest CreateHostedPaymentRequest()
        {
            var customer = new CustomerRequest {
                Name = "Jack Napier", Email = GenerateRandomEmail()
            };

            var shippingDetails = new ShippingDetails {
                Address = GetAddress(), Phone = GetPhone()
            };

            var billing = new BillingInformation {
                Address = GetAddress(), Phone = GetPhone()
            };

            var recipient = new PaymentRecipient
            {
                AccountNumber = "1234567",
                DateOfBirth   = "1985-05-15",
                LastName      = "TESTING",
                Zip           = "12345"
            };

            var products = new[] { new Product {
                                       Name = "Gold Necklace", Quantity = 1L, Price = 200L
                                   } };

            return(new HostedPaymentRequest
            {
                Amount = 1000L,
                Reference = "reference",
                Currency = Currency.GBP,
                Description = "Payment for Gold Necklace",
                Customer = customer,
                Shipping = shippingDetails,
                Billing = billing,
                Recipient = recipient,
                Processing = new ProcessingSettings {
                    Aft = true
                },
                Products = products,
                Risk = new RiskRequest {
                    Enabled = false
                },
                SuccessUrl = "https://example.com/payments/success",
                CancelUrl = "https://example.com/payments/success",
                FailureUrl = "https://example.com/payments/success",
                Locale = "en-GB",
                ThreeDs = new ThreeDsRequest {
                    Enabled = false, AttemptN3D = false
                },
                Capture = true,
                CaptureOn = DateTime.UtcNow,
                AllowPaymentMethods =
                    new List <PaymentSourceType> {
                    PaymentSourceType.Card, PaymentSourceType.Ideal
                }
            });
        }
Example #2
0
 public PaymentInitiatedDomainEvent(string paymentId, string cardToken, string currency, decimal amount, IdPaymentSource source, PaymentRecipient recipient, Address billingAddress, string description)
 {
     PaymentId      = paymentId;
     CardToken      = cardToken;
     Currency       = currency;
     Amount         = amount;
     Source         = source;
     Recipient      = recipient;
     BillingAddress = billingAddress;
     Description    = description;
 }
Example #3
0
        /// <summary>
        /// Handle payment
        /// </summary>
        /// <param name="amount">amount to be paid out</param>
        /// <param name="currency">currency</param>
        /// <param name="recipient">payment recipient</param>
        /// <param name="description">payment description</param>
        /// <param name="card">card detail</param>
        /// <returns></returns>
        public Task <Result> HandlePaymentAsync(decimal amount, string currency, PaymentRecipient recipient, string description, Card card)
        {
            var random      = new Random();
            var probability = random.Next(100);

            // Return true with 99 percent probability
            var validity = probability <= 90;

            var errorReason = random.Next(_reasons.Length);

            return(Task.FromResult(validity ? Result.Ok() : Result.Fail(_reasons[errorReason])));
        }
Example #4
0
 public CreatePaymentCommand(Guid merchantId, string cardToken, string cvv, decimal amount, string currency, Shipping shipping, PaymentRecipient recipient,
                             string reference, string description, string originIp, Uri successUrl, Uri errorUrl, Dictionary <string, string> metaData,
                             string correlationId = null) : base(correlationId)
 {
     MerchantId  = merchantId;
     CardToken   = cardToken;
     Cvv         = cvv;
     Amount      = amount;
     Currency    = currency;
     Shipping    = shipping;
     Reference   = reference;
     Description = description;
     OriginIp    = originIp;
     SuccessUrl  = successUrl;
     ErrorUrl    = errorUrl;
     MetaData    = metaData;
     Recipient   = recipient;
 }