/// <summary> /// Cancel a transaction that has not yet been approved /// </summary> public static void Cancel(long id) { try { //Prepare the objet to send for the annulment var cancellation = new CancellationRequestModel { Id = id }; //Send request for cancel transaction using transaction id var response = connection.PostCall <bool>("/api/Cancel", cancellation, Configurations.Lang); Console.WriteLine(response ? "Transaccion cancelada" : "La transaccion no pudo ser cancelada"); } catch (PayPhoneWebException e) { //All call make to PayPhone need to be inside a try catch //Verify if error returned was Unhautorized and get new token if (RefreshToken(e)) { //Make the same call again after restore the invalid token for new one Cancel(id); } PrintErrors(e); } catch (Exception e) { //Always is recomended have generic exception for possibles errors generate from your code Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Exception " + e.Message); Console.ResetColor(); } }
/// <summary> /// Send request for reimbursement by transaction id /// </summary> /// <param name="idTx">Transaction id get from PayPhone</param> public static void Reimbursemet(long txId) { try { //Prepare the objet to send for the annulment var cancellation = new CancellationRequestModel { Id = txId }; //Send reimbursement by transaction id request var response = connection.PostCall <bool>("/api/Reverse", cancellation, Configurations.Lang); //save the reimbursement id returned if (response) { Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine($"El reverso ha sido realizado satisfactoriamente"); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"La transaccion no pudo ser reversada"); } Console.ResetColor(); } catch (PayPhoneWebException e) { //All call make to PayPhone need to be inside a try catch //Verify if error returned was Unhautorized and get new token if (RefreshToken(e)) { //Make the same call again after restore the invalid token for new one Reimbursemet(txId); } PrintErrors(e); } catch (Exception e) { //Always is recomended have generic exception for possibles errors generate from your code Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Exception " + e.Message); Console.ResetColor(); } }
/// <summary> /// Annull transaction by transction id get from PayPHone /// </summary> /// <param name="txId">Transction id get from PayPHone</param> public static void Annulment(long txId) { //Prepare the objet to send for the annulment var cancellation = new CancellationRequestModel { Id = txId }; try { //Send annulment request with object created above var response = connection.PostCall <AnnulResponseModel>("/api/Annul", cancellation, Configurations.Lang); //Save the annulment id for get status later AnnulmentId = response.Id; Console.WriteLine($"Identificador de la anulación: {AnnulmentId}"); } catch (PayPhoneWebException e) { //All call make to PayPhone need to be inside a try catch //Verify if error returned was Unhautorized and get new token if (RefreshToken(e)) { //Make the same call again after restore the invalid token for new one Annulment(txId); } PrintErrors(e); } catch (Exception e) { //Always is recomended have generic exception for possibles errors generate from your code Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Exception " + e.Message); Console.ResetColor(); } }