Payment Gateway WechatPay
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Payment Gateway WechatPay
I have a problem on new omnipay payment method. I have imported the ai-payments extension, the omnipay and the omnipay-wechatpay package. I have created a new payment service with omnipay.type = "WechatPay".
When I select the payment method during checkout, and proceed to make the payment, I am getting the error message "The body parameter is required".
I try to add option "body", and have the same error message.
When I select the payment method during checkout, and proceed to make the payment, I am getting the error message "The body parameter is required".
I try to add option "body", and have the same error message.
Re: Payment Gateway WechatPay
The WechatPay driver doesn't follow the Omnipay conventions for the field names.
Omnipay standard:
WechatPay driver:
You should notify the author and if he doesn't want to change it (because of backwards compatibility), you should fork the driver and make it conform to Omnipay standards yourself.
Omnipay standard:
Code: Select all
$data = array(
'language' => 'en',
'transactionId' => '123',
'amount' => '1.00',
'currency' => 'CNY',
'description' => 'The test order',
'clientIp' => '127.0.0.1',
);
Code: Select all
$order = [
'body' => 'The test order',
'out_trade_no' => date('YmdHis').mt_rand(1000, 9999),
'total_fee' => 1, //=0.01
'spbill_create_ip' => 'ip_address',
'fee_type' => 'CNY'
];
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 56
- Joined: 15 Mar 2021, 01:03
Re: Payment Gateway WechatPay
Has this issue been resolved?
Re: Payment Gateway WechatPay
This is nothing we can solve because it's not our code.
You can create a PR in the repo of the Wechat driver and propose the required changes.
You can create a PR in the repo of the Wechat driver and propose the required changes.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 56
- Joined: 15 Mar 2021, 01:03
Re: Payment Gateway WechatPay
Thanks,
Any other wechat package that is compatible with Aimeos I can use?
Also, any suggestion on delivery service for Chinese customers?
Regards,
Any other wechat package that is compatible with Aimeos I can use?
Also, any suggestion on delivery service for Chinese customers?
Regards,
-
- Posts: 56
- Joined: 15 Mar 2021, 01:03
Re: Payment Gateway WechatPay
Does lokielse /omnipay-alipay conform to Omnipay standard?
Regards,
Regards,
Re: Payment Gateway WechatPay
Unfortunately not because it's also using non-standard parameters:
https://github.com/lokielse/omnipay-glo ... y#purchase
The official Omnipay parameters are:
https://github.com/aimeoscom/ai-payment ... #L678-L683
You can extend from the MShop/Service/Provider/Payment/OmniPay class and overwrite the getData() method. If you return the parameter names as required by the driver, then it should work.
https://github.com/lokielse/omnipay-glo ... y#purchase
The official Omnipay parameters are:
https://github.com/aimeoscom/ai-payment ... #L678-L683
You can extend from the MShop/Service/Provider/Payment/OmniPay class and overwrite the getData() method. If you return the parameter names as required by the driver, then it should work.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 56
- Joined: 15 Mar 2021, 01:03
Re: Payment Gateway WechatPay
Thanks for the reply.
pardon my rookie understanding and solution. Any help is appreciated.
ext/small-ext/lib/custom/src/MShop/Service/Provider/Payment/WechatPay.php
<?php
/**
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
* @copyright Aimeos (aimeos.org), 2015-2021
* @package MShop
* @subpackage Service
*/
namespace Aimeos\MShop\Service\Provider\Payment;
use Aimeos\MShop\Order\Item\Base as Status;
/**
* Payment provider for WechatPay.
*
* @package MShop
* @subpackage Service
*/
class WechatPay
extends \Aimeos\MShop\Service\Provider\Payment\OmniPay
implements \Aimeos\MShop\Service\Provider\Payment\Iface
{
/**
* Returns the data passed to the Omnipay library
*
* @param \Aimeos\MShop\Order\Item\Base\Iface $base Basket object
* @param string $orderid Unique order ID
* @param array $params Request parameter if available
* @return array Associative list of key/value pairs
*/
protected function getData( \Aimeos\MShop\Order\Item\Base\Iface $base, string $orderid, array $params ) : array
{
$data = parent::getData( $base, $orderid, $params );
$provider = parent::getProvider();
$data['body'] = $provider->getBody();
$data['out_trade_no'] = $provider->getOutTradeNo();
$data['total_fee'] = $provider->getTotalFee();
$data['spbill_create_ip'] = $provider->getSpbillCreateIp();
$data['fee_type'] = $provider->getFeeType();
return $data + $this->getPaymentUrls();
}
}
~
pardon my rookie understanding and solution. Any help is appreciated.
ext/small-ext/lib/custom/src/MShop/Service/Provider/Payment/WechatPay.php
<?php
/**
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
* @copyright Aimeos (aimeos.org), 2015-2021
* @package MShop
* @subpackage Service
*/
namespace Aimeos\MShop\Service\Provider\Payment;
use Aimeos\MShop\Order\Item\Base as Status;
/**
* Payment provider for WechatPay.
*
* @package MShop
* @subpackage Service
*/
class WechatPay
extends \Aimeos\MShop\Service\Provider\Payment\OmniPay
implements \Aimeos\MShop\Service\Provider\Payment\Iface
{
/**
* Returns the data passed to the Omnipay library
*
* @param \Aimeos\MShop\Order\Item\Base\Iface $base Basket object
* @param string $orderid Unique order ID
* @param array $params Request parameter if available
* @return array Associative list of key/value pairs
*/
protected function getData( \Aimeos\MShop\Order\Item\Base\Iface $base, string $orderid, array $params ) : array
{
$data = parent::getData( $base, $orderid, $params );
$provider = parent::getProvider();
$data['body'] = $provider->getBody();
$data['out_trade_no'] = $provider->getOutTradeNo();
$data['total_fee'] = $provider->getTotalFee();
$data['spbill_create_ip'] = $provider->getSpbillCreateIp();
$data['fee_type'] = $provider->getFeeType();
return $data + $this->getPaymentUrls();
}
}
~
Re: Payment Gateway WechatPay
The correct code should be:
Code: Select all
protected function getData( \Aimeos\MShop\Order\Item\Base\Iface $base, string $orderid, array $params ) : array
{
$data = parent::getData( $base, $orderid, $params );
$data['body'] = sprintf( $this->context()->translate( 'mshop', 'Order %1$s' ), $orderid ),;
$data['out_trade_no'] = $orderid;
$data['fee_type'] = $base->locale()->getCurrencyId();
$data['total_fee'] = $this->getAmount( $base->getPrice() ) * 100;
$data['spbill_create_ip'] = $this->getValue( 'client.ipaddress' );
return $data;
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 56
- Joined: 15 Mar 2021, 01:03
Re: Payment Gateway WechatPay
Much appreciated!