多货币使用Paypal支付时如果使用基础货币结算

问题咨询 · phpworkerman · 于 3年前 发布 · 1086 次阅读

目前在线商城支持多货币支付,但是运营需求是希望paypal统一采用基础货币进行支付,即使客户选择的是非基础货币在支付时也是使用基础货币。查看paypal模块代码,发现发送给paypal的代码是采用的当前货币,如果要使用基础货币需要修改代码或是修改paypal商户的配置吗?

$currency = Yii::$service->page->currency->getCurrentCurrency();
$grand_total = Yii::$service->helper->format->number_format($orderInfo['grand_total']);
$subtotal = Yii::$service->helper->format->number_format($orderInfo['subtotal']);
$shipping_total = Yii::$service->helper->format->number_format($orderInfo['shipping_total']);
$discount_amount= Yii::$service->helper->format->number_format($orderInfo['subtotal_with_discount']);
共收到 1 条回复 问题提问
Fecmall#13年前 0 个赞

自行改一下代码

对于订单表的数据,您查看sale_flat_order表可以看到,涉及到金额的字段,都有一个基础货币的字段,base_开头

$orderInfo['grand_total'] , 基础货币是 $orderInfo['base_grand_total']

代码追踪

1.controller: https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Payment/controllers/paypal/StandardController.php#L29

2.block: https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Payment/block/paypal/standard/Start.php#L24

$nvpStr_ = Yii::$service->payment->paypal->getStandardTokenNvpStr();

3.service:https://github.com/fecshop/yii2_fecshop/blob/master/services/payment/Paypal.php#L613

将这个services里面的涉及到当前货币的金额,改成基础货币的金额即可。

4.给你个例子自己参考

$currency       = Yii::$service->page->currency->getCurrentCurrency();
        $grand_total    = Yii::$service->helper->format->number_format($orderInfo['grand_total']);
        $subtotal       = Yii::$service->helper->format->number_format($orderInfo['subtotal']);
        $shipping_total = Yii::$service->helper->format->number_format($orderInfo['shipping_total']);
        $discount_amount= Yii::$service->helper->format->number_format($orderInfo['subtotal_with_discount']);

改成:

$baseCurrecy       = Yii::$service->page->currency->baseCurrecy;
$currency = $baseCurrecy['code']
        $grand_total    = Yii::$service->helper->format->number_format($orderInfo['base_grand_total']);
        $subtotal       = Yii::$service->helper->format->number_format($orderInfo['base_subtotal']);
        $shipping_total = Yii::$service->helper->format->number_format($orderInfo['base_shipping_total']);
        $discount_amount= Yii::$service->helper->format->number_format($orderInfo['base_subtotal_with_discount']);

上面的代码没有调试,您自己核验一下吧,该services很多函数都需要改一下金额

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics