Skip to content

Commit

Permalink
Fix subscription activate
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberwombat committed Mar 8, 2021
1 parent cf9e2c0 commit 93c724e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
14 changes: 10 additions & 4 deletions includes/class-wc-gateway-fastspring-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public function ajax_get_receipt()

$order_id = absint(WC()->session->get('current_order'));

$this->log(sprintf('Generating receipt for order %s', $order_id));

$order = wc_get_order($order_id);
$data = ['order_id' => $order->get_id()];

Expand All @@ -125,7 +127,7 @@ public function ajax_get_receipt()
$order->update_meta_data('fs_order_id', $payload->id);

if ($status === 'completed' && $order->payment_complete($payload->reference)) {
$this->log(sprintf('Marking order ID %s as complete', $order->get_id()));
$this->log(sprintf('Marking order ID %s as completed', $order->get_id()));
$order->add_order_note(sprintf(__('FastSpring payment approved (ID: %1$s)', 'woocommerce'), $order->get_id()));
}
// We could have a race condition where FS already called webhook so lets not assume its pending
Expand All @@ -151,15 +153,19 @@ public static function get_return_url($order = null)
{
if ($order) {
$return_url = $order->get_checkout_order_received_url();
self::log(sprintf('Receipt URL for order set to %s', $return_url));
} else {
$return_url = wc_get_endpoint_url('order-received', '', wc_get_page_permalink('checkout'));
self::log(sprintf('Receipt URL set to %s', $return_url));
}

if (is_ssl() || get_option('woocommerce_force_ssl_checkout') == 'yes') {
$return_url = str_replace('http:', 'https:', $return_url);
}

$filtered = apply_filters('woocommerce_get_return_url', $return_url, $order);

self::log(sprintf('Final filtered receipt URL set to %s', $filtered));

return $filtered;
}
Expand Down Expand Up @@ -250,7 +256,7 @@ public function handle_webhook_request($payload)
break;

case 'subscription.activated':
$this->handle_webhook_request_subscription_acivate($payload);
$this->handle_webhook_request_subscription_activate($payload);
break;

case 'subscription.updated':
Expand All @@ -262,7 +268,7 @@ public function handle_webhook_request($payload)
break;
}

$this->log(json_encode($payload));
$this->log(json_encode($payload));
return wp_send_json_success();
} catch (Exception $e) {
return wp_send_json_error($e->getMessage());
Expand Down Expand Up @@ -378,4 +384,4 @@ public static function log($message)
}
}

new WC_Gateway_FastSpring_Handler();
new WC_Gateway_FastSpring_Handler();
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,7 @@ N/A
* Support for payemnt icons, transaction URL

= 1.2.4 =
* Upgrade FastSpring JavasScript to 0.8.3
* Upgrade FastSpring JavasScript to 0.8.3

= 1.2.5 =
* Fix typo causing subscription activate issues
2 changes: 1 addition & 1 deletion woocommerce-gateway-fastspring.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Accept credit card, PayPal, Amazon Pay and other payments on your store using FastSpring.
* Author: Enradia
* Author URI: https://enradia.com/
* Version: 1.2.4
* Version: 1.2.5
* Requires at least: 4.4
* Tested up to: 4.9.6
* WC requires at least: 3.0
Expand Down

0 comments on commit 93c724e

Please sign in to comment.