Bước 1: Mở website đang chạy thật (tích hợp version 1.0). Lấy các thông số
MerchantID, Accesscode, Hashcode (SECURE_SECRET) gửi lại cho OnePAY (vào mail:
[email protected] ) để nhận được thông
tin
tài khoản thật của phiên bản version 2.0.
Bước 2: Trong module đang chạy thật tìm đến form thanh toán. Update giá trị
của
đối số vpc_Version từ
"1" thành
"2" .
Bước 3: Tải module Nội địa C#.net v2.0 xuống tại
đây ,
module Quốc tế C#.net v2.0 xuống tại
đây .
Thêm
file “VPCRequest.cs” vào project cũ
Bước 4: Mở file do.jsp trên website đang chạy thật (tích hợp version 1.0).
Update
các
hàm
giống file vpc_do.aspx.cs của version 2.0. Cụ thể:
-Viết lại hàm “Button1_Click()” là hàm chuyển sang cổng thanh toán
Thay bằng hàm trên file mới, và lấy các giá trị thông số và dữ liệu cũ vào hàm mới:
string SECURE_SECRET = "A3EFDFABA8653DF2342E8DAC29B51AF0";
// Khoi tao lop thu vien va gan gia tri cac tham so gui sang cong thanh toan
VPCRequest conn = new VPCRequest(virtualPaymentClientURL.Text);
conn.SetSecureSecret(SECURE_SECRET);
// Add the Digital Order Fields for the functionality you wish to use
// Core Transaction Fields
conn.AddDigitalOrderField("Title", "onepay paygate");
conn.AddDigitalOrderField("vpc_Locale", "vn");//Chon ngon ngu hien thi tren cong thanh toan (vn/en)
conn.AddDigitalOrderField("vpc_Version", vpc_Version.Text);
conn.AddDigitalOrderField("vpc_Command", vpc_Command.Text);
conn.AddDigitalOrderField("vpc_Merchant", vpc_Merchant.Text);
conn.AddDigitalOrderField("vpc_AccessCode", vpc_AccessCode.Text);
conn.AddDigitalOrderField("vpc_MerchTxnRef", vpc_MerchTxnRef.Text);
conn.AddDigitalOrderField("vpc_OrderInfo", vpc_OrderInfo.Text);
conn.AddDigitalOrderField("vpc_Amount", vpc_Amount.Text);
conn.AddDigitalOrderField("vpc_Currency", vpc_Currency.Text);
conn.AddDigitalOrderField("vpc_ReturnURL", vpc_ReturnURL.Text);
// Thong tin them ve khach hang. De trong neu khong co thong tin
conn.AddDigitalOrderField("vpc_SHIP_Street01", "194 Tran Quang Khai");
conn.AddDigitalOrderField("vpc_SHIP_Provice", "Hanoi");
conn.AddDigitalOrderField("vpc_SHIP_City", "Hanoi");
conn.AddDigitalOrderField("vpc_SHIP_Country", "Vietnam");
conn.AddDigitalOrderField("vpc_Customer_Phone", "043966668");
conn.AddDigitalOrderField("vpc_Customer_Email", "[email protected] ");
conn.AddDigitalOrderField("vpc_Customer_Id", "onepay_paygate");
// Dia chi IP cua khach hang
conn.AddDigitalOrderField("vpc_TicketNo", vpc_TicketNo.Text);
// Chuyen huong trinh duyet sang cong thanh toan
String url = conn.Create3PartyQueryString();
Page.Response.Redirect(url);
Bước 5: : Mở file “vpc_dr.aspx.cs” trên website đang chạy thật (tích hợp
version 1.0). Update các hàm giống file “vpc_dr.aspx.cs” của version 2.0. Cụ thể:
-Update lại thư viện sử dụng như dưới:
Viết lại hàm “Page_Load()” là hàm chuyển sang cổng thanh toán
Thay bằng hàm trên file mới, và lấy các giá trị thông số và dữ liệu cũ vào hàm mới:
string SECURE_SECRET = "A3EFDFABA8653DF2342E8DAC29B51AF0";
string hashvalidateResult = "";
// Khoi tao lop thu vien
VPCRequest conn = new VPCRequest("http://onepay.vn");
conn.SetSecureSecret(SECURE_SECRET);
// Xu ly tham so tra ve va kiem tra chuoi du lieu ma hoa
hashvalidateResult = conn.Process3PartyResponse(Page.Request.QueryString);
// Lay gia tri tham so tra ve tu cong thanh toan
String vpc_TxnResponseCode = conn.GetResultField("vpc_TxnResponseCode", "Unknown");
string amount = conn.GetResultField("vpc_Amount", "Unknown");
string localed = conn.GetResultField("vpc_Locale", "Unknown");
string command = conn.GetResultField("vpc_Command", "Unknown");
string version = conn.GetResultField("vpc_Version", "Unknown");
string cardBin = conn.GetResultField("vpc_Card", "Unknown");
string orderInfo = conn.GetResultField("vpc_OrderInfo", "Unknown");
string merchantID = conn.GetResultField("vpc_Merchant", "Unknown");
string authorizeID = conn.GetResultField("vpc_AuthorizeId", "Unknown");
string merchTxnRef = conn.GetResultField("vpc_MerchTxnRef", "Unknown");
string transactionNo = conn.GetResultField("vpc_TransactionNo", "Unknown");
string txnResponseCode = vpc_TxnResponseCode;
string message = conn.GetResultField("vpc_Message", "Unknown");
// Sua lai ham check chuoi ma hoa du lieu
if (hashvalidateResult == "INVALIDATED")
{
vpc_Result.Text = "Transaction is pending";
hashvalidateResult = "INVALIDATED";
}
else
{
if (txnResponseCode.Trim() == "0")
{
vpc_Result.Text = "Transaction was paid successful";
}
else
{
vpc_Result.Text = "Transaction was not paid successful";
}
hashvalidateResult = "CORRECTED";
}
Bước 6: Cập nhận lại giá trị thông số SECURE_SECRET do OnePAY gửi lại vào file
DO và file DR.
Bước 7: Deploy website trên web server. Thử lại quá trình thanh toán.
Thank you