PluginProbe
YayMail – WooCommerce Email Customizer / 3.2.2
YayMail – WooCommerce Email Customizer v3.2.2
4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 3.4.2 3.4.3 All 55 releases
yaymail / includes / License / LicenseAPI.php

LicenseAPI.php in YayMail – WooCommerce Email Customizer 3.2.2, at includes/License/LicenseAPI.php

111 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMail\License;
4
5 defined( 'ABSPATH' ) || exit;
6
7 class LicenseAPI {
8 public static function activate_license( $item_id, $license_key ) {
9 try {
10 $response = wp_remote_get( YAYCOMMERCE_SELLER_SITE_URL . '?edd_action=activate_license&item_id=' . $item_id . '&license=' . $license_key . '&url=' . home_url() );
11
12 $response = json_decode( $response['body'] );
13
14 if ( $response->success ) {
15 return array(
16 'success' => true,
17 'expires' => $response->expires,
18 'license_limit' => $response->license_limit,
19 'customer_name' => $response->customer_name,
20 );
21 }
22 return array(
23 'success' => false,
24 'message' => $response->error,
25 );
26 } catch ( \Error $error ) {
27 return array(
28 'success' => false,
29 'message' => 'server_error',
30 );
31 }
32 }
33
34 public static function check_license( $item_id, $license_key ) {
35 try {
36 $response = wp_remote_get( YAYCOMMERCE_SELLER_SITE_URL . '?edd_action=check_license&item_id=' . $item_id . '&license=' . $license_key . '&url=' . home_url() );
37
38 $response = json_decode( $response['body'] );
39
40 if ( true === $response->success ) {
41 if ( 'valid' === $response->license || 'expired' === $response->license ) {
42 return array(
43 'success' => true,
44 'expires' => $response->expires,
45 'license_limit' => $response->license_limit,
46 'customer_name' => $response->customer_name,
47 );
48 }
49 }
50 return array(
51 'success' => false,
52 );
53 } catch ( \Error $error ) {
54 return array(
55 'success' => false,
56 );
57 }
58 }
59
60 public static function get_version( $item_id, $license_key = null ) {
61 try {
62 $api_url = YAYCOMMERCE_SELLER_SITE_URL . '?edd_action=get_version&item_id=' . $item_id;
63 if ( ! empty( $license_key ) ) {
64 $api_url .= '&license=' . $license_key;
65 }
66 $response = wp_remote_get( $api_url );
67 $response = json_decode( $response['body'] );
68 if ( isset( $response->new_version ) ) {
69 return (array) $response;
70 }
71 return false;
72 } catch ( \Error $error ) {
73 return false;
74 }
75 }
76
77 public static function get_error_message( $message ) {
78 $result = '';
79 switch ( $message ) {
80 case 'missing':
81 $result = "License doesn't exist";
82 break;
83 case 'license_not_activable':
84 $result = "Attempting to activate a bundle's parent license";
85 break;
86 case 'disabled':
87 $result = 'License key revoked';
88 break;
89 case 'no_activations_left':
90 $result = 'No activations left';
91 break;
92 case 'expired':
93 $result = 'License has expired';
94 break;
95 case 'key_mismatch':
96 $result = 'License is not valid for this product';
97 break;
98 case 'item_name_mismatch':
99 $result = 'License is not valid for this product';
100 break;
101 case 'server_error':
102 $result = 'Your license could not be activated because of server error.';
103 break;
104 default:
105 $result = 'Your license could not be activated.';
106 break;
107 }
108 return $result;
109 }
110 }
111