public virtual void Initialize() { _paymill = new PaymillContext("9a4129b37640ea5f62357922975842a1"); String ApiKey = "941569045353c8ac2a5689deb88871bb"; HttpClient _httpClient = new HttpClient(); _httpClient.DefaultRequestHeaders.Accept .Add(new MediaTypeWithQualityHeaderValue("application/json")); var authInfo = ApiKey + ":"; authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo)); _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authInfo); String content = @""; HttpResponseMessage response = _httpClient.GetAsync(@"https://test-token.paymill.com/?transaction.mode=CONNECTOR_TEST&channel.id=941569045353c8ac2a5689deb88871bb&jsonPFunction=paymilljstests&account.number=4111111111111111&account.expiry.month=12&account.expiry.year=2015&account.verification=123&account.holder=Max%20Mustermann&presentation.amount3D=2800&presentation.currency3D=EUR").Result; String pattern = "(tok_)[a-z|0-9]+"; content = response.Content.ReadAsStringAsync().Result; if (Regex.Matches(content, pattern).Count > 0) { this.testToken = Regex.Matches(content, pattern)[0].Value; } }
public ActionResult Submit(Models.PaymillForm form) { PaymillContext paymill = new PaymillContext("YOUR Private Key"); string token = Request.Form["hToken"]; try { Transaction transaction = paymill.TransactionService.CreateWithTokenAsync(token, form.Amount, form.Currency).Result; Transaction.TransactionStatus status = transaction.Status; // You can check the transaction status like this : /* if (status == Transaction.TransactionStatus.PENDING) * { * return Content("Payment PENDING"); * }*/ // You can check the Response Code like this : if (transaction.ResponseCode == 2000) { return(Content("Payment Success")); } else { return(Content("Payment NOT successful, response code " + transaction.ResponseCode)); } } catch (AggregateException ex) { // or returns Error from server return(Content(ex.InnerException.Message)); } return(Content("")); }
protected void btnSubmit_Click(object sender, EventArgs e) { if (IsValid) { PaymillContext paymill = new PaymillContext("YOUR PRIVATE KEY"); String token = hToken.Value; Payment payment = paymill.PaymentService.CreateWithTokenAsync(token).Result; int amount = int.Parse(tbAmount.Text) * 100; Transaction transaction = paymill.TransactionService.CreateWithPaymentAsync(payment, amount, tbCurrency.Text, "Test API c#").Result; /// Yout Transaction Is Complete } }
/// <summary> /// Executes a <see cref="Transaction" /> with <see cref="Payment" /> for the given amount in the given currency. /// </summary> /// <param name="paymentId">A PAYMILL Payment representing credit card or direct debit.</param> /// <param name="amount">Amount (in cents) which will be charged.</param> /// <param name="currency">ISO 4217 formatted currency code.</param> /// <param name="description">The description.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> public async Task <Transaction> CreateWithPaymentAsync(Payment payment, int amount, String currency, String description) { ValidationUtils.ValidatesPayment(payment); ValidationUtils.ValidatesAmount(amount); ValidationUtils.ValidatesCurrency(currency); String srcValue = String.Format("{0}-{1}", PaymillContext.GetProjectName(), PaymillContext.GetProjectVersion()); return(await createAsync(null, new UrlEncoder().EncodeObject(new { Payment = payment.Id, Amount = amount, Currency = currency, source = srcValue, description = description }))); }
/// <summary> /// Creates Use either a token or an existing payment to Authorizes the given amount with the given token. /// </summary> /// <param name="token">The identifier of a token.</param> /// <param name="amount">Amount (in cents) which will be charged.</param> /// <param name="currency">ISO 4217 formatted currency code.</param> /// <param name="description">A short description for the preauthorization</param> /// <returns>Object with the Preauthorization as sub object.d</returns> public async Task <Preauthorization> CreateWithTokenAsync(String token, int amount, String currency, String description) { ValidationUtils.ValidatesToken(token); ValidationUtils.ValidatesAmount(amount); ValidationUtils.ValidatesCurrency(currency); String srcValue = String.Format("{0}-{1}", PaymillContext.GetProjectName(), PaymillContext.GetProjectVersion()); return(await createAsync(null, new UrlEncoder().EncodeObject(new { Token = token, Amount = amount, Currency = currency, Description = description, Source = srcValue }))); }
/// <summary> /// Executes a <see cref="Transaction" /> with <see cref="Preauthorization" /> for the given amount in the given currency. /// </summary> /// <param name="preauthorizationId">The Id of a Preauthorization, which has reserved some money from the client’s credit card.</param> /// <param name="amount">Amount (in cents) which will be charged.</param> /// <param name="currency">ISO 4217 formatted currency code.</param> /// <param name="description">The description.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> public async Task <Transaction> CreateWithPreauthorizationAsync(String preauthorizationId, int amount, String currency, String description, String mandateReference) { ValidationUtils.ValidatesId(preauthorizationId); ValidationUtils.ValidatesAmount(amount); ValidationUtils.ValidatesCurrency(currency); String srcValue = String.Format("{0}-{1}", PaymillContext.GetProjectName(), PaymillContext.GetProjectVersion()); return(await createAsync(null, new UrlEncoder().EncodeObject(new { preauthorization = preauthorizationId, Amount = amount, Currency = currency, source = srcValue, description = description, mandate_reference = mandateReference }))); }
/// <summary> /// Executes a <see cref="Transaction" /> with token for the given amount in the given currency. /// </summary> /// <param name="token">Token generated by PAYMILL Bridge, which represents a credit card or direct debit.</param> /// <param name="amount">Amount (in cents) which will be charged.</param> /// <param name="currency">ISO 4217 formatted currency code.</param> /// <param name="description">The description.</param> /// <param name="fee">A Fee</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> public async Task <Transaction> CreateWithTokenAndFeeAsync(String token, int amount, String currency, String description, Fee fee) { ValidationUtils.ValidatesToken(token); ValidationUtils.ValidatesAmount(amount); ValidationUtils.ValidatesCurrency(currency); ValidationUtils.ValidatesFee(fee); String srcValue = String.Format("{0}-{1}", PaymillContext.GetProjectName(), PaymillContext.GetProjectVersion()); return(await createAsync(null, new UrlEncoder().EncodeObject(new { Token = token, Amount = amount, Currency = currency, source = srcValue, description = description, Fee_Amount = fee != null ? fee.Amount : null, Fee_Payment = fee != null ? fee.Payment : null }))); }
public async Task <string> Save([FromBody] string paymentToken) { if (ModelState.IsValid) { var paymentExceptionMessage = string.Empty; try { var paymillContext = new PaymillContext("337e3a54ea95ca8740e3dc035ee02172"); var paymentService = paymillContext.PaymentService; var payment = await paymentService.CreateWithTokenAsync(paymentToken); } catch (Exception exc) { paymentExceptionMessage = exc.Message; } return(paymentExceptionMessage); } return(FormatValidationErrors(ModelState.Values)); }
/// <summary> /// Authorizes the given amount with the given Payment. Works only for credit cards. Direct debit not supported. /// </summary> /// <param name="payment">The Payment itself (only creditcard-object)</param> /// <param name="amount">Amount (in cents) which will be charged.</param> /// <param name="currency">ISO 4217 formatted currency code.</param> /// <returns>Transaction object with the Preauthorization as sub object.</returns> public async Task <Preauthorization> CreateWithPaymentAsync(Payment payment, int amount, String currency) { ValidationUtils.ValidatesPayment(payment); ValidationUtils.ValidatesAmount(amount); ValidationUtils.ValidatesCurrency(currency); String srcValue = String.Format("{0}-{1}", PaymillContext.GetProjectName(), PaymillContext.GetProjectVersion()); Transaction replyTransaction = await createSubClassAsync <Transaction>(Resource.Preauthorizations.ToString(), new UrlEncoder().EncodeObject(new { Payment = payment.Id, Amount = amount, Currency = currency, Source = srcValue })); if (replyTransaction != null) { return(replyTransaction.Preauthorization); } return(null); }
public void Initialize() { _paymill = new PaymillContext("9a4129b37640ea5f62357922975842a1"); }
public void Initialize() { _paymill = new PaymillContext("0ecdb65b3c7caeb2e10932699dacd50c"); }