There are two payment modes: PayPal and credit card. PayPal payment submits the payment form data to the specified IPN, which processes and provides corresponding pages. Credit card payment includes single payment and monthly subscription payment, monthly subscription payment automatically transfers money from your account every month. If you do not cancel the payment, the payment will continue.
Both payment methods have a test environment. After the upgrade is made in the test environment, the formal environment is accessible. You can search for the specific test environment on the Internet.
The key of two payment methods is how to submit data to the specified gateway and receive the data returned by the gateway. One is the form and the other is xml, A very practical method is used as follows:
PostXML
Private string PostXml (string url, string strPost)
{
String result = "";
StreamWriter myWriter = null;
HttpWebRequest objRequest = (HttpWebRequest) WebRequest. Create (url );
ObjRequest. Method = "POST ";
ObjRequest. ContentLength = strPost. Length;
ObjRequest. ContentType = "text/xml"; // submit xml
// ObjRequest. ContentType = "application/x-www-form-urlencoded"; // submit the form
Try
{
MyWriter = new StreamWriter (objRequest. GetRequestStream ());
MyWriter. Write (strPost );
}
Catch (Exception e)
{
Return e. Message;
}
Finally
{
MyWriter. Close ();
}
HttpWebResponse objResponse = (HttpWebResponse) objRequest. GetResponse ();
Using (StreamReader sr = new StreamReader (objResponse. GetResponseStream ()))
{
Result = sr. ReadToEnd ();
Sr. Close ();
}
Return result;
}
After the gateway url and the specified parameter string are passed, the information can be submitted to the gateway and the result information is returned. Some of the returned results are string lists, which are truncated by specified characters, and some are returned with a specific xml. Here we will introduce, you can obtain the text by entering the start and end tags as follows:
// Write by: suhanyu
Private string PraseResponseXml (string conents, string start, string end)
{
If (conents. IndexOf (start) = 0 | conents. IndexOf (end) = 0)
{
Return "";
}
Else
{
Int start_position = conents. IndexOf (start) + start. Length;
Int end_position = conents. IndexOf (end );
If (start_position! =-1 & end_position! =-1)
{
Return conents. Substring (start_position, end_position-start_position );
}
Else
{
Return "";
}
}
}
Call:
String refId = this. PraseResponseXml (xmlcode, "<refId>", "</refId> ");
// Xmlcode is a string in xml format
I have done this, reviewed it, and learned it before... Haha...