protected void Submit_Click(object sender, EventArgs e) { // Create request object DoReauthorizationRequestType request = new DoReauthorizationRequestType(); // (Required) Value of a previously authorized transaction identification number returned by PayPal. request.AuthorizationID = authorizationId.Value; // (Required) Amount to reauthorize. CurrencyCodeType currency = (CurrencyCodeType) Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue); request.Amount = new BasicAmountType(currency, amount.Value); // Invoke the API DoReauthorizationReq wrapper = new DoReauthorizationReq(); wrapper.DoReauthorizationRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary <string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the DoReauthorization method in service wrapper object DoReauthorizationResponseType doReauthorizationResponse = service.DoReauthorization(wrapper); // Check for API return status setKeyResponseObjects(service, doReauthorizationResponse); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object DoReauthorizationRequestType request = new DoReauthorizationRequestType(); request.AuthorizationID = authorizationId.Value; CurrencyCodeType currency = (CurrencyCodeType) Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue); request.Amount = new BasicAmountType(currency, amount.Value); // Invoke the API DoReauthorizationReq wrapper = new DoReauthorizationReq(); wrapper.DoReauthorizationRequest = request; PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); DoReauthorizationResponseType doReauthorizationResponse = service.DoReauthorization(wrapper); // Check for API return status setKeyResponseObjects(service, doReauthorizationResponse); }
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); }
// # DoReauthorization API Operation // Authorize a payment public DoReauthorizationResponseType DoReauthorizationAPIOperation() { // Create the DoReauthorizationResponseType object DoReauthorizationResponseType responseDoReauthorizationResponseType = new DoReauthorizationResponseType(); try { // Create the DoAuthorizationReq object DoReauthorizationReq requestDoReauthorization = new DoReauthorizationReq(); // `Amount` to reauthorize which takes mandatory params: // // * `currencyCode` // * `amount` BasicAmountType amount = new BasicAmountType(CurrencyCodeType.USD, "3.00"); // `DoReauthorizationRequest` which takes mandatory params: // // * `Authorization Id` - Value of a previously authorized transaction // identification number returned by PayPal. // * `amount` DoReauthorizationRequestType doReauthorizationRequest = new DoReauthorizationRequestType("9B2288061E685550E", amount); requestDoReauthorization.DoReauthorizationRequest = doReauthorizationRequest; // Create the service wrapper object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); // # API call // Invoke the DoReauthorization method in service wrapper object responseDoReauthorizationResponseType = service.DoReauthorization(requestDoReauthorization); if (responseDoReauthorizationResponseType != null) { // Response envelope acknowledgement string acknowledgement = "DoReauthorization API Operation - "; acknowledgement += responseDoReauthorizationResponseType.Ack.ToString(); logger.Info(acknowledgement + "\n"); Console.WriteLine(acknowledgement + "\n"); // # Success values if (responseDoReauthorizationResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS")) { // Authorization identification number logger.Info("Authorization ID : " + responseDoReauthorizationResponseType.AuthorizationID + "\n"); Console.WriteLine("Authorization ID : " + responseDoReauthorizationResponseType.AuthorizationID + "\n"); } // # Error Values else { List <ErrorType> errorMessages = responseDoReauthorizationResponseType.Errors; foreach (ErrorType error in errorMessages) { logger.Debug("API Error Message : " + error.LongMessage); Console.WriteLine("API Error Message : " + error.LongMessage + "\n"); } } } } // # Exception log catch (System.Exception ex) { // Log the exception message logger.Debug("Error Message : " + ex.Message); Console.WriteLine("Error Message : " + ex.Message); } return(responseDoReauthorizationResponseType); }