public ActionResult MakeBill(long OccupacyNumber) { PaymentClient PC = new PaymentClient(); var model = PC.MakeBill(OccupacyNumber); ViewBag.OccupacyNumber = OccupacyNumber; ViewBag.model = model; return(View()); }
public void TestInitialize() { Config = new ClientConfig().SetupForTesting(); Client = new PaymentClient(Config); PaymentAmount = 3000; CardNumber = "4444333322221111"; Expires = new YearMonth(DateTime.Today.Year + 1, DateTime.Today.Month); Ccv = "123"; }
static void OutputPaymentList(PaymentClient paymentClient) { Console.WriteLine("Outputting the first 2 payments"); ListResponse <PaymentResponse> paymentList = paymentClient.GetPaymentListAsync(0, 2).Result; foreach (PaymentResponse paymentResponse in paymentList.Data) { Console.WriteLine($"Payment Id: { paymentResponse.Id } - Payment method: { paymentResponse.Method }"); } }
private static async Task <DTOManager> GetAllowedContact(string phone) { List <DTOManager> managers; var credentials = DiscoveryFactory.GetDefaultCreditenals(); using (var client = new PaymentClient(ConfigurationContainer.Configuration["DiscoveryUrl"], credentials.ClientId, credentials.ClientSecret)) { managers = await client.GetAllowedManagers(); } return(managers.FirstOrDefault(x => x.Phone == phone)); }
public ActionResult Commit(long OccupacyNumber) { PaymentClient PC = new PaymentClient(); var model = PC.CommitBill(OccupacyNumber); ViewBag.model = model; return(View()); }
private async Task <PaymentResponse> CreatePayment(string amount = "100.00") { PaymentRequest paymentRequest = new CreditCardPaymentRequest { Amount = new Amount(Currency.EUR, amount), Description = "Description", RedirectUrl = DefaultRedirectUrl }; return(await PaymentClient.CreatePaymentAsync(paymentRequest)); }
/// <summary> /// Determines whether [is sign correct] [the specified dictionary]. /// </summary> /// <param name="dictionary">The dictionary.</param> /// <returns><c>true</c> if [is sign correct] [the specified dictionary]; otherwise, <c>false</c>.</returns> private bool IsSignCorrect(Dictionary <string, string> dictionary) { if (dictionary != null) { var client = new PaymentClient(this.TransactionInfo); string signed = client.GetSignedString(dictionary); return(dictionary["sign"] == signed); } return(false); }
public ProcessManager( WebshopDbContext db, PaymentClient paymentClient, MailerClient mailerClient, ILogger <ProcessManager> logger) { _db = db; _paymentClient = paymentClient; _mailerClient = mailerClient; _logger = logger; }
public async Task ListPaymentsNeverReturnsMorePaymentsThenTheNumberOfRequestedPayments() { // When: Number of payments requested is 5 int numberOfPayments = 5; // When: Retrieve 5 payments ListResponse <PaymentResponse> response = await PaymentClient.GetPaymentListAsync(null, numberOfPayments); // Then Assert.IsTrue(response.Items.Count <= numberOfPayments); }
private void AuthorizeRecurringPaymentInternal(Payment payment, out string status) { var originalPayment = payment.PurchaseOrder.Payments.FirstOrDefault(x => x.PaymentProperties.Any(y => y.Key == RecurringDetailReference)); if (originalPayment == null) { throw new SecurityException("There was no payment found, with recurring details reference attached. Please make sure the recurring payment was authorized correctly."); } SetupWebServiceClients(payment.PaymentMethod); SetupWebServiceCredentials(payment.PaymentMethod); var result = PaymentClient.authorise( new Adyen.Test.ModificationSoapService.PaymentRequest { selectedRecurringDetailReference = originalPayment[RecurringDetailReference], recurring = new Recurring { contract = "RECURRING" }, merchantAccount = payment.PaymentMethod.DynamicProperty <string>().MerchantAccount, amount = new Amount { value = payment.Amount.ToCents(), currency = payment.PurchaseOrder.BillingCurrency.ISOCode }, reference = payment.PaymentId.ToString(CultureInfo.InvariantCulture), shopperEmail = payment.PurchaseOrder.BillingAddress.EmailAddress, shopperReference = originalPayment.ReferenceId, shopperInteraction = "ContAuth", fraudOffset = payment.PaymentMethod.DynamicProperty <int>().Offset }); payment.TransactionId = result.pspReference; if (result.resultCode == "Authorised") { SetPaymentStatus(payment, PaymentStatusCode.Acquired, "Recurring payment authorized."); status = "Recurring payment authorized."; return; } if (result.resultCode == "Refused") { SetPaymentStatus(payment, PaymentStatusCode.Declined, "Recurring payment could not be authorized: " + result.refusalReason); status = "Recurring payment could not be authorized: " + result.refusalReason; return; } SetPaymentStatus(payment, PaymentStatusCode.Declined, "Error occured during authorization of recurring payment: " + result.refusalReason); status = "Error occured during authorization of recurring payment: " + result.refusalReason; }
public void When_Payment_Method_Is_Paypal_Make_Payment_Must_Return_Two_Percent_Commission() { //arrange var paymentClient = new PaymentClient(new PaypalPaymentService()); //act var result = paymentClient.MakePayment(100); //assert Assert.Equal(120, result); }
public void When_Payment_Method_Is_LocalBank_Make_Payment_Must_Return_One_Percent_Commission() { //arrange var paymentClient = new PaymentClient(new LocalBankPaymentService()); //act var result = paymentClient.MakePayment(100); //assert Assert.Equal(110, result); }
public async Task GetPaymentListAsync_EmbedChargebacks_QueryStringContainsEmbedChargebacksParameter() { // Given: We make a request to retrieve a payment with embedded refunds var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments?embed=chargebacks", defaultPaymentJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); // When: We send the request await paymentClient.GetPaymentListAsync(embedChargebacks : true); // Then mockHttp.VerifyNoOutstandingExpectation(); }
public async Task GetPaymentListAsync_IncludeQrCode_QueryStringContainsIncludeQrCodeParameter() { // Given: We make a request to retrieve a payment without wanting any extra data var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments?include=details.qrCode", defaultPaymentJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); // When: We send the request await paymentClient.GetPaymentListAsync(includeQrCode : true); // Then mockHttp.VerifyNoOutstandingExpectation(); }
static void Main(string[] args) { var paymentClient = new PaymentClient(new PaypalPaymentService()); var totalAmount = paymentClient.MakePayment(100); Console.WriteLine("Total Amount: " + totalAmount); paymentClient.ChangeStrategy(new LocalBankPaymentService()); totalAmount = paymentClient.MakePayment(100); Console.WriteLine("Total Amount: " + totalAmount); Console.ReadLine(); }
public PaymentClientTest() { _mockHttpClientFactory = new Mock <IHttpClientFactory>(); _mockMessageHandler = new Mock <HttpMessageHandler>(MockBehavior.Strict); _mockHttpClientFactory.Setup(x => x.CreateClient(It.IsAny <string>())) .Returns(new HttpClient(_mockMessageHandler.Object) { BaseAddress = new Uri(BaseUri) }); _paymentClient = new PaymentClient(_mockHttpClientFactory.Object); }
static void Main(string[] args) { string apiKey = "{your_api_test_key}"; PaymentClient paymentClient = new PaymentClient(apiKey); PaymentMethodClient paymentMethodClient = new PaymentMethodClient(apiKey); OutputAndWait("Press any key to create a new payment"); OutputNewPayment(paymentClient); OutputAndWait("Press any key to retrieve a list of payments"); OutputPaymentList(paymentClient); OutputAndWait("Press any key to retrieve a list of payment methods"); OutputPaymentMethods(paymentMethodClient); OutputAndWait("Example completed"); }
public async Task When_A_Payment_Is_Created_And_GetPaymentDetails_Is_Called_Then_PaymentDetails_Should_Be_Returned() { var accessToken = await TokenHelper.GetReferenceAccessToken(); Guid merchantId = Guid.Parse("b074e29b-54bc-4085-a97d-5a370cafa598"); var baseUri = "https://localhost:5001"; var apiClient = new HttpClient(); var paymentClient = new PaymentClient(apiClient, new PaymentRoutes(merchantId, baseUri), accessToken); var cardPaymentRequest = new CardPaymentRequestDto { Amount = 100m, Currency = Currency.GBP, BillingAddressDto = new AddressDto() { AddressLine1 = "Random Flat in", AddressLine2 = "Canary Wharf", City = "London", Country = "England", FirstName = "Joe", LastName = "Blogs" }, CardInformation = new CardInformationDto() { CardNumber = "366252948156588", FirstName = "Joe", LastName = "Blogs", Cvv = "1011", ExpiryMonth = "01", ExpiryYear = "24" } }; var payment = await paymentClient.CreateCardPaymentAsync(cardPaymentRequest); var paymentDetails = await paymentClient.GetPaymentDetailsAsync(payment.PaymentId); var expectedResponse = new PaymentDetailResponseDto { PaymentStatus = payment.PaymentStatus, PaymentId = payment.PaymentId, MerchantId = payment.MerchantId, Year = "24", Month = "01", MaskedCardNumber = "3662 52XX XXX6 588" }; paymentDetails.Should().BeEquivalentTo(expectedResponse); }
public async Task GetPaymentAsync_NoIncludeParameters_QueryStringIsEmpty() { // Given: We make a request to retrieve a payment without wanting any extra data const string paymentId = "abcde"; var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", defaultPaymentJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); // When: We send the request await paymentClient.GetPaymentAsync(paymentId); // Then mockHttp.VerifyNoOutstandingExpectation(); }
static void Main(string[] args) { //CreditCardServiceReference.CreditCardServiceClient cc = new CreditCardServiceReference.CreditCardServiceClient(); PaymentClient pc = new PaymentClient(); Console.WriteLine("Enter credit card no."); string cno = Console.ReadLine(); Console.WriteLine("Enter credit card Expiry date"); DateTime expd = Convert.ToDateTime(Console.ReadLine()); SelfHostingServicePaymentLibraray.CreditCard cc = new SelfHostingServicePaymentLibraray.CreditCard(); cc.CCNo = cno; cc.ExpDate = expd; bool result = false; try { result = pc.ValidateCard(cc); } catch (FaultException ex) { Console.WriteLine(ex.Message); } catch (ProtocolException ex) { Console.WriteLine(ex.Message); } if (result) { Console.WriteLine("Valid"); } else { Console.WriteLine("Invalid"); } DataContractSerializer dcs = new DataContractSerializer(typeof(CreditCard)); using (Stream stream = new FileStream(@"D:\Tesco batch5\WCF\CarPoolingPaymentClient\file.xml", FileMode.Create, FileAccess.Write)) { using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(stream, Encoding.UTF8)) { writer.WriteStartDocument(); dcs.WriteObject(writer, cc); } } Console.ReadLine(); }
static void OutputNewPayment(PaymentClient paymentClient) { Console.WriteLine("Creating a payment"); PaymentRequest paymentRequest = new PaymentRequest() { Amount = 100, Description = "Test payment of the example project", RedirectUrl = "http://google.com" }; PaymentResponse paymentResponse = paymentClient.CreatePaymentAsync(paymentRequest).Result; Console.WriteLine("Payment created"); Console.WriteLine(""); Console.WriteLine($"Payment can be paid on the following URL: {paymentResponse.Links.PaymentUrl}"); }
private static async Task <ReturnModel> SendPaymentIfValid(Tuple <DTOInsertPayment, string> content) { var manager = await GetAllowedContact(content.Item2); if (manager == null) { return(null); } var credentials = DiscoveryFactory.GetDefaultCreditenals(); using (var client = new PaymentClient(ConfigurationContainer.Configuration["DiscoveryUrl"], credentials.ClientId, credentials.ClientSecret)) { content.Item1.OperatorId = manager.Id; return(await client.AddPayment(content.Item1)); } }
public async Task WhenRetrievingAListOfPaymentsPaymentSubclassesShouldBeInitialized() { // Given: We create a new payment IdealPaymentRequest paymentRequest = new IdealPaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", RedirectUrl = DefaultRedirectUrl }; await PaymentClient.CreatePaymentAsync(paymentRequest); // When: We retrieve it in a list ListResponse <PaymentResponse> result = await PaymentClient.GetPaymentListAsync(null, 5); // Then: We expect a list with a single ideal payment Assert.IsInstanceOfType(result.Items.First(), typeof(IdealPaymentResponse)); }
public async Task <BackerPaymentRequestModel> Handle(CheckoutBackerCommand request, CancellationToken cancellationToken) { var molliePaymentClient = new PaymentClient(_applicationSettings.PaymentProviderApiKey); var paymentResponse = await molliePaymentClient.CreatePaymentAsync(new PaymentRequest { Description = request.Description, Amount = new Amount(request.Currency, request.TotalAmount), RedirectUrl = request.RedirectUrl, Locale = request.Locale, WebhookUrl = "https://google.be" }, true); return(new BackerPaymentRequestModel { CheckoutUrl = paymentResponse.Links.Checkout.Href }); }
public async Task When_ValidCerditCard_Information_Used_Then_Payment_Is_Created() { var accessToken = await TokenHelper.GetReferenceAccessToken(); Guid merchantId = Guid.Parse("b074e29b-54bc-4085-a97d-5a370cafa598"); var baseUri = "https://localhost:5001"; var apiClient = new HttpClient(); var paymentClient = new PaymentClient(apiClient, new PaymentRoutes(merchantId, baseUri), accessToken); var cardPaymentRequest = new CardPaymentRequestDto { Amount = 100m, Currency = Currency.GBP, BillingAddressDto = new AddressDto() { AddressLine1 = "Random Flat in", AddressLine2 = "Canary Wharf", City = "London", Country = "England", FirstName = "Joe", LastName = "Blogs" }, CardInformation = new CardInformationDto() { CardNumber = "366252948156588", FirstName = "Joe", LastName = "Blogs", Cvv = "1011", ExpiryMonth = "01", ExpiryYear = "24" } }; try { var response = await paymentClient.CreateCardPaymentAsync(cardPaymentRequest); response.PaymentId.Should().NotBeEmpty(); response.MerchantId.Should().Be(merchantId); response.PaymentStatus.Should().Be(PaymentStatus.Created); } catch (CheckoutGatewayException gatewayException) { Assert.Fail(); } }
public async Task CanCreatePaymentWithJsonMetaData() { // If: We create a payment with meta data string json = "{\"order_id\":\"4.40\"}"; PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", RedirectUrl = DefaultRedirectUrl, Metadata = json }; // When: We send the payment request to Mollie PaymentResponse result = await PaymentClient.CreatePaymentAsync(paymentRequest); // Then: Make sure we get the same json result as metadata Assert.AreEqual(json, result.Metadata); }
public async Task CanCreatePaymentWithMetaData() { // If: We create a payment with meta data var metadata = "this is my metadata"; var paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", RedirectUrl = DefaultRedirectUrl, Metadata = metadata }; // When: We send the payment request to Mollie var result = await PaymentClient.CreatePaymentAsync(paymentRequest); // Then: Make sure we get the same json result as metadata Assert.Equal(metadata, result.Metadata); }
public static PaymentResponse GetOrderPaymentResponse(OrderData orderData, string origin) { var info = ProviderUtils.GetProviderSettings(); var apiKey = info.GetXmlProperty("genxml/textbox/key"); IPaymentClient paymentClient = new PaymentClient(apiKey); var task = Task.Run(async() => await paymentClient.GetPaymentAsync(orderData.PaymentPassKey)); task.Wait(); PaymentResponse paymentClientResult = task.Result; if (string.IsNullOrEmpty(orderData.GetInfo().GetXmlNode("genxml/paymentreturn"))) { orderData.GetInfo().AddSingleNode("paymentreturn", "", "genxml"); } var xmlDoc = orderData.GetInfo().XMLDoc; var newNode = xmlDoc.CreateNode(XmlNodeType.Element, "data", ""); var dtAttr = newNode.Attributes.Append(xmlDoc.CreateAttribute("timestamp")); dtAttr.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); newNode.Attributes.Append(dtAttr); var xml = $@"<data timestamp=""{DateTime.Now:yyyy-MM-dd HH:mm:ss}"" origin=""{origin}""> <created>{paymentClientResult.CreatedAt:yyyy-MM-dd HH:mm:ss}</created> <cancelled>{paymentClientResult.CreatedAt:yyyy-MM-dd HH:mm:ss}</cancelled> <expired>{paymentClientResult.CreatedAt:yyyy-MM-dd HH:mm:ss}</expired> <failed>{paymentClientResult.CreatedAt:yyyy-MM-dd HH:mm:ss}</failed> <paied>{paymentClientResult.CreatedAt:yyyy-MM-dd HH:mm:ss}</paied> <description>{paymentClientResult.Description}</description> <method>{paymentClientResult.Method}</method> <amount>{paymentClientResult.Amount.Value}</amount> <currency>{paymentClientResult.Amount.Currency}</currency> <status>{paymentClientResult.Status}</status> </data>"; orderData.GetInfo().AddXmlNode(xml, "data", "genxml/paymentreturn"); var modCtrl = new NBrightBuyController(); modCtrl.Update(orderData.GetInfo()); return(paymentClientResult); }
public static void Main(string[] args) { // https://developer.mastercard.com/portal/display/api/Software+Development+Kit // http://newsroom.mastercard.com/2014/07/11/masterpass-continues-global-expansion-product-enhancements-planned-for-august/ { //FullName = System.Reflection.TargetInvocationException, InnerException = System.IO.FileNotFoundException: The JVM/ CLR feature is not available within this build. System.Console.WriteLine( typeof(object).AssemblyQualifiedName ); // jsc java natives/ where is the ctor we think of? PaymentClient client = new PaymentClient(getPrivateKey(), "my-client-id", false); PurchaseRequest purchaseRequest = new PurchaseRequest(); Amount amount = new Amount(); amount.setCurrency("GBP"); amount.setValue(new BigInteger("441250")); purchaseRequest.setAmount(amount); MerchantIdentity merchantIdentity = new MerchantIdentity(); merchantIdentity.setClientId("my-merchant-id"); merchantIdentity.setPassword("my-merchant-password"); purchaseRequest.setMerchantIdentity(merchantIdentity); purchaseRequest.setClientReference(getClientReference()); Card card = new Card(); card.setAccountNumber("6XXXXXXXXXXXXXXX"); card.setExpiryMonth("01"); card.setExpiryYear("11"); card.setSecurityCode("111"); purchaseRequest.setFundingCard(card); Purchase purchase = client.createPurchase(purchaseRequest); CLRProgram.CLRMain(); } }
public async Task CreatePaymentAsync_IncludeQrCode_QueryStringContainsIncludeQrCodeParameter() { // Given: We make a request to create a payment and include the QR code PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", RedirectUrl = "http://www.mollie.com", Method = PaymentMethod.Ideal }; var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments?include=details.qrCode", defaultPaymentJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); // When: We send the request await paymentClient.CreatePaymentAsync(paymentRequest, includeQrCode : true); // Then mockHttp.VerifyNoOutstandingExpectation(); }
public async Task CanCreateDefaultPaymentWithOnlyRequiredFields() { // When: we create a payment request with only the required parameters PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", RedirectUrl = DefaultRedirectUrl }; // When: We send the payment request to Mollie PaymentResponse result = await PaymentClient.CreatePaymentAsync(paymentRequest); // Then: Make sure we get a valid response Assert.IsNotNull(result); Assert.AreEqual(paymentRequest.Amount.Currency, result.Amount.Currency); Assert.AreEqual(paymentRequest.Amount.Value, result.Amount.Value); Assert.AreEqual(paymentRequest.Description, result.Description); Assert.AreEqual(paymentRequest.RedirectUrl, result.RedirectUrl); }
public void BillPayment() { var binding = new WSHttpBinding(SecurityMode.None, true); var request = XElement.Parse(GetContentFromFile("BillPayment.xml")); var sign = new EfawateerSigner("ARKAIM-TEST"); var time = DateTime.Now.ToString("s"); request.Element("MsgHeader").Element("TmStp").Value = time; request.Element("MsgBody").Element("Transactions").Element("TrxInf").Element("ProcessDate").Value = time; request.Element("MsgBody").Element("Transactions").Element("TrxInf").Element("BankTrxID").Value = Guid.NewGuid().ToString(); request.Element("MsgFooter").Element("Security").Element("Signature").Value = sign.SignData(request.Element("MsgBody").ToString()); var client = new PaymentClient(binding, new EndpointAddress(UriContext.BillPayment)); var upload = client.PayBill(Guid.NewGuid().ToString(), GetToken(), request); Debug.WriteLine("BillPayment " + upload); }
static void Main() { using (var proxy = new RecurringClient()) // do not use RecurringPortTypeClient { try { var thisUserDetail = new RecurringDetailsRequest(); thisUserDetail.shopperReference = "[Shopper Reference]"; thisUserDetail.recurring = new Adyen.RecurringSample.Adyen.Recurring.Recurring() { contract = "RECURRING" }; var recContractDetails = proxy.ListRecurringDetails(thisUserDetail); Trace.TraceInformation("Shoppermail {0}", recContractDetails.lastKnownShopperEmail); Trace.TraceInformation("Creation date {0}", recContractDetails.creationDate.Value.ToShortDateString()); } catch (Exception ex) { Trace.TraceError("error using RecurringClient.listRecurringDetails {0}", ex.Message); throw ex; } } ///etc... using (var proxy = new PaymentClient()) { try { var paymentRequest = new PaymentRequest(); proxy.Authorise(paymentRequest); } catch (Exception ex) { } } }