コード例 #1
0
ファイル: PaymillTest.cs プロジェクト: paymill/paymill-net
        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;
            }
        }
コード例 #2
0
        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(""); 
        } 
コード例 #3
0
ファイル: Default.aspx.cs プロジェクト: paymill/paymill-net
 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 
     }
 }
コード例 #4
0
ファイル: TestOffers.cs プロジェクト: paymill/paymill-net
        public void Initialize()
        {

            _paymill = new PaymillContext("9a4129b37640ea5f62357922975842a1");
        }