public processor_cc_txn_response sp_refund_payment(int payment_id) { #region Check-for-Null-Values if (string_null_or_empty(_token_string)) { log("sp_refund_payment null value detected for token, please authenticate", true); return null; } if (payment_id <= 0) { log("sp_refund_payment payment_id must be greater than zero", true); return null; } #endregion #region Variables rest_response refund_payment_rest_resp = new rest_response(); response refund_payment_resp = new response(); processor_cc_txn_response curr_resp = new processor_cc_txn_response(); #endregion #region Process-Request refund_payment_rest_resp = rest_client<simple_payment>( _endpoint_url + "payment/refund/" + payment_id, "POST", null, null); if (refund_payment_rest_resp == null) { log("sp_refund_payment null response from rest_client for refund call", true); return null; } if (refund_payment_rest_resp.status_code != 200 && refund_payment_rest_resp.status_code != 201) { log("sp_refund_payment rest_client returned status other than 200/201 for refund call", true); return null; } try { refund_payment_resp = deserialize_json<response>(refund_payment_rest_resp.output_body_string); } catch (Exception) { log("sp_refund_payment unable to deserialize response from server for refund call", true); return null; } if (!refund_payment_resp.success) { log("sp_refund_payment success false returned from server for refund call", true); return null; } try { curr_resp = deserialize_json<processor_cc_txn_response>(refund_payment_resp.data.ToString()); log("sp_refund_payment response retrieved"); } catch (Exception) { log("sp_refund_payment unable to deserialize processor response", true); return null; } #endregion #region Enumerate log("==============================================================================="); log("Refund response received: " + curr_resp.is_approved); log(" " + curr_resp.cc_type + " " + curr_resp.cc_redacted_number + " " + curr_resp.cc_expiry_month + "/" + curr_resp.cc_expiry_year + " " + decimal_tostring(curr_resp.amount)); log(" Approval " + curr_resp.approval_code + " Status " + curr_resp.status_code + " " + curr_resp.status_message + " " + curr_resp.transaction_state); log(" Response time " + curr_resp.processor_time_ms + "ms"); if (curr_resp.is_approved) { log(" Payment ID " + curr_resp.payment_id); log(" Stored Payment GUID " + curr_resp.stored_payment_guid); } log("==============================================================================="); #endregion return curr_resp; }
public static bool track2_payment() { #region Variables string track2 = ""; decimal amount = 0m; string notes = ""; processor_cc_txn_response curr_resp = new processor_cc_txn_response(); #endregion #region Populate-Variables Console.Write("Track 2 Data: "); track2 = Console.ReadLine(); Console.Write("Notes: "); notes = Console.ReadLine(); Console.Write("Amount: "); try { amount = Convert.ToDecimal(Console.ReadLine()); } catch (Exception) { Console.WriteLine("Unable to convert amount from string to decimal."); return false; } #endregion #region Check-for-Null-or-Bad-Values if (string_null_or_empty(track2)) { Console.WriteLine("Track 1 field was not populated."); return false; } if (amount <= 0) { Console.WriteLine("Amount must be greater than zero."); return false; } #endregion #region Process-Request curr_resp = slidepay.sp_track2_payment( track2, notes, amount); if (curr_resp == null) { Console.WriteLine("Null response for keyed payment request."); return false; } Console.WriteLine("==============================================================================="); Console.WriteLine("Payment response received: " + curr_resp.is_approved); Console.WriteLine(" " + curr_resp.cc_type + " " + curr_resp.cc_redacted_number + " " + curr_resp.cc_expiry_month + "/" + curr_resp.cc_expiry_year + " " + decimal_tostring(curr_resp.amount)); Console.WriteLine(" Approval " + curr_resp.approval_code + " Status " + curr_resp.status_code + " " + curr_resp.status_message + " " + curr_resp.transaction_state); Console.WriteLine(" Response time " + curr_resp.processor_time_ms + "ms"); Console.WriteLine(" Card present " + curr_resp.cc_present); if (curr_resp.is_approved) { Console.WriteLine(" Payment ID " + curr_resp.payment_id); Console.WriteLine(" Stored Payment GUID " + curr_resp.stored_payment_guid); } Console.WriteLine("==============================================================================="); #endregion return curr_resp.is_approved; }
public static bool refund_payment() { #region Variables int payment_id = 0; processor_cc_txn_response curr_resp = new processor_cc_txn_response(); #endregion #region Populate-Variables Console.Write("Payment ID: "); try { payment_id = Convert.ToInt32(Console.ReadLine()); } catch (Exception) { Console.WriteLine("Unable to convert payment ID from string to integer."); return false; } #endregion #region Check-for-Null-or-Bad-Values if (payment_id <= 0) { Console.WriteLine("Payment ID must be greater than zero."); return false; } #endregion #region Process-Request curr_resp = slidepay.sp_refund_payment(payment_id); if (curr_resp == null) { Console.WriteLine("Null response for refund request."); return false; } Console.WriteLine("==============================================================================="); Console.WriteLine("Refund response received: " + curr_resp.is_approved); Console.WriteLine(" " + curr_resp.cc_type + " " + curr_resp.cc_redacted_number + " " + curr_resp.cc_expiry_month + "/" + curr_resp.cc_expiry_year + " " + decimal_tostring(curr_resp.amount)); Console.WriteLine(" Approval " + curr_resp.approval_code + " Status " + curr_resp.status_code + " " + curr_resp.status_message + " " + curr_resp.transaction_state); Console.WriteLine(" Response time " + curr_resp.processor_time_ms + "ms"); if (curr_resp.is_approved) { Console.WriteLine(" Payment ID " + curr_resp.payment_id); Console.WriteLine(" Stored Payment GUID " + curr_resp.stored_payment_guid); } Console.WriteLine("==============================================================================="); #endregion return curr_resp.is_approved; }
public processor_cc_txn_response sp_stored_payment( string guid, string notes, decimal amount) { #region Check-for-Null-Values if (string_null_or_empty(_token_string)) { log("sp_stored_payment null value detected for token, please authenticate", true); return null; } if (string_null_or_empty(guid) || string_null_or_empty(notes)) { log("sp_stored_payment null value detected in one of the input values", true); return null; } if (amount <= 0) { log("sp_stored_payment amount must be greater than zero", true); return null; } #endregion #region Variables rest_response key_payment_rest_resp = new rest_response(); response key_payment_resp = new response(); processor_cc_txn_response curr_resp = new processor_cc_txn_response(); #endregion #region Create-Request-Body simple_payment curr = new simple_payment(); curr.stored_payment_guid = guid; curr.notes = notes; curr.amount = amount; curr.method = "CreditCard"; #endregion #region Process-Request key_payment_rest_resp = rest_client<simple_payment>( _endpoint_url + "payment/simple", "POST", null, curr); if (key_payment_rest_resp == null) { log("sp_stored_payment null response from rest_client for simple payment call", true); return null; } if (key_payment_rest_resp.status_code != 200 && key_payment_rest_resp.status_code != 201) { log("sp_stored_payment rest_client returned status other than 200/201 for simple payment call", true); return null; } try { key_payment_resp = deserialize_json<response>(key_payment_rest_resp.output_body_string); } catch (Exception) { log("sp_stored_payment unable to deserialize response from server for simple payment call", true); return null; } try { curr_resp = deserialize_json<processor_cc_txn_response>(key_payment_resp.data.ToString()); log("sp_stored_payment response retrieved"); } catch (Exception) { log("sp_stored_payment unable to deserialize processor response", true); return null; } #endregion #region Enumerate log("==============================================================================="); log("Payment response received: " + curr_resp.is_approved); log(" " + curr_resp.cc_type + " " + curr_resp.cc_redacted_number + " " + curr_resp.cc_expiry_month + "/" + curr_resp.cc_expiry_year + " " + decimal_tostring(curr_resp.amount)); log(" Approval " + curr_resp.approval_code + " Status " + curr_resp.status_code + " " + curr_resp.status_message + " " + curr_resp.transaction_state); log(" Response time " + curr_resp.processor_time_ms + "ms"); log(" Card present " + curr_resp.cc_present); if (curr_resp.is_approved) { log(" Payment ID " + curr_resp.payment_id); log(" Stored Payment GUID " + curr_resp.stored_payment_guid); } log("==============================================================================="); #endregion return curr_resp; }
public static bool key_payment() { #region Variables string ccn = ""; string exp_mo = ""; string exp_yr = ""; string cvv2 = ""; string zip = ""; decimal amount = 0m; string notes = ""; processor_cc_txn_response curr_resp = new processor_cc_txn_response(); #endregion #region Populate-Variables Console.Write("Credit Card Number: "); ccn = Console.ReadLine(); Console.Write("Expiration Month: "); exp_mo = Console.ReadLine(); Console.Write("Expiration Year: "); exp_yr = Console.ReadLine(); Console.Write("CVV2: "); cvv2 = Console.ReadLine(); Console.Write("Billing Zip Code: "); zip = Console.ReadLine(); Console.Write("Notes: "); notes = Console.ReadLine(); Console.Write("Amount: "); try { amount = Convert.ToDecimal(Console.ReadLine()); } catch (Exception) { Console.WriteLine("Unable to convert amount from string to decimal."); return false; } #endregion #region Check-for-Null-or-Bad-Values if (string_null_or_empty(ccn) || string_null_or_empty(exp_mo) || string_null_or_empty(exp_yr) || string_null_or_empty(cvv2) || string_null_or_empty(zip) || string_null_or_empty(notes)) { Console.WriteLine("One or more fields were not populated."); return false; } if (amount <= 0) { Console.WriteLine("Amount must be greater than zero."); return false; } #endregion #region Process-Request curr_resp = slidepay.sp_key_payment( ccn, exp_mo, exp_yr, cvv2, zip, notes, amount); if (curr_resp == null) { Console.WriteLine("Null response for keyed payment request."); return false; } Console.WriteLine("==============================================================================="); Console.WriteLine("Payment response received: " + curr_resp.is_approved); Console.WriteLine(" " + curr_resp.cc_type + " " + curr_resp.cc_redacted_number + " " + curr_resp.cc_expiry_month + "/" + curr_resp.cc_expiry_year + " " + decimal_tostring(curr_resp.amount)); Console.WriteLine(" Approval " + curr_resp.approval_code + " Status " + curr_resp.status_code + " " + curr_resp.status_message + " " + curr_resp.transaction_state); Console.WriteLine(" Response time " + curr_resp.processor_time_ms + "ms"); Console.WriteLine(" Card present " + curr_resp.cc_present); if (curr_resp.is_approved) { Console.WriteLine(" Payment ID " + curr_resp.payment_id); Console.WriteLine(" Stored Payment GUID " + curr_resp.stored_payment_guid); } Console.WriteLine("==============================================================================="); #endregion return curr_resp.is_approved; }