SMS Payment
URL Endpoint: https://easypay5.com/APIcardProcREST/v1.0.0/Other/SMSPay
Request Method: POST
Headers:
Session Key is passed to the API via the header:
Content-Type: application/json
Accept: application/json
SessKey: A1842D663E9A4A72XXXXXXXX303541303234373138
This call allows you to create a tinyURL of the widget payment link that will display a message and payment form to the customer. The message and form that is displayed to the customer is easily configured by using the API call options.
This API method allows users to accomplish three typical tasks:
- Send a SMS text with a message and Payment Link
- Send an email with message and Payment Link
- Acquire the Payment Link and use it internally or externally
For more details on the use of Text to Pay as well as some sample code is available on our documentation site located at https://easypaysoftware.com/en/text-to-pay.
Copied
{
"Msg": {
"Person": {
"Firstname": "EasyPay",
"Lastname": "Tester",
"Company": "",
"Title": "",
"Url": "",
"BillIngAdress": {
"Address1": "123 Fake St.",
"Address2": "",
"City": "Portland",
"State": "ME",
"ZIP": "04106",
"Country": "USA"
},
"Email": "testing@here.com",
"Phone": "2076885025"
},
"MessageType": "TEXT",
"RefID": "52520ABC",
"RPGUID": "4c269391-a698-4e10-a1a8-0353ee80d1a6",
"MessageBody": "",
"AcctHolderID": 0,
"Amount": 50.00,
"ConsentID": 0,
"DueOn": "1/12/2025",
"EINDEX": "100",
"MerchID": 1,
"TXID": 0,
"WType": "SW",
"RedirectURL": "https://easypay7.com/PostingApp",
"WidgetURL": "https://easypay5.com/stdwidget",
"ExpiresOn": "2025-10-05",
"SingleUse": 0,
"OptParam": "VISIBLE|1EE7|READONLY|0000|STYLES|0000|OPTIONS|0601|COLORS|#ffffff,#428bca,#007bff,#212121,#ffffff,#212121,#ffffff",
"Questions": [
{
}
]
}
}
{
"SMSPaymentResult": {
"ErrCode": 0,
"ErrMsg": "",
"FunctionOk": true,
"PaymentUrl": null,
"RespMsg": "Text Sent Successfully to 2078995025"
}
}
Copied
private void RESTSMSPay()
{
string SessKey = "70826FC89809414BB4303231333441303331343335";
var p = new api_Person();
var b = new api_Address();
var a = new api_SMSPayment();
p.Firstname = "John";
p.Lastname = "Doe";
p.Company = "";
p.Title = "";
p.Url = "";
b.Address1 = "1307 Broad Hollow Road";
b.Address2 = "";
b.City = "PORTLAND";
b.State = "ME";
b.ZIP = "11747";
b.Country = "USA";
p.BillIngAdress = b;
p.Email = ""; //when MessageType = EMAIL, the message will be sent here
p.Phone = "";//when MessageType = TEXT, the message will be sent here
a.Person = p;
a.MessageType = "URLONLY"; //Valid options = TEXT, EMAIL, or URLONLY
a.RefID = "12345";
a.RPGUID = "ABC123";
a.MessageBody = "";//Custom Message: example, 'You have a payment due.'
a.AcctHolderID = 0;
a.Amount = 25;
a.ConsentID = 0;
a.DueOn = DateTime.Parse("3/12/2025");
a.EINDEX = "300";
a.MerchID = 1;
a.TXID = 0;
a.WType = "SW";
a.RedirectURL = "https://easypay7.com/PostingApp"; //where to redirect after processing payment form
a.WidgetURL = "https://easypay5.com/stdwidget/"; //endpoint of your widget
a.OptParam = "VISIBLE|1EE7|READONLY|0000|STYLES|0000|OPTIONS|0601"; //Optional Widget Parameters, not available in the object - pipe (|) delimited string
string json = JsonConvert.SerializeObject(a);
byte[] data = Encoding.UTF8.GetBytes(json);
// create Request
WebRequest request = WebRequest.Create("https://easypay5.com/APIcardProcREST/v1.0.0/Other/SMSPay");
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = data.Length;
// use your session key obtained when you authenticated
request.Headers.Add("SessKey: " + SessKey);
string Myheaders = request.Headers.ToString();
string responseContent = null;
// Using the Try block will catch communication errors
try
{
using (Stream stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
using (WebResponse response = request.GetResponse())
{
using (Stream stream = response.GetResponseStream())
{
using (StreamReader sr99 = new StreamReader(stream))
{
responseContent = sr99.ReadToEnd();
}
}
}
}
catch (Exception ee)
{
MessageBox.Show("Problem communicating with EasyPay Service:" + ee.Message);
/// important to insert your Logging function here
return;
}
// Check for null Response as this would be a critical communication error as well
if (responseContent == null)
{
MessageBox.Show("Critical Error!");
/// important to insert your Logging function here
return;
}
/// develop Response Object
var Result = JsonConvert.DeserializeObject<dynamic>(responseContent);
bool FunctionOk = (bool)Result.FunctionOk;
int ErrCode = (int)Result.ErrCode;
string ErrMsg = (string)Result.ErrMsg;
string RespMsg = (string)Result.RespMsg;
//Check for unexpected Errors on cloud servers. If errors found Stop Processing and check ErrorCodes
if (!FunctionOk)
{
MessageBox.Show(RespMsg + " " + ErrCode + " " + ErrMsg);
/// important to insert your Logging function here
return;
}
//Successful
MessageBox.Show("Success");
/// important to insert your Logging function here
return;
}