public PaymentCallback Notify(RenderContext context) { var forms = context.Request.Forms; var data = new BraintreeAPI(Setting).Parse(forms["bt_signature"], forms["bt_payload"]); var result = new PaymentCallback(); if (data != null) { var transactions = data.Subject.Subscription.Transactions; for (int i = 0; i < transactions.Length; i++) { var strPaymentRequestId = transactions[i].Transaction.OrderId; Guid paymentRequestId; if (Guid.TryParse(strPaymentRequestId, out paymentRequestId)) { result.RequestId = paymentRequestId; if (string.Equals(data.kind, "transaction_settled", StringComparison.OrdinalIgnoreCase)) { result.Status = PaymentStatus.Paid; } else { result.Status = PaymentStatus.Cancelled; } } } } return(result); }
public PaymentStatusResponse checkStatus(PaymentRequest request) { PaymentStatusResponse result = new PaymentStatusResponse(); var id = request.ReferenceId; var resp = new BraintreeAPI(Setting).Find(id); result = GetPaidStatus(result, resp.Transaction.Status); return(result); }
public IPaymentResponse CreateTransaction(RenderContext context) { if (this.Setting == null) { return(null); } decimal amount; RedirectResponse res = null; try { amount = Convert.ToDecimal(context.Request.Forms["amount"]); var nonce = context.Request.Forms["payment_method_nonce"]; var request = new TransactionRequest { Transaction = new TransactionRequestChildren { Amount = amount, PaymentMethodNonce = nonce, Options = new TransactionOptionsRequest { SubmitForSettlement = true }, OrderId = context.Request.Forms["orderId"] } }; var result = new BraintreeAPI(Setting).Sale(request); var strPaymentRequestId = context.Request.Forms["orderId"]; Guid paymentRequestId; if (Guid.TryParse(strPaymentRequestId, out paymentRequestId)) { if (result != null && result.Transaction.Status.Equals("submitted_for_settlement", StringComparison.OrdinalIgnoreCase)) { res = new RedirectResponse(Setting.SucceedRedirectURL, paymentRequestId); res.paymemtMethodReferenceId = result.Transaction.Id; } } } catch (FormatException e) { Kooboo.Data.Log.Instance.Exception.WriteException(e); } return(res); }
public PaymentCallback CreateTransaction(RenderContext context) { decimal amount; PaymentCallback res = null; try { amount = Convert.ToDecimal(context.Request.GetValue("amount")); var nonce = context.Request.GetValue("nonce"); var orderId = context.Request.GetValue("orderId"); var request = new TransactionRequest { Transaction = new TransactionRequestChildren { Amount = amount, PaymentMethodNonce = nonce, Options = new TransactionOptionsRequest { SubmitForSettlement = true }, OrderId = orderId } }; var result = new BraintreeAPI(Setting).Sale(request); var strPaymentRequestId = orderId; Guid paymentRequestId; if (Guid.TryParse(strPaymentRequestId, out paymentRequestId)) { if (result != null && result.Transaction.Status.Equals("submitted_for_settlement", StringComparison.OrdinalIgnoreCase)) { res = new PaymentCallback(); var paymentRequest = PaymentManager.GetRequest(paymentRequestId, context); paymentRequest.ReferenceId = result.Transaction.Id; PaymentManager.UpdateRequest(paymentRequest, context); } } } catch (FormatException e) { Kooboo.Data.Log.Instance.Exception.WriteException(e); } return(res); }
private string GenerateClientToken() { try { if (this.Setting == null) { return(null); } var service = new BraintreeAPI(Setting); return(service.Generate()); } catch (Exception ex) { Kooboo.Data.Log.Instance.Exception.WriteException(ex); return(null); } }