Computer Vision 1
What is Lorem Ipsum?
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Why do we use it?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using ‘Content here, content here’, making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for ‘lorem ipsum’ will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
- PHP
- C#
- Python
<?php
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
date_default_timezone_set('Asia/Ho_Chi_Minh');
$vnp_Url = "https://sandbox.vnpayment.vn/paymentv2/vpcpay.html";
$vnp_Returnurl = "https://localhost/vnpay_php/vnpay_return.php";
$vnp_TmnCode = "";//Mã website tại VNPAY
$vnp_HashSecret = ""; //Chuỗi bí mật
$vnp_TxnRef = $_POST['order_id']; //Mã đơn hàng. Trong thực tế Merchant cần insert đơn hàng vào DB và gửi mã này
sang VNPAY
$vnp_OrderInfo = $_POST['order_desc'];
$vnp_OrderType = $_POST['order_type'];
$vnp_Amount = $_POST['amount'] * 100;
$vnp_Locale = $_POST['language'];
$vnp_BankCode = $_POST['bank_code'];
$vnp_IpAddr = $_SERVER['REMOTE_ADDR'];
//Add Params of 2.0.1 Version
$vnp_ExpireDate = $_POST['txtexpire'];
//Billing
$vnp_Bill_Mobile = $_POST['txt_billing_mobile'];
$vnp_Bill_Email = $_POST['txt_billing_email'];
$fullName = trim($_POST['txt_billing_fullname']);
if (isset($fullName) && trim($fullName) != '') {
$name = explode(' ', $fullName);
$vnp_Bill_FirstName = array_shift($name);
$vnp_Bill_LastName = array_pop($name);
}
$vnp_Bill_Address=$_POST['txt_inv_addr1'];
$vnp_Bill_City=$_POST['txt_bill_city'];
$vnp_Bill_Country=$_POST['txt_bill_country'];
$vnp_Bill_State=$_POST['txt_bill_state'];
// Invoice
$vnp_Inv_Phone=$_POST['txt_inv_mobile'];
$vnp_Inv_Email=$_POST['txt_inv_email'];
$vnp_Inv_Customer=$_POST['txt_inv_customer'];
$vnp_Inv_Address=$_POST['txt_inv_addr1'];
$vnp_Inv_Company=$_POST['txt_inv_company'];
$vnp_Inv_Taxcode=$_POST['txt_inv_taxcode'];
$vnp_Inv_Type=$_POST['cbo_inv_type'];
$inputData = array(
"vnp_Version" => "2.1.0",
"vnp_TmnCode" => $vnp_TmnCode,
"vnp_Amount" => $vnp_Amount,
"vnp_Command" => "pay",
"vnp_CreateDate" => date('YmdHis'),
"vnp_CurrCode" => "VND",
"vnp_IpAddr" => $vnp_IpAddr,
"vnp_Locale" => $vnp_Locale,
"vnp_OrderInfo" => $vnp_OrderInfo,
"vnp_OrderType" => $vnp_OrderType,
"vnp_ReturnUrl" => $vnp_Returnurl,
"vnp_TxnRef" => $vnp_TxnRef,
"vnp_ExpireDate"=>$vnp_ExpireDate,
"vnp_Bill_Mobile"=>$vnp_Bill_Mobile,
"vnp_Bill_Email"=>$vnp_Bill_Email,
"vnp_Bill_FirstName"=>$vnp_Bill_FirstName,
"vnp_Bill_LastName"=>$vnp_Bill_LastName,
"vnp_Bill_Address"=>$vnp_Bill_Address,
"vnp_Bill_City"=>$vnp_Bill_City,
"vnp_Bill_Country"=>$vnp_Bill_Country,
"vnp_Inv_Phone"=>$vnp_Inv_Phone,
"vnp_Inv_Email"=>$vnp_Inv_Email,
"vnp_Inv_Customer"=>$vnp_Inv_Customer,
"vnp_Inv_Address"=>$vnp_Inv_Address,
"vnp_Inv_Company"=>$vnp_Inv_Company,
"vnp_Inv_Taxcode"=>$vnp_Inv_Taxcode,
"vnp_Inv_Type"=>$vnp_Inv_Type
);
if (isset($vnp_BankCode) && $vnp_BankCode != "") {
$inputData['vnp_BankCode'] = $vnp_BankCode;
}
if (isset($vnp_Bill_State) && $vnp_Bill_State != "") {
$inputData['vnp_Bill_State'] = $vnp_Bill_State;
}
//var_dump($inputData);
ksort($inputData);
$query = "";
$i = 0;
$hashdata = "";
foreach ($inputData as $key => $value) {
if ($i == 1) {
$hashdata .= '&' . urlencode($key) . "=" . urlencode($value);
} else {
$hashdata .= urlencode($key) . "=" . urlencode($value);
$i = 1;
}
$query .= urlencode($key) . "=" . urlencode($value) . '&';
}
$vnp_Url = $vnp_Url . "?" . $query;
if (isset($vnp_HashSecret)) {
$vnpSecureHash = hash_hmac('sha512', $hashdata, $vnp_HashSecret);//
$vnp_Url .= 'vnp_SecureHash=' . $vnpSecureHash;
}
$returnData = array('code' => '00'
, 'message' => 'success'
, 'data' => $vnp_Url);
if (isset($_POST['redirect'])) {
header('Location: ' . $vnp_Url);
die();
} else {
echo json_encode($returnData);
}
// vui lòng tham khảo thêm tại code demo
private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
txtOrderDesc.Text = "Nhap noi dung thanh toan";
txtExpire.Text = DateTime.Now.AddMinutes(15).ToString("yyyyMMddHHmmss");
}
}
protected void btnPay_Click(object sender, EventArgs e)
{
//Get Config Info
string vnp_Returnurl = ConfigurationManager.AppSettings["vnp_Returnurl"]; //URL nhan ket qua tra ve
string vnp_Url = ConfigurationManager.AppSettings["vnp_Url"]; //URL thanh toan cua VNPAY
string vnp_TmnCode = ConfigurationManager.AppSettings["vnp_TmnCode"]; //Ma website
string vnp_HashSecret = ConfigurationManager.AppSettings["vnp_HashSecret"]; //Chuoi bi mat
if (string.IsNullOrEmpty(vnp_TmnCode) || string.IsNullOrEmpty(vnp_HashSecret))
{
lblMessage.Text = "Vui lòng cấu hình các tham số: vnp_TmnCode,vnp_HashSecret trong file web.config";
return;
}
//Get payment input
OrderInfo order = new OrderInfo();
//Save order to db
order.OrderId = DateTime.Now.Ticks; // Giả lập mã giao dịch hệ thống merchant gửi sang VNPAY
order.Amount = 100000; // Giả lập số tiền thanh toán hệ thống merchant gửi sang VNPAY 100,000 VND
order.Status = "0"; //0: Trạng thái thanh toán "chờ thanh toán" hoặc "Pending"
order.OrderDesc = txtOrderDesc.Text;
order.CreatedDate = DateTime.Now;
string locale = cboLanguage.SelectedItem.Value;
//Build URL for VNPAY
VnPayLibrary vnpay = new VnPayLibrary();
vnpay.AddRequestData("vnp_Version", VnPayLibrary.VERSION);
vnpay.AddRequestData("vnp_Command", "pay");
vnpay.AddRequestData("vnp_TmnCode", vnp_TmnCode);
vnpay.AddRequestData("vnp_Amount", (order.Amount * 100).ToString()); //Số tiền thanh toán. Số tiền không
mang các ký tự phân tách thập phân, phần nghìn, ký tự tiền tệ. Để gửi số tiền thanh toán là 100,000 VND
(một trăm nghìn VNĐ) thì merchant cần nhân thêm 100 lần (khử phần thập phân), sau đó gửi sang VNPAY
là: 10000000
if (cboBankCode.SelectedItem != null && !string.IsNullOrEmpty(cboBankCode.SelectedItem.Value))
{
vnpay.AddRequestData("vnp_BankCode", cboBankCode.SelectedItem.Value);
}
vnpay.AddRequestData("vnp_CreateDate", order.CreatedDate.ToString("yyyyMMddHHmmss"));
vnpay.AddRequestData("vnp_CurrCode", "VND");
vnpay.AddRequestData("vnp_IpAddr", Utils.GetIpAddress());
if (!string.IsNullOrEmpty(locale))
{
vnpay.AddRequestData("vnp_Locale", locale);
}
else
{
vnpay.AddRequestData("vnp_Locale", "vn");
}
vnpay.AddRequestData("vnp_OrderInfo", "Thanh toan don hang:" + order.OrderId);
vnpay.AddRequestData("vnp_OrderType", orderCategory.SelectedItem.Value); //default value: other
vnpay.AddRequestData("vnp_ReturnUrl", vnp_Returnurl);
vnpay.AddRequestData("vnp_TxnRef", order.OrderId.ToString()); // Mã tham chiếu của giao dịch tại hệ
thống của merchant. Mã này là duy nhất dùng để phân biệt các đơn hàng gửi sang VNPAY. Không được
trùng lặp trong ngày
//Add Params of 2.1.0 Version
vnpay.AddRequestData("vnp_ExpireDate",txtExpire.Text);
//Billing
vnpay.AddRequestData("vnp_Bill_Mobile", txt_billing_mobile.Text.Trim());
vnpay.AddRequestData("vnp_Bill_Email", txt_billing_email.Text.Trim());
var fullName = txt_billing_fullname.Text.Trim();
if (!String.IsNullOrEmpty(fullName))
{
var indexof = fullName.IndexOf(' ');
vnpay.AddRequestData("vnp_Bill_FirstName", fullName.Substring(0, indexof));
vnpay.AddRequestData("vnp_Bill_LastName", fullName.Substring(indexof + 1,
fullName.Length - indexof - 1));
}
vnpay.AddRequestData("vnp_Bill_Address", txt_inv_addr1.Text.Trim());
vnpay.AddRequestData("vnp_Bill_City", txt_bill_city.Text.Trim());
vnpay.AddRequestData("vnp_Bill_Country", txt_bill_country.Text.Trim());
vnpay.AddRequestData("vnp_Bill_State", "");
// Invoice
vnpay.AddRequestData("vnp_Inv_Phone", txt_inv_mobile.Text.Trim());
vnpay.AddRequestData("vnp_Inv_Email", txt_inv_email.Text.Trim());
vnpay.AddRequestData("vnp_Inv_Customer", txt_inv_customer.Text.Trim());
vnpay.AddRequestData("vnp_Inv_Address", txt_inv_addr1.Text.Trim());
vnpay.AddRequestData("vnp_Inv_Company", txt_inv_company.Text);
vnpay.AddRequestData("vnp_Inv_Taxcode", txt_inv_taxcode.Text);
vnpay.AddRequestData("vnp_Inv_Type", cbo_inv_type.SelectedItem.Value);
string paymentUrl = vnpay.CreateRequestUrl(vnp_Url, vnp_HashSecret);
log.InfoFormat("VNPAY URL: {0}", paymentUrl);
Response.Redirect(paymentUrl);
}
// vui lòng tham khảo thêm tại code demo
def payment(request):
if request.method == 'POST':
# Process input data and build url payment
form = PaymentForm(request.POST)
if form.is_valid():
order_type = form.cleaned_data['order_type']
order_id = form.cleaned_data['order_id']
amount = form.cleaned_data['amount']
order_desc = form.cleaned_data['order_desc']
bank_code = form.cleaned_data['bank_code']
language = form.cleaned_data['language']
ipaddr = get_client_ip(request)
# Build URL Payment
vnp = vnpay()
vnp.requestData['vnp_Version'] = '2.1.0'
vnp.requestData['vnp_Command'] = 'pay'
vnp.requestData['vnp_TmnCode'] = settings.VNPAY_TMN_CODE
vnp.requestData['vnp_Amount'] = amount * 100
vnp.requestData['vnp_CurrCode'] = 'VND'
vnp.requestData['vnp_TxnRef'] = order_id
vnp.requestData['vnp_OrderInfo'] = order_desc
vnp.requestData['vnp_OrderType'] = order_type
# Check language, default: vn
if language and language != '':
vnp.requestData['vnp_Locale'] = language
else:
vnp.requestData['vnp_Locale'] = 'vn'
# Check bank_code, if bank_code is empty, customer will be selected bank on VNPAY
if bank_code and bank_code != "":
vnp.requestData['vnp_BankCode'] = bank_code
vnp.requestData['vnp_CreateDate'] = datetime.now().strftime('%Y%m%d%H%M%S')
vnp.requestData['vnp_IpAddr'] = ipaddr
vnp.requestData['vnp_ReturnUrl'] = settings.VNPAY_RETURN_URL
vnpay_payment_url = vnp.get_payment_url(settings.VNPAY_PAYMENT_URL, settings.VNPAY_HASH_SECRET_KEY)
print(vnpay_payment_url)
# Redirect to VNPAY
return redirect(vnpay_payment_url)
else:
print("Form input not validate")
else:
return render(request, "payment.html", {"title": "Thanh toán"})
// vui lòng tham khảo thêm tại code demo
Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of “de Finibus Bonorum et Malorum” (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, “Lorem ipsum dolor sit amet..”, comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from “de Finibus Bonorum et Malorum” by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.