Add shopping cart to payment gateway

This commit is contained in:
Enrique Barcelli 2021-07-18 20:46:36 +08:00
parent c2213d53ca
commit 22ae8137ac
3 changed files with 21 additions and 3 deletions

View file

@ -9,7 +9,7 @@ Smart Accounts ( https://www.smt-acc.com )
Smart Accounts ( https://www.smt-acc.com ) Smart Accounts ( https://www.smt-acc.com )
## More details ## More details
**This version of the code is work-in-progress and should not be use in any production site.** **This version of the code is released for testing. Use carefully on production sites.**
At this stage the plugin is able to accept payments, but cannot receive payment notifications or process refunds. At this stage the plugin is able to accept payments, but cannot receive payment notifications or process refunds.
The TripleA Cryptocurrency Payments API is documented here: The TripleA Cryptocurrency Payments API is documented here:

View file

@ -26,6 +26,23 @@ class plgHikashoppaymentTriplea extends hikashopPaymentPlugin{
function onAfterOrderConfirm(&$order,&$methods,$method_id){ function onAfterOrderConfirm(&$order,&$methods,$method_id){
parent::onAfterOrderConfirm($order, $methods, $method_id); parent::onAfterOrderConfirm($order, $methods, $method_id);
$tacart = array();
foreach($order->cart->products as $v) {
$temp = array();
$temp['sku'] = $v->product_id;
$temp['label'] = $v->order_product_name;
$temp['quantity'] = (float)$v->order_product_quantity;
$temp['amount'] = ((float)$v->order_product_price+(float)$v->order_product_tax)*$temp['quantity'];
$tacart[] = $temp;
};
$tacart = array(
"items"=>$tacart,
"shipping_cost"=>$order->order_shipping_price, //includes tax
"shipping_discount"=>$order->order_discount_price, //includes tax
"tax_cost"=>0); //tax included above
$tacart = json_encode($tacart);
// var_dump($tacart); //debug only
$payment_url = $this->payment_params->url.'/payment'; $payment_url = $this->payment_params->url.'/payment';
$curl = curl_init(); $curl = curl_init();
@ -44,6 +61,7 @@ class plgHikashoppaymentTriplea extends hikashopPaymentPlugin{
"merchant_key": "'.$this->payment_params->merchant_key.'", "merchant_key": "'.$this->payment_params->merchant_key.'",
"order_currency": "'.$this->currency->currency_code.'", "order_currency": "'.$this->currency->currency_code.'",
"order_amount": '.$order->order_full_price.', "order_amount": '.$order->order_full_price.',
"cart": '.$tacart.',
"payer_id": "'.(string)$order->order_user_id.'", "payer_id": "'.(string)$order->order_user_id.'",
"payer_name": "'.$order->cart->billing_address->address_firstname.' '.$order->cart->billing_address->address_lastname.'", "payer_name": "'.$order->cart->billing_address->address_firstname.' '.$order->cart->billing_address->address_lastname.'",
"payer_email": "'.$this->user->user_email.'", "payer_email": "'.$this->user->user_email.'",

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="2.5" method="upgrade" group="hikashoppayment"> <extension type="plugin" version="2.5" method="upgrade" group="hikashoppayment">
<name>Hikashop TripleA Payment Plugin</name> <name>Hikashop TripleA Payment Plugin</name>
<creationDate>17 July 2021</creationDate> <creationDate>18 July 2021</creationDate>
<version>1.0.1</version> <version>1.1.0</version>
<author>Enrique Barcelli</author> <author>Enrique Barcelli</author>
<authorEmail>e.barcelli@gmail.com</authorEmail> <authorEmail>e.barcelli@gmail.com</authorEmail>
<authorUrl>http://www.smt-acc.com</authorUrl> <authorUrl>http://www.smt-acc.com</authorUrl>