- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们商店的基础货币是美元,我们为国际客户使用 PayPal。我们希望使用 ccAvenue (INR) 作为印度客户的支付网关。不幸的是,ccAvenue 不读取货币。所以 12 美元将从我们的网站推出,ccAvenue 会将其解读为 12 印度卢比,而不是正确的 600 印度卢比。
如何即时转换金额(从美元到印度卢比),以便我们的网站向 ccAvenue 发送正确的金额?最好这应该在插件中使用实时货币转换服务来完成。但是,我们对粗略的解决方法持开放态度 - 例如每周两次手动更新转换率等。这是指向 free ccavenue woocommerce plugin 的链接。 .
任何帮助将非常感激。
这是插件的 index.php:
<?php
/*
Plugin Name: WooCommerce CCAvenue gateway
Plugin URI: http://mrova.com/
Description: Extends WooCommerce with mrova ccavenue gateway.
Version: 1.1
Author: mRova
Author URI: http://mrova.com/
Copyright: © 2009-2012 mRova.
License: GNU General Public License v3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
add_action('plugins_loaded', 'woocommerce_mrova_ccave_init', 0);
function woocommerce_mrova_ccave_init() {
if ( !class_exists( 'WC_Payment_Gateway' ) ) return;
/**
* Localisation
*/
load_plugin_textdomain('wc-mrova-ccave', false, dirname( plugin_basename( __FILE__ ) ) . '/languages');
/**
* Gateway class
*/
class WC_Mrova_Ccave extends WC_Payment_Gateway {
protected $msg = array();
public function __construct(){
// Go wild in here
$this -> id = 'ccavenue';
$this -> method_title = __('CCAvenue', 'mrova');
$this -> icon = WP_PLUGIN_URL . "/" . plugin_basename(dirname(__FILE__)) . '/images/logo.gif';
$this -> has_fields = false;
$this -> init_form_fields();
$this -> init_settings();
$this -> title = $this -> settings['title'];
$this -> description = $this -> settings['description'];
$this -> merchant_id = $this -> settings['merchant_id'];
$this -> working_key = $this -> settings['working_key'];
$this -> redirect_page_id = $this -> settings['redirect_page_id'];
$this -> liveurl = 'https://www.ccavenue.com/shopzone/cc_details.jsp';
$this -> msg['message'] = "";
$this -> msg['class'] = "";
add_action('init', array(&$this, 'check_ccavenue_response'));
add_action('valid-ccavenue-request', array(&$this, 'successful_request'));
add_action('woocommerce_update_options_payment_gateways', array(&$this, 'process_admin_options'));
add_action('woocommerce_receipt_ccavenue', array(&$this, 'receipt_page'));
add_action('woocommerce_thankyou_ccavenue',array(&$this, 'thankyou_page'));
}
function init_form_fields(){
$this -> form_fields = array(
'enabled' => array(
'title' => __('Enable/Disable', 'mrova'),
'type' => 'checkbox',
'label' => __('Enable CCAvenue Payment Module.', 'mrova'),
'default' => 'no'),
'title' => array(
'title' => __('Title:', 'mrova'),
'type'=> 'text',
'description' => __('This controls the title which the user sees during checkout.', 'mrova'),
'default' => __('CCAvenue', 'mrova')),
'description' => array(
'title' => __('Description:', 'mrova'),
'type' => 'textarea',
'description' => __('This controls the description which the user sees during checkout.', 'mrova'),
'default' => __('Pay securely by Credit or Debit card or internet banking through CCAvenue Secure Servers.', 'mrova')),
'merchant_id' => array(
'title' => __('Merchant ID', 'mrova'),
'type' => 'text',
'description' => __('This id(USER ID) available at "Generate Working Key" of "Settings and Options at CCAvenue."')),
'working_key' => array(
'title' => __('Working Key', 'mrova'),
'type' => 'text',
'description' => __('Given to Merchant by CCAvenue', 'mrova'),
),
'redirect_page_id' => array(
'title' => __('Return Page'),
'type' => 'select',
'options' => $this -> get_pages('Select Page'),
'description' => "URL of success page"
)
);
}
/**
* Admin Panel Options
* - Options for bits like 'title' and availability on a country-by-country basis
**/
public function admin_options(){
echo '<h3>'.__('CCAvenue Payment Gateway', 'mrova').'</h3>';
echo '<p>'.__('CCAvenue is most popular payment gateway for online shopping in India').'</p>';
echo '<table class="form-table">';
$this -> generate_settings_html();
echo '</table>';
}
/**
* There are no payment fields for CCAvenue, but we want to show the description if set.
**/
function payment_fields(){
if($this -> description) echo wpautop(wptexturize($this -> description));
}
/**
* Receipt Page
**/
function receipt_page($order){
echo '<p>'.__('Thank you for your order, please click the button below to pay with CCAvenue.', 'mrova').'</p>';
echo $this -> generate_ccavenue_form($order);
}
/**
* Process the payment and return the result
**/
function process_payment($order_id){
$order = &new woocommerce_order($order_id);
return array('result' => 'success', 'redirect' => add_query_arg('order',
$order->id, add_query_arg('key', $order->order_key, get_permalink(get_option('woocommerce_pay_page_id'))))
);
}
/**
* Check for valid CCAvenue server callback
**/
function check_ccavenue_response(){
global $woocommerce;
if(isset($_REQUEST['Order_Id']) && isset($_REQUEST['AuthDesc'])){
$order_id_time = $_REQUEST['Order_Id'];
$order_id = explode('_', $_REQUEST['Order_Id']);
$order_id = (int)$order_id[0];
if($order_id != ''){
try{
$order = new woocommerce_order($order_id);
$merchant_id = $_REQUEST['Merchant_Id'];
$amount = $_REQUEST['Amount'];
$checksum = $_REQUEST['Checksum'];
$AuthDesc = $_REQUEST['AuthDesc'];
$Checksum = $this -> verifyCheckSum($merchant_id, $order_id_time, $amount, $AuthDesc, $checksum, $this -> working_key);
$transauthorised = false;
if($order -> status !=='completed'){
if($Checksum=="true")
{
if($AuthDesc=="Y"){
$transauthorised = true;
$this -> msg['message'] = "Thank you for shopping with us. Your account has been charged and your transaction is successful. We will be shipping your order to you soon.";
$this -> msg['class'] = 'success';
if($order -> status == 'processing'){
}else{
$order -> payment_complete();
$order -> add_order_note('CCAvenue payment successful<br/>Bank Ref Number: '.$_REQUEST['nb_bid']);
$order -> add_order_note($this->msg['message']);
$woocommerce -> cart -> empty_cart();
}
}else if($AuthDesc=="B"){
$this -> msg['message'] = "Thank you for shopping with us. We will keep you posted regarding the status of your order through e-mail";
$this -> msg['class'] = 'info';
//Here you need to put in the routines/e-mail for a "Batch Processing" order
//This is only if payment for this transaction has been made by an American Express Card
//since American Express authorisation status is available only after 5-6 hours by mail from ccavenue and at the "View Pending Orders"
}
else{
$this -> msg['class'] = 'error';
$this -> msg['message'] = "Thank you for shopping with us. However, the transaction has been declined.";
//Here you need to put in the routines for a failed
//transaction such as sending an email to customer
//setting database status etc etc
}
}else{
$this -> msg['class'] = 'error';
$this -> msg['message'] = "Security Error. Illegal access detected";
//Here you need to simply ignore this and dont need
//to perform any operation in this condition
}
if($transauthorised==false){
$order -> update_status('failed');
$order -> add_order_note('Failed');
$order -> add_order_note($this->msg['message']);
}
add_action('the_content', array(&$this, 'showMessage'));
}}catch(Exception $e){
// $errorOccurred = true;
$msg = "Error";
}
}
}
}
function showMessage($content){
return '<div class="box '.$this -> msg['class'].'-box">'.$this -> msg['message'].'</div>'.$content;
}
/**
* Generate CCAvenue button link
**/
public function generate_ccavenue_form($order_id){
global $woocommerce;
$order = &new woocommerce_order($order_id);
$redirect_url = ($this -> redirect_page_id=="" || $this -> redirect_page_id==0)?get_site_url() . "/":get_permalink($this -> redirect_page_id);
$order_id = $order_id.'_'.date("ymds");
$checksum = $this -> getCheckSum($this -> merchant_id, $order -> order_total, $order_id, $redirect_url, $this -> working_key);
$ccavenue_args = array(
'Merchant_Id' => $this -> merchant_id,
'Amount' => $order -> order_total,
'Order_Id' => $order_id,
'Redirect_Url' => $redirect_url,
'Checksum' => $checksum,
'billing_cust_name' => $order -> billing_first_name .' '. $order -> billing_last_name,
'billing_cust_address' => $order -> billing_address_1,
'billing_cust_country' => $order -> billing_country,
'billing_cust_state' => $order -> billing_state,
'billing_cust_city' => $order -> billing_city,
'billing_zip' => $order -> shipping_postcode,
'billing_cust_tel',
'billing_cust_email' => $order -> billing_email,
'delivery_cust_name' => $order -> shipping_first_name .' '. $order -> shipping_last_name,
'delivery_cust_address' => $order -> shipping_address_1,
'delivery_cust_country' => $order -> shipping_country,
'delivery_cust_state' => $order -> shipping_state,
'delivery_cust_tel' => '',
'delivery_cust_notes' => '',
'Merchant_Param' => '',
'billing_zip_code' => $order -> billing_postcode,
'delivery_cust_city' => $order -> shipping_city,
'delivery_zip_code' => $order -> shipping_postcode);
$ccavenue_args_array = array();
foreach($ccavenue_args as $key => $value){
$ccavenue_args_array[] = "<input type='hidden' name='$key' value='$value'/>";
}
return '<form action="'.$this -> liveurl.'" method="post" id="ccavenue_payment_form">
' . implode('', $ccavenue_args_array) . '
<input type="submit" class="button-alt" id="submit_ccavenue_payment_form" value="'.__('Pay via CCAvenue', 'mrova').'" /> <a class="button cancel" href="'.$order->get_cancel_order_url().'">'.__('Cancel order & restore cart', 'mrova').'</a>
<script type="text/javascript">
jQuery(function(){
jQuery("body").block(
{
message: "<img src=\"'.$woocommerce->plugin_url().'/assets/images/ajax-loader.gif\" alt=\"Redirecting…\" style=\"float:left; margin-right: 10px;\" />'.__('Thank you for your order. We are now redirecting you to CCAvenue to make payment.', 'mrova').'",
overlayCSS:
{
background: "#fff",
opacity: 0.6
},
css: {
padding: 20,
textAlign: "center",
color: "#555",
border: "3px solid #aaa",
backgroundColor:"#fff",
cursor: "wait",
lineHeight:"32px"
}
});
jQuery("#submit_ccavenue_payment_form").click();
});
</script>
</form>';
}
/**
* CCAvenue Essential Functions
**/
private function getCheckSum($MerchantId,$Amount,$OrderId ,$URL,$WorkingKey)
{
$str ="$MerchantId|$OrderId|$Amount|$URL|$WorkingKey";
$adler = 1;
$adler = $this -> adler32($adler,$str);
return $adler;
}
private function verifyCheckSum($MerchantId,$OrderId,$Amount,$AuthDesc,$CheckSum,$WorkingKey)
{
$str = "$MerchantId|$OrderId|$Amount|$AuthDesc|$WorkingKey";
$adler = 1;
$adler = $this -> adler32($adler,$str);
if($adler == $CheckSum)
return "true" ;
else
return "false" ;
}
private function adler32($adler , $str)
{
$BASE = 65521 ;
$s1 = $adler & 0xffff ;
$s2 = ($adler >> 16) & 0xffff;
for($i = 0 ; $i < strlen($str) ; $i++)
{
$s1 = ($s1 + Ord($str[$i])) % $BASE ;
$s2 = ($s2 + $s1) % $BASE ;
//echo "s1 : $s1 <BR> s2 : $s2 <BR>";
}
return $this -> leftshift($s2 , 16) + $s1;
}
private function leftshift($str , $num)
{
$str = DecBin($str);
for( $i = 0 ; $i < (64 - strlen($str)) ; $i++)
$str = "0".$str ;
for($i = 0 ; $i < $num ; $i++)
{
$str = $str."0";
$str = substr($str , 1 ) ;
//echo "str : $str <BR>";
}
return $this -> cdec($str) ;
}
private function cdec($num)
{
for ($n = 0 ; $n < strlen($num) ; $n++)
{
$temp = $num[$n] ;
$dec = $dec + $temp*pow(2 , strlen($num) - $n - 1);
}
return $dec;
}
/*
* End CCAvenue Essential Functions
**/
// get all pages
function get_pages($title = false, $indent = true) {
$wp_pages = get_pages('sort_column=menu_order');
$page_list = array();
if ($title) $page_list[] = $title;
foreach ($wp_pages as $page) {
$prefix = '';
// show indented child pages?
if ($indent) {
$has_parent = $page->post_parent;
while($has_parent) {
$prefix .= ' - ';
$next_page = get_page($has_parent);
$has_parent = $next_page->post_parent;
}
}
// add to page list array array
$page_list[$page->ID] = $prefix . $page->post_title;
}
return $page_list;
}
}
/**
* Add the Gateway to WooCommerce
**/
function woocommerce_add_mrova_ccave_gateway($methods) {
$methods[] = 'WC_Mrova_Ccave';
return $methods;
}
add_filter('woocommerce_payment_gateways', 'woocommerce_add_mrova_ccave_gateway' );
}
?>
最佳答案
使用第三方机构提供的货币转换API,封装成wordpress函数。
open exchange rates
XE Datafeed
请参阅以下使用谷歌金融 API 的示例代码。
//get the exchange rate from google finance
function get_exchange_rate($from='USD', $to='INR') {
$url = "http://www.google.com/ig/calculator?hl=en&q=1%s=?%s"; //url for the currency convertor
$result = wp_remote_retrieve_body($response = wp_remote_get(sprintf($url, $from, $to))); // fetches the result from the url
if(is_wp_error( $response )) {
return FALSE;
}
$result = explode('"',$result);
$result = str_replace(chr(160), '', substr( $result[3], 0, strpos($result[3], ' ') ) );
return ( $result == 0 ) ? FALSE : $result;
}
关于wordpress - 如何即时将 *USD 转换为 INR* 货币? - WooCommerce,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13134574/
我需要显示这样的货币格式,我们如何显示。 ₹1 ₹10 ₹100 ₹1,000 ₹10,000 ₹1,00,000 ...... 最佳答案 AngularJS 在 HTML 中 {{ currency
我正在尝试为 cgal 库创建一个灰度 .inr 图像,但我在文件格式方面遇到了问题。 This seems to be the best description of the format ,但看起
我有一个应用程序,其中一些价格以美元表示,一些价格以印度卢比表示。现在,当我显示商品的价格时,根据其价格以美元或印度卢比为单位,我可以告诉我显示价格所用的货币。当我显示总值(value)或净值时,问题
对于英镑 (£),有 HTML 代码 £。 对于 INR你能告诉我 HTML 代码吗? 最佳答案 您可以使用以下 HTML 代码段: Price ₹ 9500 = ₹ 95
我正在尝试删除输入数字后的文本并添加小数 我有多个input type="text",在按键时我在INR(印度卢比)标准中添加一个逗号,但是当我输入三个以上的数字时,整个值将被删除并且“0” ' 被添
这个问题在这里已经有了答案: Decimal Pipe in Angular 2 - Commas Only, No Decimal Places (1 个回答) 关闭 3 年前。 我需要根据 An
在 Coq 标准库中我可以在哪里找到一个引理,指出 inl和inr是注入(inject)吗?即forall (A B : Type)(x y : A), inl B x = inl B y -> x
tcpdf(); $obj_pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
我正在将 PayPal 集成到我的 android 应用程序中。 以下是 PayPal 付款方式,它只接受美元。但我的货币格式是 INR。那么请帮助我如何使用当前汇率将我的货币从 INR 转换为美元?
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 4 年前。
我正在开发在线购物网站,在购物网站中,所有产品的价格均以印度卢比 (INR) 为单位。我要将我的购物车集成到 PayPal 支付网关。我知道 PayPal 不支持 INR。所以我必须将 INR 转换为
我们商店的基础货币是美元,我们为国际客户使用 PayPal。我们希望使用 ccAvenue (INR) 作为印度客户的支付网关。不幸的是,ccAvenue 不读取货币。所以 12 美元将从我们的网站推
我正在寻找支持 INR 的支付网关,我可以将其与 nodejs 应用程序一起使用。找不到任何有用的东西。任何建议和指示都会有所帮助。 最佳答案 我认为 citruspay 是一个不错的选择。以下链接显
我想在 php 中将货币从 INR 转换为 USD,这是我到目前为止尝试过的代码。但它不起作用。我错过了什么? function currency($from_Currency,$to_Currenc
我在我的 wordpress 网站上使用 ccavenue 支付网关。 插件网址是 https://wordpress.org/plugins/ccavenue-payment-gateway-woo
我正在使用 Apache POI 导出数据,并且数据同时显示印度和美国货币。但是在应用单独的数据格式之后,我得到了应用于所有数据的相同格式(印度 INR)。 public static void ma
我在我的 Ionic 应用程序中工作,我在我的应用程序中添加了 PayPal native 插件,但是当我在 PayPal 代码中添加“INR”货币时,它没有在真实设备中打开,当我将货币更改为 ' U
我试过使用 unicode 和 HTML 代码,但它们似乎无法识别相同的代码。我知道通过复制 word 文档中的符号有一种更简单的方法,但我只是想知道是否可以通过编程方式在 gmail 撰写框中使用
我是一名优秀的程序员,十分优秀!