static void Main(string[] args) { MollieClient mollieClient = new MollieClient(); mollieClient.setApiKey(ConfigurationManager.AppSettings["mollie_api_key"]); Console.WriteLine("Loading iDeal issuers ..."); Issuers issuers = mollieClient.GetIssuers(); foreach (Issuer issuer in issuers.data) { Console.WriteLine(issuer.name); } Console.WriteLine("Starting payment without method ..."); Payment payment = new Payment { amount = 99.99M, description = "Test payment", redirectUrl = "http://www.foxip.net/completed/?orderId=1245", }; PaymentStatus status = mollieClient.StartPayment(payment); Console.WriteLine("The status is: " + status.status); Console.WriteLine("Please follow this link to start the payment:"); Console.WriteLine(status.links.paymentUrl); Console.WriteLine("Press [enter] to continue ..."); Console.ReadLine(); Console.WriteLine("Getting status ..."); status = mollieClient.GetStatus(status.id); Console.WriteLine("The status is now: " + status.status); //Refunds only for iDEAL, Bancontact/Mister Cash, SOFORT Banking, creditcard and banktransfer Console.WriteLine("Refunding ..."); try { RefundStatus refundStatus = mollieClient.Refund(status.id); Console.WriteLine("The status is now: " + refundStatus.payment.status); } catch (Exception ex) { Console.WriteLine("Exception: " + ex.Message); } Console.WriteLine("Starting payment with a specific method ..."); status = mollieClient.StartPayment(new Payment { amount = 1.99M, method = Method.mistercash, description = "Test payment", redirectUrl = "http://www.foxip.net/completed/?orderId=12345" }); Console.WriteLine("The status is: " + status.status); Console.WriteLine("Please follow this link to start the payment:"); Console.WriteLine(status.links.paymentUrl); Console.WriteLine("Press [enter] to continue ..."); Console.ReadLine(); }
public void CanMakePayment() { Payment payment = new Payment { amount = 99.99M, description = "Test payment", redirectUrl = "http://www.foxip.net/test/12345", metadata = "12345678" }; PaymentStatus status = mollieClient.StartPayment(payment); Assert.AreEqual(status.amount, payment.amount); Assert.AreEqual(status.description, payment.description); Assert.AreEqual(status.links.redirectUrl, payment.redirectUrl); Assert.IsTrue(status.links.paymentUrl.StartsWith("https://")); Assert.AreEqual(status.mode, "test"); Assert.AreEqual(status.paidDatetime, null); Assert.IsNull(status.cancelledDatetime, null); Assert.IsNotNull(status.createdDatetime); Assert.IsNull(status.details); Assert.IsNull(status.expiredDatetime); Assert.IsTrue(status.id!=""); Assert.AreEqual(status.metadata,payment.metadata); Assert.AreEqual(status.status, Status.open); Assert.IsNull(status.method); }
/// <summary> /// Start a payment /// </summary> /// <param name="payment">Payment object</param> /// <returns></returns> public PaymentStatus StartPayment(Payment payment) { string jsonData = LoadWebRequest("POST", "payments", JsonConvert.SerializeObject(payment)); PaymentStatus status = JsonConvert.DeserializeObject<PaymentStatus>(jsonData, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore}); return status; }
public void IDEAL_CanMakePaymentWithIssuer() { Issuers issuers = mollieClient.GetIssuers(); Payment payment = new Payment { amount = 99.99M, description = "Test payment", redirectUrl = "http://www.foxip.net/test/12345", method = Method.ideal, issuer = issuers.data[0].id }; PaymentStatus status = mollieClient.StartPayment(payment); Assert.AreEqual(status.method, Method.ideal); }
public void IDEAL_CanMakePayment() { Payment payment = new Payment { amount = 99.99M, description = "Test payment", redirectUrl = "http://www.foxip.net/test/12345", method = Method.ideal }; PaymentStatus status = mollieClient.StartPayment(payment); Assert.AreEqual(status.method, Method.ideal); }