Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
crefopay
WooCommerce
Commits
36a00adc
Commit
36a00adc
authored
Feb 08, 2021
by
Daniel Kazior
Browse files
Merge branch 'develop' into 'master'
Release 3.1.1 See merge request
!13
parents
4a7b0beb
f26c157e
Changes
34
Expand all
Hide whitespace changes
Inline
Side-by-side
crefopay payment flow.blinkmind
0 → 100644
View file @
36a00adc
This diff is collapsed.
Click to expand it.
crefopay-payment-solution.zip
View file @
36a00adc
No preview for this file type
crefopay-payment-solution/crefopay-payment-solution.php
View file @
36a00adc
...
...
@@ -3,7 +3,7 @@
* Plugin Name: CrefoPay Payment Solution
* Plugin URI: https://repo.crefopay.de/crefopay/woocommerce
* Description: The complete solution for your eCommerce payments.
* Version: 3.1.
0
* Version: 3.1.
1
* Requires at least: 5.1
* Requires PHP: 7.2
* Author: Shakuras GbR
...
...
@@ -64,6 +64,11 @@ require_once plugin_dir_path(__FILE__) . 'includes/gateways/class-wc-payment-gat
require_once
plugin_dir_path
(
__FILE__
)
.
'includes/callbacks/class-wc-api-callback.php'
;
require_once
plugin_dir_path
(
__FILE__
)
.
'includes/callbacks/class-wc-notification-callback.php'
;
/**
* require third party helpers
*/
require_once
plugin_dir_path
(
__FILE__
)
.
'includes/controllers/class-wc-helper-germanized.php'
;
/**
* define plugin internal name
*/
...
...
@@ -84,6 +89,7 @@ define('ORDER_STATE_CIAPENDING', 'wc-pending');
define
(
'ORDER_STATE_DONE'
,
'wc-completed'
);
define
(
'ORDER_STATE_DELIVERED'
,
'wc-delivered'
);
define
(
'ORDER_STATE_FAILED'
,
'wc-failed'
);
define
(
'ORDER_STATE_PROCESSING'
,
'wc-processing'
);
define
(
'ORDER_STATE_REFUNDED'
,
'wc-refunded'
);
/**
...
...
@@ -114,7 +120,7 @@ define('PAYMENT_METHOD_SU', 'SU');
* Main Class of the CrefoPay payment plugin
*
* @class CrefoPay_Payment_Solution
* @version 3.1.
0
* @version 3.1.
1
* @package CrefoPay-Payment-Solution
*/
class
Crefopay_Payment_Solution
...
...
@@ -180,9 +186,6 @@ class Crefopay_Payment_Solution
public
static
function
init_translation
()
{
load_plugin_textdomain
(
'crefopay-payment-solution'
,
false
,
basename
(
dirname
(
__FILE__
))
.
'/languages'
);
load_plugin_textdomain
(
'crefopay-payment-geateways'
,
false
,
basename
(
dirname
(
__FILE__
))
.
'/languages'
);
load_plugin_textdomain
(
'crefopay-payment-messages'
,
false
,
basename
(
dirname
(
__FILE__
))
.
'/languages'
);
load_plugin_textdomain
(
'crefopay-payment-solution'
,
false
,
basename
(
dirname
(
__FILE__
))
.
'/languages'
);
}
...
...
@@ -445,7 +448,31 @@ class Crefopay_Payment_Solution
return
$orderStatuses
;
}
#### START ORDER FILTER ###
#### END ORDER FILTER ###
#### START THIRD PARTY ACTIONS ###
/**
* Prevent order confirmation mail before thank you page with WGM_Mail
*
* @return void
*/
public
static
function
wgm_mail
()
{
if
(
method_exists
(
'WGM_Email'
,
'send_order_confirmation_mail'
))
{
remove_action
(
'woocommerce_checkout_order_processed'
,
array
(
'WGM_Email'
,
'send_order_confirmation_mail'
),
10
);
add_action
(
'woocommerce_thankyou'
,
function
(
$order_id
)
{
$order
=
wc_get_order
(
$order_id
);
if
(
empty
(
$order
->
get_meta
(
'_gm_email_confirm_order_send'
)))
{
WGM_Email
::
send_order_confirmation_mail
(
$order_id
);
$order
->
update_meta_data
(
'_gm_email_confirm_order_send'
,
'yes'
);
$order
->
save_meta_data
();
}
});
}
}
#### START THIRD PARTY ACTIONS AND FILTER ###
}
# Installation hooks and actions
...
...
@@ -470,3 +497,6 @@ add_action('wp_ajax_nopriv_delete_user_payment_instrument', array(PLUGIN_CPS_NAM
# extra order states
add_filter
(
'wc_order_statuses'
,
array
(
PLUGIN_CPS_NAME
,
'crefopay_payment_solution_wc_plugin_add_order_status'
));
# third party actions
add_action
(
'plugins_loaded'
,
array
(
PLUGIN_CPS_NAME
,
'wgm_mail'
));
crefopay-payment-solution/includes/callbacks/class-wc-api-callback.php
View file @
36a00adc
...
...
@@ -16,7 +16,7 @@ use Upg\Library\Request\Objects\Amount;
*
* @class WC_API_CrefoPay_Api_Callback
* @extends WC_API
* @version 3.1.
0
* @version 3.1.
1
* @package CrefoPay-Payment-Solution\Callbacks
*/
class
WC_API_CrefoPay_Api_Callback
extends
WC_API
...
...
crefopay-payment-solution/includes/callbacks/class-wc-notification-callback.php
View file @
36a00adc
...
...
@@ -16,7 +16,7 @@ use Upg\Library\Mns\Handler;
*
* @class WC_API_Crefo_Notification_Callback
* @extends WC_API
* @version 3.1.
0
* @version 3.1.
1
* @package CrefoPay-Payment-Solution\Callbacks
*/
class
WC_API_Crefo_Notification_Callback
extends
WC_API
...
...
crefopay-payment-solution/includes/controllers/class-wc-api-callback-processor.php
View file @
36a00adc
...
...
@@ -12,7 +12,7 @@ require_once plugin_dir_path(__FILE__) . '../controllers/class-wc-crefopay.php';
* Process redirect payments
*
* @class WC_API_CrefoPay_Api_Callback
* @version 3.1.
0
* @version 3.1.
1
* @package CrefoPay-Payment-Solution\Controllers
*/
class
CrefoPay_API_Callback_Processor
...
...
crefopay-payment-solution/includes/controllers/class-wc-crefopay.php
View file @
36a00adc
...
...
@@ -20,6 +20,7 @@ use Upg\Library\Api\Capture as CaptureApi;
use
Upg\Library\Api\Finish
as
FinishApi
;
use
Upg\Library\Api\Refund
as
RefundApi
;
use
Upg\Library\Api\Exception\ApiError
;
use
Upg\Library\Api\GetTransactionPaymentInstruments
as
GetTransactionPaymentInstrumentsApi
;
use
Upg\Library\Api\GetUserPaymentInstrument
as
GetUserPaymentInstrumentApi
;
use
Upg\Library\Api\DeleteUserPaymentInstrument
as
DeleteUserPaymentInstrumentApi
;
use
Upg\Library\Api\Reserve
as
ReserveApi
;
...
...
@@ -31,6 +32,7 @@ use Upg\Library\Request\Capture as CaptureRequest;
use
Upg\Library\Request\CreateTransaction
as
CreateTransactionRequest
;
use
Upg\Library\Request\Finish
as
FinishRequest
;
use
Upg\Library\Request\DeleteUserPaymentInstrument
as
DeleteUserPaymentInstrumentRequest
;
use
Upg\Library\Request\GetTransactionPaymentInstruments
as
GetTransactionPaymentInstrumentsRequest
;
use
Upg\Library\Request\GetUserPaymentInstrument
as
GetUserPaymentInstrumentRequest
;
use
Upg\Library\Request\Objects\Address
;
use
Upg\Library\Request\Objects\Amount
;
...
...
@@ -50,7 +52,7 @@ use Upg\Library\Validation\Validation;
*
* @class CrefoPay
* @autoloads Upg\Library
* @version 3.1.
0
* @version 3.1.
1
* @package CrefoPay-Payment-Solution\Controllers
*/
class
CrefoPay
...
...
@@ -87,7 +89,7 @@ class CrefoPay
/**
* @var array
*/
private
$allowedPayment
Instrument
s
;
private
$allowedPayment
Method
s
;
/**
* @var Upg\Library\Config
...
...
@@ -194,7 +196,7 @@ class CrefoPay
'merchantPassword'
=>
$this
->
options
[
'crefopay_password'
],
'merchantID'
=>
$this
->
options
[
'crefopay_merchant_id'
],
'storeID'
=>
$this
->
options
[
'crefopay_store_id'
],
'logEnabled'
=>
$this
->
options
[
'crefopay_log_enabled'
]
,
'logEnabled'
=>
false
,
'logLocationMain'
=>
self
::
LOG_LOCATION_MAIN
,
'logLocationRequest'
=>
self
::
LOG_LOCATION_REQUEST
,
'logLocationMNS'
=>
self
::
LOG_LOCATION_MNS
,
...
...
@@ -203,6 +205,7 @@ class CrefoPay
]);
$this
->
logger
=
wc_get_logger
(
'class-wc-crefopay'
);
$this
->
publicKey
=
$this
->
options
[
'crefopay_public_key'
];
$this
->
allowedPaymentMethods
=
array
();
$this
->
creationTime
=
null
;
$this
->
secureFieldsStatus
=
false
;
...
...
@@ -212,12 +215,6 @@ class CrefoPay
->
setBasketValidity
(
$this
->
options
[
'crefopay_basket_validity'
]
.
'h'
)
->
setContext
(
CreateTransactionRequest
::
CONTEXT_ONLINE
)
->
setIntegrationType
(
CreateTransactionRequest
::
INTEGRATION_TYPE_SECURE_FIELDS
);
// set user IP address if it's not empty
$userIpAddress
=
$this
->
_getUserIpAddress
();
if
(
!
empty
(
$userIpAddress
)
&&
gettype
(
$userIpAddress
)
==
'string'
)
{
$this
->
transaction
->
setUserIpAddress
(
$userIpAddress
);
}
}
/**
...
...
@@ -432,7 +429,7 @@ class CrefoPay
$this
->
logger
->
debug
(
"CrefoPay transaktion creation successfully"
);
$this
->
logger
->
debug
(
"Response: "
.
print_r
(
$this
->
response
,
true
));
$this
->
logger
->
debug
(
"Payment Methods: "
.
print_r
(
$this
->
response
->
getData
(
"allowedPaymentMethods"
),
true
));
$this
->
transaction
->
setA
llowedPaymentMethods
(
$this
->
response
->
getData
(
"allowedPaymentMethods"
)
)
;
$this
->
a
llowedPaymentMethods
=
$this
->
response
->
getData
(
"allowedPaymentMethods"
);
$this
->
transaction
->
setAllowedPaymentInstruments
(
$this
->
response
->
getData
(
"allowedPaymentInstruments"
));
break
;
default
:
...
...
@@ -448,6 +445,7 @@ class CrefoPay
]);
if
(
$a
->
getCode
()
==
2008
)
{
$this
->
logger
->
info
(
"Order ID already exists: continue with existing order "
.
$this
->
transaction
->
getOrderID
());
$this
->
allowedPaymentMethods
=
$this
->
_getAllowedPaymentMethods
();
}
else
{
$this
->
logger
->
error
(
"CreateTransaction fails with ApiError: "
.
$a
->
getMessage
());
throw
new
WC_Crefo_Exception
(
$error
,
'API'
);
...
...
@@ -691,25 +689,6 @@ class CrefoPay
}
}
/**
* Get users ip address
*
* @return string
*/
private
function
_getUserIpAddress
()
{
if
(
!
empty
(
$_SERVER
[
'HTTP_CLIENT_IP'
]))
{
//check ip from share internet
$ip
=
$_SERVER
[
'HTTP_CLIENT_IP'
];
}
elseif
(
!
empty
(
$_SERVER
[
'HTTP_X_FORWARDED_FOR'
]))
{
//to check ip is pass from proxy
$ip
=
$_SERVER
[
'HTTP_X_FORWARDED_FOR'
];
}
else
{
$ip
=
$_SERVER
[
'REMOTE_ADDR'
];
}
return
$ip
;
}
/**
* Delete a user payment instrument
...
...
@@ -748,6 +727,34 @@ class CrefoPay
}
/**
* Get the transaction payment instruments
*
* @return array
*/
private
function
_getAllowedPaymentMethods
()
{
$this
->
logger
->
debug
(
"try to get user payment instruments..."
);
try
{
$request
=
new
GetTransactionPaymentInstrumentsRequest
(
$this
->
config
);
$request
->
setOrderID
(
$this
->
transaction
->
getOrderID
());
$api
=
new
GetTransactionPaymentInstrumentsApi
(
$this
->
config
,
$request
);
$response
=
$api
->
sendRequest
();
if
((
int
)
$this
->
resultCode
=
(
int
)
$response
->
getData
(
"resultCode"
)
!=
0
)
{
$this
->
logger
->
error
(
"invalid response while trying to get users payment instruments."
);
return
[];
}
return
$response
->
getData
(
"allowedPaymentMethods"
);
}
catch
(
ApiError
$a
)
{
$this
->
logger
->
error
(
"invalid response while trying to get users payment instruments; leads into ApiError: "
.
$a
->
getMessage
()
.
'('
.
$a
->
getCode
()
.
')'
);
}
catch
(
Exception
$e
)
{
$this
->
logger
->
error
(
"invalid response while trying to get users payment instruments; leads into Exception: "
.
$e
->
getMessage
()
.
'('
.
$e
->
getCode
()
.
')'
);
}
return
[];
}
/**
* Get the payment instruments by provided userID
*
...
...
@@ -778,7 +785,7 @@ class CrefoPay
break
;
}
}
catch
(
Exception
$e
)
{
$this
->
logger
->
error
(
"invalid response while trying to get users payment instruments; leads into Exception: "
.
$
a
->
getMessage
()
.
'('
.
$e
->
getCode
()
.
')'
);
$this
->
logger
->
error
(
"invalid response while trying to get users payment instruments; leads into Exception: "
.
$
e
->
getMessage
()
.
'('
.
$e
->
getCode
()
.
')'
);
}
return
[];
}
...
...
@@ -1231,7 +1238,7 @@ class CrefoPay
*/
public
function
isAllowedPaymentMethod
(
string
$label
)
{
if
(
in_array
(
$label
,
$this
->
transaction
->
getA
llowedPaymentMethods
()
))
{
if
(
in_array
(
$label
,
$this
->
a
llowedPaymentMethods
))
{
return
true
;
}
return
false
;
...
...
@@ -1516,4 +1523,15 @@ class CrefoPay
return
$this
;
}
/**
* Set users IP Address
*
* @param string $userIpAddress
* @return void
*/
public
function
setUserIpAddress
(
$userIpAddress
)
{
$this
->
transaction
->
setUserIpAddress
(
$userIpAddress
);
}
}
crefopay-payment-solution/includes/controllers/class-wc-helper-germanized.php
0 → 100644
View file @
36a00adc
<?php
/**
* CrefoPay_GZD_Email_Customer_Paid_For_Order
*
* prevent unauthorized access
*/
defined
(
'ABSPATH'
)
or
die
(
'No script kiddies please!'
);
if
(
class_exists
(
'WC_GZD_Email_Customer_Paid_For_Order'
)
)
:
/**
* Class CrefoPay_GZD_Email_Customer_Paid_For_Order provides
* helper functionality to manage the payment confirmation email
* from the WooCommerce Germanized extension.
*
* @class CrefoPay_GZD_Email_Customer_Paid_For_Order
* @version 3.1.1
* @package CrefoPay-Payment-Solution\Controllers
*/
class
CrefoPay_GZD_Email_Customer_Paid_For_Order
extends
WC_GZD_Email_Customer_Paid_For_Order
{
/**
* Constructor
*/
public
function
__construct
()
{
parent
::
__construct
();
}
/**
* Send the payment complete email
*
* @param string $order_id
* @return void
*/
public
function
send
(
$order_id
)
{
$this
->
trigger
(
$order_id
);
}
}
endif
;
crefopay-payment-solution/includes/controllers/class-wc-notification-callback-processor.php
View file @
36a00adc
...
...
@@ -15,7 +15,7 @@ use Upg\Library\Mns\ProcessorInterface;
*
* @class CrefoPay_Notification_Callback_Processor
* @implements Upg\Library\Mns\ProcessorInterface
* @version 3.1.
0
* @version 3.1.
1
* @package CrefoPay-Payment-Solution\Controllers
*/
class
CrefoPay_Notification_Callback_Processor
implements
ProcessorInterface
...
...
@@ -218,12 +218,6 @@ class CrefoPay_Notification_Callback_Processor implements ProcessorInterface
$order
->
add_meta_data
(
META_TAG_MNS
,
array
(
$this
->
getMnsArray
()),
true
);
}
// Complete the payment
if
(
$this
->
transactionStatus
==
'ACKNOWLEDGEPENDING'
)
{
$this
->
logger
->
debug
(
"now complete the payment"
);
$order
->
payment_complete
(
$this
->
orderID
);
}
$this
->
logger
->
debug
(
"Saving the order: "
.
$this
->
orderID
);
$order
->
save
();
}
else
{
...
...
crefopay-payment-solution/includes/controllers/class-wc-notification-processor.php
View file @
36a00adc
...
...
@@ -10,7 +10,7 @@ defined('ABSPATH') or die('No script kiddies please!');
* Process CrefoPay notifications.
*
* @class CrefoPay_Notification_Processor
* @version 3.1.
0
* @version 3.1.
1
* @package CrefoPay-Payment-Solution\Controllers
*/
class
CrefoPay_Notification_Processor
...
...
@@ -71,13 +71,13 @@ class CrefoPay_Notification_Processor
// Transaction states:
case
self
::
STATE_ACKNOWLEDGEPENDING
:
$this
->
logger
->
debug
(
"add order note: "
.
__
(
'TRANSACTION_ACKNOWLEDGED'
,
'crefopay-payment-
messages
'
));
$this
->
logger
->
debug
(
"add order note: "
.
__
(
'TRANSACTION_ACKNOWLEDGED'
,
'crefopay-payment-
solution
'
));
// save payment reference
$this
->
logger
->
debug
(
"add 3rd party payment reference as order meta: "
.
$this
->
getPaymentReference
(
$mns
));
$order
->
add_meta_data
(
META_TAG_PAYMENT_REFERENCE
,
$this
->
getPaymentReference
(
$mns
),
true
);
// add order note
if
(
$order
->
add_order_note
(
__
(
'TRANSACTION_ACKNOWLEDGED'
,
'crefopay-payment-
messages
'
)))
{
if
(
$order
->
add_order_note
(
__
(
'TRANSACTION_ACKNOWLEDGED'
,
'crefopay-payment-
solution
'
)))
{
$this
->
logger
->
debug
(
"successfully added order note"
);
}
else
{
$this
->
logger
->
error
(
"unable to add order note TRANSACTION_ACKNOWLEDGED"
);
...
...
@@ -88,19 +88,26 @@ class CrefoPay_Notification_Processor
if
(
$this
->
options
[
'crefopay_orderstate_cia_pending'
]
!=
'disabled'
)
{
$newState
=
empty
(
$this
->
options
[
'crefopay_orderstate_cia_pending'
])
?
ORDER_STATE_CIAPENDING
:
$this
->
options
[
'crefopay_orderstate_cia_pending'
];
$this
->
logger
->
debug
(
"set new order status: "
.
$newState
);
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_CIAPENDING'
,
'crefopay-payment-
messages
'
)))
{
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_CIAPENDING'
,
'crefopay-payment-
solution
'
)))
{
$this
->
logger
->
debug
(
"successfully set new order state "
.
$newState
);
}
else
{
$this
->
logger
->
error
(
"unable to set new order state "
.
$newState
);
}
}
break
;
case
self
::
STATE_MERCHANTPENDING
:
// Complete the payment
if
(
$order
->
get_payment_method
()
!=
'crefopay_invoice'
)
{
$this
->
logger
->
debug
(
"complete the payment"
);
$order
->
payment_complete
(
$this
->
orderID
);
}
if
(
$this
->
options
[
'crefopay_orderstate_merchant_pending'
]
!=
'disabled'
)
{
$newState
=
empty
(
$this
->
options
[
'crefopay_orderstate_merchant_pending'
])
?
ORDER_STATE_RESERVED
:
$this
->
options
[
'crefopay_orderstate_merchant_pending'
];
$this
->
logger
->
debug
(
"set new order status: "
.
$newState
);
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_MERCHANTPENDING'
,
'crefopay-payment-messages'
)))
{
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_MERCHANTPENDING'
,
'crefopay-payment-solution'
)))
{
$this
->
logger
->
debug
(
"successfully set new order state "
.
$newState
);
}
else
{
$this
->
logger
->
error
(
"unable to set new order state "
.
$newState
);
...
...
@@ -112,7 +119,7 @@ class CrefoPay_Notification_Processor
if
(
$this
->
options
[
'crefopay_orderstate_fraud_pending'
]
!=
'disabled'
)
{
$newState
=
empty
(
$this
->
options
[
'crefopay_orderstate_fraud_pending'
])
?
ORDER_STATE_FRAUDPENDING
:
$this
->
options
[
'crefopay_orderstate_fraud_pending'
];
$this
->
logger
->
debug
(
"set new order status: "
.
$newState
);
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_FRAUDPENDING'
,
'crefopay-payment-
messages
'
)))
{
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_FRAUDPENDING'
,
'crefopay-payment-
solution
'
)))
{
$this
->
logger
->
debug
(
"successfully set new order state "
.
$newState
);
}
else
{
$this
->
logger
->
error
(
"unable to set new order state "
.
$newState
);
...
...
@@ -124,7 +131,7 @@ class CrefoPay_Notification_Processor
if
(
$this
->
options
[
'crefopay_orderstate_fraud_cancelled'
]
!=
'disabled'
)
{
$newState
=
empty
(
$this
->
options
[
'crefopay_orderstate_fraud_cancelled'
])
?
ORDER_STATE_CANCELLED
:
$this
->
options
[
'crefopay_orderstate_fraud_cancelled'
];
$this
->
logger
->
debug
(
"set new order status: "
.
$newState
);
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_FRAUDCANCELLED'
,
'crefopay-payment-
messages
'
)))
{
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_FRAUDCANCELLED'
,
'crefopay-payment-
solution
'
)))
{
$this
->
logger
->
debug
(
"successfully set new order state "
.
$newState
);
}
else
{
$this
->
logger
->
error
(
"unable to set new order state "
.
$newState
);
...
...
@@ -136,7 +143,7 @@ class CrefoPay_Notification_Processor
if
(
$this
->
options
[
'crefopay_orderstate_cancelled'
]
!=
'disabled'
)
{
$newState
=
empty
(
$this
->
options
[
'crefopay_orderstate_cancelled'
])
?
ORDER_STATE_CANCELLED
:
$this
->
options
[
'crefopay_orderstate_cancelled'
];
$this
->
logger
->
debug
(
"set new order status: "
.
$newState
);
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_CANCELLED'
,
'crefopay-payment-
messages
'
)))
{
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_CANCELLED'
,
'crefopay-payment-
solution
'
)))
{
$this
->
logger
->
debug
(
"successfully set new order state "
.
$newState
);
}
else
{
$this
->
logger
->
error
(
"unable to set new order state "
.
$newState
);
...
...
@@ -148,7 +155,7 @@ class CrefoPay_Notification_Processor
if
(
$this
->
options
[
'crefopay_orderstate_expired'
]
!=
'disabled'
)
{
$newState
=
empty
(
$this
->
options
[
'crefopay_orderstate_expired'
])
?
ORDER_STATE_FAILED
:
$this
->
options
[
'crefopay_orderstate_expired'
];
$this
->
logger
->
debug
(
"set new order status: "
.
$newState
);
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_EXPIRED'
,
'crefopay-payment-
messages
'
)))
{
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_EXPIRED'
,
'crefopay-payment-
solution
'
)))
{
$this
->
logger
->
debug
(
"successfully set new order state "
.
$newState
);
}
else
{
$this
->
logger
->
error
(
"unable to set new order state "
.
$newState
);
...
...
@@ -157,10 +164,16 @@ class CrefoPay_Notification_Processor
break
;
case
self
::
STATE_DONE
:
// Complete the payment for invoice payments
if
(
$order
->
get_payment_method
()
==
'crefopay_invoice'
)
{
$this
->
logger
->
debug
(
"complete the payment"
);
$order
->
payment_complete
(
$mns
[
'orderID'
]);
$this
->
sendGzdEmailConfirmation
(
$mns
[
'orderID'
]);
}
if
(
$this
->
options
[
'crefopay_orderstate_done'
]
!=
'disabled'
)
{
$newState
=
empty
(
$this
->
options
[
'crefopay_orderstate_done'
])
?
ORDER_STATE_DONE
:
$this
->
options
[
'crefopay_orderstate_done'
];
$this
->
logger
->
debug
(
"set new order status: "
.
$newState
);
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_DONE'
,
'crefopay-payment-
messages
'
)))
{
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_DONE'
,
'crefopay-payment-
solution
'
)))
{
$this
->
logger
->
debug
(
"successfully set new order state "
.
$newState
);
}
else
{
$this
->
logger
->
error
(
"unable to set new order state "
.
$newState
);
...
...
@@ -174,7 +187,7 @@ class CrefoPay_Notification_Processor
if
(
$mns
[
'amount'
]
==
0
)
{
$newState
=
ORDER_STATE_REFUNDED
;
$this
->
logger
->
debug
(
"set new order status: "
.
$newState
);
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_DONE'
,
'crefopay-payment-
messages
'
)))
{
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_DONE'
,
'crefopay-payment-
solution
'
)))
{
$this
->
logger
->
debug
(
"successfully set new order state "
.
$newState
);
}
else
{
$this
->
logger
->
error
(
"unable to set new order state "
.
$newState
);
...
...
@@ -185,7 +198,7 @@ class CrefoPay_Notification_Processor
case
self
::
STATE_PAYMENTFAILED
:
$newState
=
ORDER_STATE_FAILED
;
$this
->
logger
->
debug
(
"set new order status: "
.
$newState
);
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_PAYMENTFAILED'
,
'crefopay-payment-
messages
'
)))
{
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_PAYMENTFAILED'
,
'crefopay-payment-
solution
'
)))
{
$this
->
logger
->
debug
(
"successfully set new order state "
.
$newState
);
}
else
{
$this
->
logger
->
error
(
"unable to set new order state "
.
$newState
);
...
...
@@ -195,7 +208,7 @@ class CrefoPay_Notification_Processor
case
self
::
STATE_CHARGEBACK
:
$newState
=
ORDER_STATE_CHARGEBACK
;
$this
->
logger
->
debug
(
"set new order status: "
.
$newState
);
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_CHARGEBACK'
,
'crefopay-payment-
messages
'
)))
{
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_CHARGEBACK'
,
'crefopay-payment-
solution
'
)))
{
$this
->
logger
->
debug
(
"successfully set new order state "
.
$newState
);
}
else
{
$this
->
logger
->
error
(
"unable to set new order state "
.
$newState
);
...
...
@@ -205,7 +218,7 @@ class CrefoPay_Notification_Processor
case
self
::
STATE_INDUNNING
:
$newState
=
ORDER_STATE_INDUNNING
;
$this
->
logger
->
debug
(
"set new order status: "
.
$newState
);
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_INDUNNING'
,
'crefopay-payment-
messages
'
)))
{
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_INDUNNING'
,
'crefopay-payment-
solution
'
)))
{
$this
->
logger
->
debug
(
"successfully set new order state "
.
$newState
);
}
else
{
$this
->
logger
->
error
(
"unable to set new order state "
.
$newState
);
...
...
@@ -215,7 +228,7 @@ class CrefoPay_Notification_Processor
case
self
::
STATE_IN_COLLECTION
:
$newState
=
ORDER_STATE_INCOLLECTION
;
$this
->
logger
->
debug
(
"set new order status: "
.
$newState
);
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_INCOLLECTION'
,
'crefopay-payment-
messages
'
)))
{
if
(
$order
->
set_status
(
$newState
,
__
(
'TRANSACTION_INCOLLECTION'
,
'crefopay-payment-
solution
'
)))
{
$this
->
logger
->
debug
(
"successfully set new order state "
.
$newState
);
}
else
{
$this
->
logger
->
error
(
"unable to set new order state "
.
$newState
);
...
...
@@ -257,4 +270,20 @@ class CrefoPay_Notification_Processor
{
return
empty
(
$mns
[
'paymentReference'
])
?
''
:
$mns
[
'paymentReference'
];
}
/**
* Sends Germanized order confirmation mail
*
* @param string $order_id
* @return bool
*/
private
function
sendGzdEmailConfirmation
(
string
$order_id
)
{
if
(
class_exists
(
'CrefoPay_GZD_Email_Customer_Paid_For_Order'
))
{
$gzd
=
new
CrefoPay_GZD_Email_Customer_Paid_For_Order
();
$gzd
->
send
(
$order_id
);
return
true
;
}
return
false
;
}
}
crefopay-payment-solution/includes/gateways/class-wc-crefopay-gateway-exception.php
View file @
36a00adc
...
...
@@ -19,7 +19,7 @@ require_once plugin_dir_path(__FILE__) . '../models/class-wc-crefopay-error.php'
*
* @class WC_Crefo_Exception
* @extends WC_Data_Exception
* @version 3.1.
0
* @version 3.1.
1
* @package CrefoPay Payment Solution
*/
class
WC_Crefo_Exception
extends
WC_Data_Exception
...
...
crefopay-payment-solution/includes/gateways/class-wc-payment-gateway-creditcard.php
View file @
36a00adc
...
...
@@ -14,7 +14,7 @@ require_once plugin_dir_path(__FILE__) . '../controllers/class-wc-crefopay.php';
*
* @class WC_Crefo_Credit Card
* @extends WC_Crefo_Gateway
* @version 3.1.
0
* @version 3.1.
1
* @package CrefoPay Payment Solution
*/
class
WC_Crefo_CreditCard
extends
WC_Crefo_Gateway
...
...
@@ -46,10 +46,13 @@ class WC_Crefo_CreditCard extends WC_Crefo_Gateway
*/
public
function
__construct
()
{
$pluginOptions
=
get_option
(
'igp_settings'
);
// payment gateway description
$this
->
_setCrefoLabel
(
PAYMENT_METHOD_CC3D
);
$this
->
id
=
'crefopay_creditcard'
;
$this
->
icon
=
plugin_dir_url
(
false
)
.
'crefopay-payment-solution'
.
'/img/CC.png'
;
if
(
!
$pluginOptions
[
'disable_payment_logos'
])
{
$this
->
icon
=
plugin_dir_url
(
false
)
.
'crefopay-payment-solution'
.
'/img/CC.png'
;
}
$this
->
has_fields
=
false
;
$this
->
scriptsLoaded
=
false
;
$this
->
paymentMethod
=
PAYMENT_METHOD_CC3D
;
...
...
crefopay-payment-solution/includes/gateways/class-wc-payment-gateway-debit.php
View file @
36a00adc
...
...
@@ -15,7 +15,7 @@ require_once plugin_dir_path(__FILE__) . 'class-wc-payment-gateway.php';
*
* @class WC_Crefo_Debit
* @extends WC_Crefo_Gateway
* @version 3.1.
0
* @version 3.1.
1
* @package CrefoPay-Payment-Solution\Gateways
*/
class
WC_Crefo_Debit
extends
WC_Crefo_Gateway
...
...
@@ -68,10 +68,13 @@ class WC_Crefo_Debit extends WC_Crefo_Gateway
*/
public
function
__construct
()
{
$pluginOptions
=
get_option
(
'igp_settings'
);
// payment gateway description
$this
->
_setCrefoLabel
(
PAYMENT_METHOD_DD
);
$this
->
id
=
'crefopay_debit'
;
$this
->
icon
=
plugin_dir_url
(
false
)
.
'crefopay-payment-solution'
.
'/img/DD.png'
;
if
(
!
$pluginOptions
[
'disable_payment_logos'
])
{