Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
widget
WooCommerce
Commits
82e21328
Commit
82e21328
authored
Mar 21, 2021
by
mr.amirka
Browse files
fixed log
parent
23178f6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
lunupayment-woocommerce/lunupayment-woocommerce.php
View file @
82e21328
<?php
/**
* Plugin Name: Lunu WooCommerce - Lunu Cryptocurrencies Payment Gateway Addon
* Plugin Name: Lunu
for
WooCommerce - Lunu Cryptocurrencies Payment Gateway Addon
* Plugin URI: https://lunu.io/plugins
* Description: Payment system plugin.
* Version: 1.0
...
...
@@ -175,6 +175,7 @@ if (
private
$success_url
=
''
;
private
$cancel_url
=
''
;
private
$lunu_wallet_discount
=
''
;
private
$lunu_gift_enabled
=
'no'
;
public
function
__construct
()
{
...
...
@@ -227,14 +228,13 @@ if (
private
function
lunupayment_settings
()
{
// Define user set variables
$this
->
enabled
=
$this
->
get_option
(
'enabled'
);
// $this->release = $this->get_option('release');
$this
->
app_id
=
$this
->
get_option
(
'app_id'
);
$this
->
api_secret
=
$this
->
get_option
(
'api_secret'
);
$this
->
success_url
=
$this
->
get_option
(
'success_url'
);
$this
->
cancel_url
=
$this
->
get_option
(
'cancel_url'
);
// $this->description = $this->get_option('description');
$this
->
lunu_wallet_discount
=
$this
->
get_option
(
'lunu_wallet_discount'
);
$this
->
enabled
=
trim
(
$this
->
get_option
(
'enabled'
));
$this
->
app_id
=
trim
(
$this
->
get_option
(
'app_id'
));
$this
->
api_secret
=
trim
(
$this
->
get_option
(
'api_secret'
));
$this
->
success_url
=
trim
(
$this
->
get_option
(
'success_url'
));
$this
->
cancel_url
=
trim
(
$this
->
get_option
(
'cancel_url'
));
$this
->
lunu_wallet_discount
=
trim
(
$this
->
get_option
(
'lunu_wallet_discount'
));
$this
->
lunu_gift_enabled
=
trim
(
$this
->
get_option
(
'lunu_gift_enabled'
));
// Re-check
if
(
!
$this
->
title
)
$this
->
title
=
__
(
'Lunu Payment'
,
LUNUPAYMENTWC
);
...
...
@@ -276,6 +276,12 @@ if (
'title'
=>
__
(
'Lunu Wallet discount'
,
LUNUPAYMENTWC
),
'type'
=>
'text'
,
'default'
=>
''
),
'lunu_gift_enabled'
=>
array
(
'title'
=>
__
(
'Lunu Gift Enable'
,
LUNUPAYMENTWC
),
'type'
=>
'checkbox'
,
'default'
=>
'no'
,
'label'
=>
__
(
"Enable payments by Lunu Gifts if you marketing partners of Lunu"
,
LUNUPAYMENTWC
)
)
);
...
...
@@ -324,11 +330,12 @@ if (
$orderData
=
$order
->
get_data
();
$shipping_amount
=
floatval
(
$orderData
[
'shipping_total'
]);
$app_id
=
trim
(
$this
->
app_id
);
$api_secret
=
trim
(
$this
->
api_secret
);
$success_url
=
trim
(
$this
->
success_url
);
$cancel_url
=
trim
(
$this
->
cancel_url
);
$payment_discount_percent
=
floatval
(
trim
(
$this
->
lunu_wallet_discount
));
$app_id
=
$this
->
app_id
;
$api_secret
=
$this
->
api_secret
;
$success_url
=
$this
->
success_url
;
$cancel_url
=
$this
->
cancel_url
;
$payment_discount_percent
=
floatval
(
$this
->
lunu_wallet_discount
);
$lunu_gift_enabled
=
$this
->
lunu_gift_enabled
===
'yes'
;
if
(
$order_status
==
"cancelled"
||
$post_status
==
"wc-cancelled"
)
{
...
...
@@ -399,11 +406,7 @@ if (
'description'
=>
'Order #'
.
$order_id
.
' '
.
join
(
$description
,
', '
)
);
// var_dump($payment_discount_percent);
if
(
$payment_discount_percent
>
0
)
{
// $payment_discount_amount = round($amount * $payment_discount_percent * 0.01, 2);
$payment_discount_amount
=
round
((
$amount
-
$shipping_amount
)
*
$payment_discount_percent
*
0.01
,
2
);
$payment_amount
=
$amount
-
$payment_discount_amount
;
...
...
@@ -461,13 +464,13 @@ if (
new window.Lunu.widgets.Payment(
d.getElementById('payment-form'),
{
enableLunuGift: "
.
(
$widget_version
===
'beta'
||
$widget_version
===
'testing'
?
'true'
:
'false'
)
.
",
confirmation_token: '"
.
$confirmation_token
.
"',
// Token that must be received from the Processing Service before making a payment
// Required parameter
enableLunuGift: "
.
(
$lunu_gift_enabled
?
'true'
:
'false'
)
.
",
overlay: true,
callbacks: {
init_error: function(error) {
// Handling initialization errors
...
...
@@ -526,33 +529,6 @@ if (
// Lunu Cryptocurrencies Gateway - Instant Payment Notification
public
function
lunupayment_callback
(
$payment
)
{
/*
global $_GET;
if (intval($_GET['test']) == 1) {
$order_id = 7665;
$order = new WC_Order($order_id);
if ($order === false) return false;
$payment_status = get_post_meta($order_id, '_lunupayment_status', true);
var_dump($payment_status);
if (
$payment_status === LUNUPAYMENT_STATUS_PAID
|| $payment_status === LUNUPAYMENT_STATUS_FAILED
|| $payment_status === LUNUPAYMENT_STATUS_CANCELED
|| $payment_status === LUNUPAYMENT_STATUS_EXPIRED
) {
return false;
}
$order->set_status(LUNUPAYMENT_WC_STATUS_PROCESSING);
$order->payment_complete();
$order->save();
var_dump($order->status);
return true;
}
*/
//
lunuLogError
(
array
(
'payment'
=>
$payment
,
),
'Payment callback'
);
...
...
@@ -621,13 +597,6 @@ if (
$lunu_wallet_discount
=
$payment
[
'lunu_wallet_discount'
];
$payment_amount
=
floatval
(
$lunu_wallet_discount
[
'amount'
]);
/*
lunuLogError(array(
'order_status' => $order_status,
'payment' => $payment,
), 'Lunu Wallet discount apply');
*/
if
(
$order_status
===
'pending'
)
{
lunu_coupon_create
(
$lunu_wallet_discount
,
$order
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment