Beispiel #1
0
        public override PaymentResult Refund(Money money, string transRef, PaymentOptions options)
        {
            if (options.GetType() != typeof(PayDollarPaymentOptions))
            {
                throw new ArgumentException("options parameter needs to be type of PayDollarPaymentOptions.");
            }
            PayDollarPaymentOptions opt = (PayDollarPaymentOptions)options;
            string url = string.Format("{0}/merchant/api/onlineApi.jsp", Parameters.Options.BaseUrl);
            var    sb  = new StringBuilder();

            sb.Append("merchantId=");
            sb.Append(opt.MerchantId);
            sb.Append("&loginId=");
            sb.Append(opt.LoginId);
            sb.Append("&password="******"&actionType=OnlineReversal");
            sb.Append("&payRef=");
            sb.Append(transRef);
            sb.Append("&amount=");
            sb.Append(money.Amount);
            var result = HttpPost(url, sb.ToString(), "POST", "application/x-www-form-urlencoded");
            var q      = System.Web.HttpUtility.ParseQueryString(result);
            var r      = new PayDollarPaymentResult();

            r.SuccessCode = q["resultCode"];
            r.Message     = q["errMsg"];
            r.GatewayRef  = q["payRef"];
            r.MerchantRef = q["ref"];

            if (!string.IsNullOrWhiteSpace(q["amt"]))
            {
                r.Amount = decimal.Parse(q["amt"]);
            }

            r.OrderStatus = q["orderStatus"];
            r.Currency    = q["cur"];
            return(r);
        }
Beispiel #2
0
        /// <summary>
        /// make payment or hold payment (AUTH)
        /// </summary>
        /// <param name="money"></param>
        /// <param name="card"></param>
        /// <param name="paymentType">H: hold only; N: payment</param>
        /// <param name="opt"></param>
        /// <returns></returns>
        private PayDollarPaymentResult MakePayment(Money money, CreditCard card, string paymentType, PayDollarPaymentOptions opt)
        {
            opt.PaymentType = paymentType;
            string url = string.Format("{0}/directPay/payComp.jsp", Parameters.Options.BaseUrl);

            opt.Amount   = money.Amount;
            opt.Currency = money.Currency;

            string hash = string.Empty;

            //apply to authorized merchant only
            if (!string.IsNullOrEmpty(opt.SecretKey))
            {
                hash = GetSecureHash(opt);
            }
            var sb = new StringBuilder();

            sb.Append("merchantId=");
            sb.Append(opt.MerchantId);
            sb.Append("&loginId=");
            sb.Append(opt.LoginId);
            sb.Append("&password="******"&orderRef=");
            sb.Append(opt.MerchantRef);
            sb.Append("&payType=");
            sb.Append(opt.PaymentType);
            sb.Append("&amount=");
            sb.Append(money.Amount);
            sb.Append("&currCode=");
            sb.Append(money.Currency);
            sb.Append("&pMethod=");
            sb.Append(opt.PaymentMethod);
            sb.Append("&epMonth=");
            sb.Append(card.ExpiryMonth);
            sb.Append("&epYear=");
            sb.Append(card.ExpiryYear);
            sb.Append("&cardNo=");
            sb.Append(card.CardNo);
            sb.Append("&cardHolder=");
            sb.Append(card.HolderName);
            sb.Append("&securityCode=");
            sb.Append(card.CVV);
            sb.Append("&remark=");
            sb.Append(opt.TransactionRemark);
            if (!string.IsNullOrEmpty(hash))
            {
                sb.Append("&secureHash=");
                sb.Append(hash);
            }
            var result = HttpPost(url, sb.ToString(), "POST", "application/x-www-form-urlencoded");
            var q      = System.Web.HttpUtility.ParseQueryString(result);
            var r      = new PayDollarPaymentResult();

            r.SuccessCode = q["successcode"];
            r.Message     = q["errMsg"];
            r.GatewayRef  = q["PayRef"];
            r.MerchantRef = q["Ref"];
            r.Src         = q["src"];
            r.Prc         = q["prc"];
            if (!string.IsNullOrWhiteSpace(q["Amt"]))
            {
                r.Amount = decimal.Parse(q["Amt"]);
            }
            r.Holder = q["Holder"];
            if (!string.IsNullOrWhiteSpace(q["TxTime"]))
            {
                r.TransactionTime = DateTime.Parse(q["TxTime"]);
            }
            r.BankRef      = q["ord"];
            r.ApprovalCode = q["AuthId"];
            r.Currency     = q["Cur"];
            return(r);
        }