Skip to content
This repository has been archived by the owner on Sep 14, 2024. It is now read-only.

Commit

Permalink
fix two step
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Feb 15, 2024
1 parent 17fb1e6 commit 2220f8d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/Handlers/IPNHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ protected function handleFinished()
{
$this->order->payment_complete();

if ($this->order->get_meta('_cone_simplepay_two_step_payment_reserved') && ! $this->order->get_meta('_cone_simplepay_two_step_payment_finished')) {
$this->order->update_meta_data('_cone_simplepay_two_step_payment_finished', date('c'));

$this->order->save();
}

$virtual = true;

foreach ($this->order->get_items(['line_item']) as $item) {
Expand Down
1 change: 1 addition & 0 deletions src/Support/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public function send()

if (is_wp_error($response)) {
Log::info($response->get_error_message());

throw new Exception($response->get_error_message());
}

Expand Down
15 changes: 8 additions & 7 deletions src/TwoStepPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,20 @@ class TwoStepPayment
*/
public static function boot()
{
add_filter('woocommerce_order_actions', [static::class, 'register']);
add_filter('woocommerce_order_actions', [static::class, 'register'], 10, 2);
add_action('woocommerce_order_action_'.static::ACTION, [static::class, 'handle']);
}

/**
* Register the action.
*
* @param array $actions
* @param \WC_Order $order
* @return array
*/
public static function register($actions)
public static function register($actions, $order)
{
global $theorder;

if (! $theorder->is_paid()
&& $theorder->get_meta('_cone_simplepay_two_step_payment_reserved')
&& ! $theorder->get_meta('_cone_simplepay_two_step_payment_finished')) {
if ($order->get_meta('_cone_simplepay_two_step_payment_reserved') && ! $order->get_meta('_cone_simplepay_two_step_payment_finished')) {
$actions[static::ACTION] = __('Finish the two step SimplePay payment', 'cone-simplepay');
}

Expand Down Expand Up @@ -69,6 +66,10 @@ public static function handle(WC_Order $order)
throw new Exception(__('Request is invalid', 'cone-simplepay'));
}

if ($order->get_meta('_cone_simplepay_two_step_payment_reserved') && ! $order->get_meta('_cone_simplepay_two_step_payment_finished')) {
$order->update_meta_data('_cone_simplepay_two_step_payment_finished', date('c'));
}

$order->add_order_note(
__('Two step SimplePay payment has been finished.', 'cone-simplepay')
);
Expand Down

0 comments on commit 2220f8d

Please sign in to comment.