I am working on a project that need to connect to a payment service, the example code for this payment service company is written in PHP, I have been studying this php code for hours but still can not figure out how to rewrite this in Xojo, please can any one give me a direction what control should I use to complete this?
[code]<?php
//???
function replaceChar($value)
{
$search_list = array(’%2d’, ‘%5f’, ‘%2e’, ‘%21’, ‘%2a’, ‘%28’, ‘%29’);
$replace_list = array(’-’, '’, ‘.’, ‘!’, ‘*’, ‘(’, ‘)’);
$value = str_replace($search_list, $replace_list ,$value);
return $value;
}
//?????
function _getMacValue($hash_key, $hash_iv, $form_array)
{
$encode_str = "HashKey=" . $hash_key;
foreach ($form_array as $key => $value)
{
$encode_str .= "&" . $key . "=" . $value;
}
$encode_str .= "&HashIV=" . $hash_iv;
$encode_str = strtolower(urlencode($encode_str));
$encode_str = _replaceChar($encode_str);
return md5($encode_str);
}
//------------------------------------------???------------------------------------------------------
//???
$trade_no = “StageTest”.time();
//???
$total_amt = “100”;
//???
$trade_desc = “???(??)”;
//???(#)
$item_name = “???(??)”;
//???
$return_url = “http://www.allpay.com.tw/receive.php”;
//???
$client_back_url = “http://www.allpay.com.tw/receive.php”;
//???
$choose_payment = “ALL”;
//???
$needExtraPaidInfo = “Y”;
//Alipay ???
$alipay_item_name = $item_name;
$alipay_item_counts = 1;
$alipay_item_price = $total_amt;
$alipay_email = ‘stage_test@allpay.com.tw’;
$alipay_phone_no = ‘0911222333’;
$alipay_user_name = ‘Stage Test’;
/???(???,???)*******/
//???(???)
$gateway_url = “http://payment-stage.allpay.com.tw/Cashier/AioCheckOut”;
//???
$merchant_id = “2000132”;
//HashKey
$hash_key = “5294y06JbISpM5x9”;
//HashIV
$hash_iv = “v77hoKGq4kWxNNIS”;
/********************************************************************************************/
$form_array = array(
“MerchantID” => $merchant_id,
“MerchantTradeNo” => $trade_no,
“MerchantTradeDate” => date(“Y/m/d H:i:s”),
“PaymentType” => “aio”,
“TotalAmount” => $total_amt,
“TradeDesc” => $trade_desc,
“ItemName” => $item_name,
“ReturnURL” => $return_url,
“ChoosePayment” => $choose_payment,
“ClientBackURL” => $client_back_url,
“NeedExtraPaidInfo” => $needExtraPaidInfo,
# Alipay ???
“AlipayItemName” => $alipay_item_name,
“AlipayItemCounts” => $alipay_item_counts,
“AlipayItemPrice” => $alipay_item_price,
“Email” => $alipay_email,
“PhoneNo” => $alipay_phone_no,
“UserName” => $alipay_user_name
);
# ??ksort????--??????(??????)
ksort($form_array, SORT_NATURAL |SORT_FLAG_CASE);
# ?? Mac Value
$form_array['CheckMacValue'] = _getMacValue($hash_key, $hash_iv, $form_array);
$html_code = ‘’;
foreach ($form_array as $key => $val) {
$html_code .= “
”;
}
$html_code .= “”;
$html_code .= “”;
echo $html_code;
?>[/code]