public String ReAuthorizeOrder(int OrderNumber) { // Once the PayPal honor period (3 days) is over, PayPal no longer ensures that 100% // of the funds will be available. A ReAuthorize will start a new settle period. String result = String.Empty; String PNREF = String.Empty; String TransID = String.Empty; Decimal OrderTotal = 0; using (var con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (var rs = DB.GetRS("select * from orders with (NOLOCK) where OrderNumber=" + OrderNumber.ToString(), con)) { if (rs.Read()) { PNREF = DB.RSField(rs, "AuthorizationPNREF"); TransID = Regex.Match(PNREF, "(?<=AUTH=)[0-9A-Z]+", RegexOptions.Compiled).ToString(); OrderTotal = DB.RSFieldDecimal(rs, "OrderTotal"); } } } if (TransID.Length == 0 || TransID == "0") { result = "Invalid or Empty Transaction ID"; } else { try { BasicAmountType totalAmount = new BasicAmountType(); totalAmount.Value = Localization.CurrencyStringForGatewayWithoutExchangeRate(OrderTotal); totalAmount.currencyID = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), AppLogic.AppConfig("Localization.StoreCurrency"), true); DoReauthorizationRequestType Reauth = new DoReauthorizationRequestType(); Reauth.Amount = totalAmount; Reauth.AuthorizationID = TransID; Reauth.Version = API_VER; DoReauthorizationReq ReauthReq = new DoReauthorizationReq(); ReauthReq.DoReauthorizationRequest = Reauth; DoReauthorizationResponseType ReauthResponse; ReauthResponse = (DoReauthorizationResponseType)IPayPal.DoReauthorization(ReauthReq); //if (LogToErrorTable) //{ // PayPalController.Log(XmlCommon.SerializeObject(ReauthReq, ReauthReq.GetType()), "DoReauthorization Request"); // PayPalController.Log(XmlCommon.SerializeObject(ReauthResponse, ReauthResponse.GetType()), "DoReauthorization Response"); //} if (ReauthResponse != null && ReauthResponse.Ack.ToString().StartsWith("success", StringComparison.InvariantCultureIgnoreCase)) { result = AppLogic.ro_OK; DB.ExecuteSQL("update orders set AuthorizedOn=getdate(), AuthorizationPNREF=AuthorizationPNREF+'|REAU=" + ReauthResponse.AuthorizationID + "' where OrderNumber=" + OrderNumber.ToString()); } else { if (ReauthResponse.Errors != null) { bool first = true; for (int ix = 0; ix < ReauthResponse.Errors.Length; ix++) { if (!first) { result += ", "; } result += "Error: [" + ReauthResponse.Errors[ix].ErrorCode + "] " + ReauthResponse.Errors[ix].LongMessage; first = false; } } } } catch { result = "NO RESPONSE FROM GATEWAY!"; } } return(result); }