Skip to content

Commit

Permalink
Lastest cafe changes 5.0.24.p
Browse files Browse the repository at this point in the history
  • Loading branch information
Pebblo committed Aug 22, 2024
1 parent 87a62b1 commit baa30b7
Show file tree
Hide file tree
Showing 71 changed files with 1,631 additions and 1,009 deletions.
1 change: 1 addition & 0 deletions .VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.0.24.009
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,51 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Releases

### [5.0.24]

#### Added
- [New Reg List Table Event Filter (#1451)](https://github.com/eventespresso/cafe/pull/1451)
- NEW

#### Fixed
- [Fix PPC Meta Data Array Error (#1454)](https://github.com/eventespresso/cafe/pull/1454)
- [Fix Event List Shortcode Show Expired Parameter (#1470)](https://github.com/eventespresso/cafe/pull/1470)
- [Force Payment Method Registration When Generating Messages (#1464)](https://github.com/eventespresso/cafe/pull/1464)
- [Ensure editor-buttons Script is Enqueued (#1472)](https://github.com/eventespresso/cafe/pull/1472)
- [PPC. Fix PM thinking it disconnected (#1479)](https://github.com/eventespresso/cafe/pull/1479)
- FIX

#### Changed
- [Build machine 5.0.23.p changes (#1461)](https://github.com/eventespresso/cafe/pull/1461)
- [Add GraphQL interface manager (#1463)](https://github.com/eventespresso/cafe/pull/1463)
- MOD

#### Deprecated
- DEP

#### Removed
- RMV

#### Security
- [Add current_user_can() Check When Updating Timezone (#1475)](https://github.com/eventespresso/cafe/pull/1475)
- SEC



### [5.0.23]


#### Fixed
- [Type Cast Return Value for EE_Admin_Config::useAdvancedEditor() (#1458)](https://github.com/eventespresso/cafe/pull/1458)

#### Changed
- [BuildMachine 5.0.22 changes (#1450)](https://github.com/eventespresso/cafe/pull/1450)






### [5.0.22]

#### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class EEG_PayPalCheckout extends EE_Onsite_Gateway
* @param EE_Payment|null $payment
* @param array|null $billing_info
* @return EE_Payment
* @throws EE_Error
* @throws ReflectionException
*/
public function do_direct_payment($payment, $billing_info = null)
{
Expand Down Expand Up @@ -185,63 +183,6 @@ public static function updatePaymentStatus(
}


/**
* Get PayPal order if already created for this transaction and saved.
*
* @param EE_Payment_Method $paypal_pm
* @param int $TXN_ID
* @return array
*/
public static function getPpOrder(EE_Payment_Method $paypal_pm, int $TXN_ID): array
{
try {
$pp_orders = PayPalExtraMetaManager::getPmOption($paypal_pm, Domain::META_KEY_PAYPAL_ORDERS) ?? [];
return $pp_orders[ $TXN_ID ] ?? [];
} catch (Exception $exception) {
return [];
}
}


/**
* Update PayPal order for this transaction.
*
* @param $order
* @param EE_Payment_Method $paypal_pm
* @param int $TXN_ID
* @return bool
*/
public static function updatePpOrder($order, EE_Payment_Method $paypal_pm, int $TXN_ID): bool
{
try {
$pp_orders = PayPalExtraMetaManager::getPmOption($paypal_pm, Domain::META_KEY_PAYPAL_ORDERS) ?? [];
$pp_orders[ $TXN_ID ] = $order;
return PayPalExtraMetaManager::savePmOption($paypal_pm, Domain::META_KEY_PAYPAL_ORDERS, $pp_orders);
} catch (Exception $exception) {
return false;
}
}


/**
* Delete PP Order associated with the provided transaction.
*
* @param EE_Payment_Method $paypal_pm
* @param int $TXN_ID
* @return bool
*/
public static function deletePpOrder(EE_Payment_Method $paypal_pm, int $TXN_ID): bool
{
try {
$pp_orders = PayPalExtraMetaManager::getPmOption($paypal_pm, Domain::META_KEY_PAYPAL_ORDERS) ?? [];
unset($pp_orders[ $TXN_ID ]);
return PayPalExtraMetaManager::savePmOption($paypal_pm, Domain::META_KEY_PAYPAL_ORDERS, $pp_orders);
} catch (Exception $exception) {
return false;
}
}


/**
* Save some transaction details, like billing information.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ public function __construct($pm_instance = null)
// Display a refund message at transactions actions area.
add_action(
'AHEE__txn_admin_details_main_meta_box_txn_details__after_actions_buttons',
[__CLASS__, 'refundNotice'],
10,
1
[__CLASS__, 'refundNotice']
);

parent::__construct($pm_instance);
Expand Down
10 changes: 4 additions & 6 deletions PaymentMethods/PayPalCommerce/PayPalCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace EventEspresso\PaymentMethods;

use EE_Config;
use EE_Dependency_Map;
use EE_Error;
use EEH_Autoloader;
Expand Down Expand Up @@ -39,8 +38,7 @@ public function initialize()
// Register payment method through a legacy manager.
add_filter(
'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
[__CLASS__, 'injectPaymentMethod'],
10
[__CLASS__, 'injectPaymentMethod']
);
// Load modules.
/** @var LegacyModulesManager $legacy_modules_manager */
Expand All @@ -50,9 +48,9 @@ public function initialize()

// Setup auto loaders.
EEH_Autoloader::instance()->register_autoloader([
'SettingsForm' => EEP_PAYPAL_COMMERCE_PATH . 'forms' . DS . 'SettingsForm.php',
'OnboardingForm' => EEP_PAYPAL_COMMERCE_PATH . 'forms' . DS . 'OnboardingForm.php',
'BillingForm' => EEP_PAYPAL_COMMERCE_PATH . 'forms' . DS . 'BillingForm.php',
'SettingsForm' => EEP_PAYPAL_COMMERCE_PATH . 'forms/SettingsForm.php',
'OnboardingForm' => EEP_PAYPAL_COMMERCE_PATH . 'forms/OnboardingForm.php',
'BillingForm' => EEP_PAYPAL_COMMERCE_PATH . 'forms/BillingForm.php',
]);
}

Expand Down
8 changes: 3 additions & 5 deletions PaymentMethods/PayPalCommerce/api/FirstPartyPayPalApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,13 @@ private function getRequestParameters(array $body_parameters, string $method, ar
'redirection' => 5,
'blocking' => true,
];
$default_headers = [
// add default values to incoming headers.
$request_parameters['headers'] = $headers + [
'User-Agent' => sanitize_text_field($_SERVER['HTTP_USER_AGENT']),
'PayPal-Partner-Attribution-Id' => $this->bn_code,
'Content-Type' => 'application/json',
'Authorization' => 'Basic ' . base64_encode(
$this->client_id . ':' . $this->client_secret
),
'Authorization' => 'Basic ' . base64_encode("$this->client_id:$this->client_secret"),
];
$request_parameters['headers'] = array_merge($default_headers, $headers);
// Add body if this is a POST request.
if ($body_parameters && ($method === 'POST' || $method === 'PUT')) {
$request_parameters['body'] = json_encode($body_parameters);
Expand Down
5 changes: 1 addition & 4 deletions PaymentMethods/PayPalCommerce/api/OneTimeString.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
*/
class OneTimeString
{
/**
* @var string
*/
private $value;
private string $value;


/**
Expand Down
5 changes: 3 additions & 2 deletions PaymentMethods/PayPalCommerce/api/PayPalApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ abstract class PayPalApi
/**
* @param bool $sandbox_mode
*/
public function __construct(bool $sandbox_mode = true) {
public function __construct(bool $sandbox_mode = true)
{
$this->sandbox_mode = $sandbox_mode;
// Is this a sandbox request.
$this->api_endpoint = $this->sandbox_mode
? 'https://api-m.sandbox.paypal.com/v2/'
: 'https://api-m.paypal.com/v2/';
$this->inspector = new ResponseInspector();
$this->inspector = new ResponseInspector();
}


Expand Down
11 changes: 4 additions & 7 deletions PaymentMethods/PayPalCommerce/api/ResponseInspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class ResponseInspector
*
* @var bool
*/
protected $valid = true;
protected bool $valid = true;

/**
* An encountered error.
*
* @var array
*/
protected $error = [];
protected array $error = [];


/**
Expand All @@ -51,13 +51,14 @@ public function isValid(): bool


/**
* Set/save the error.
* Set/save the error and mark the response as invalid
*
* @param array $error
*/
private function setError(array $error)
{
$this->error = $error;
$this->setInValid();
}


Expand Down Expand Up @@ -99,7 +100,6 @@ public function validateResponse($response): bool
),
]
);
$this->setInValid();
return false;
}
// Do we have a response body ?
Expand All @@ -110,7 +110,6 @@ public function validateResponse($response): bool
'message' => esc_html__('No response body provided.', 'event_espresso'),
]
);
$this->setInValid();
return false;
}
return true;
Expand All @@ -132,7 +131,6 @@ public function validateParameters($response): bool
'event_espresso'
),
]);
$this->setInValid();
return false;
}
// Check the data for errors.
Expand All @@ -145,7 +143,6 @@ public function validateParameters($response): bool
'message' => $error_message,
]
);
$this->setInValid();
return false;
}
return true;
Expand Down
29 changes: 15 additions & 14 deletions PaymentMethods/PayPalCommerce/api/ThirdPartyPayPalApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(
string $bn_code,
string $partner_client_id = '',
string $payer_id = '',
bool $sandbox_mode = true
bool $sandbox_mode = true
) {
parent::__construct($sandbox_mode);
$this->access_token = $access_token;
Expand Down Expand Up @@ -90,9 +90,7 @@ public function sendRequest(array $body_parameters, string $endpoint, string $me
*/
private function getRequestParameters(array $body_parameters, string $method, array $headers): array
{
$request_parameters = [
'method' => $method,
];
$request_parameters = ['method' => $method];
$default_headers = [
'User-Agent' => sanitize_text_field($_SERVER['HTTP_USER_AGENT']),
'PayPal-Partner-Attribution-Id' => $this->bnCode(),
Expand All @@ -101,17 +99,20 @@ private function getRequestParameters(array $body_parameters, string $method, ar
];
// If we have merchant credentials then we are onboard and can do requests on behalf of the seller.
if ($this->partner_client_id && $this->payer_id) {
$assertion1 = [
'alg' => 'none',
];
$assertion2 = [
'iss' => $this->partner_client_id,
'payer_id' => $this->payer_id,
];
$default_headers['PayPal-Auth-Assertion'] = base64_encode(json_encode($assertion1, JSON_HEX_APOS)) . '.' .
base64_encode(json_encode($assertion2, JSON_HEX_APOS)) . '.';
$assertion1 = base64_encode(json_encode(['alg' => 'none'], JSON_HEX_APOS));
$assertion2 = base64_encode(
json_encode(
[
'iss' => $this->partner_client_id,
'payer_id' => $this->payer_id,
],
JSON_HEX_APOS
)
);
// now concatenate the two assertions and add to the headers.
$default_headers['PayPal-Auth-Assertion'] = "$assertion1.$assertion2.";
}
$request_parameters['headers'] = array_merge($default_headers, $headers);
$request_parameters['headers'] = $headers + $default_headers;
// Add body if this is a POST request.
if ($body_parameters && ($method === 'POST' || $method === 'PUT')) {
$request_parameters['body'] = json_encode($body_parameters);
Expand Down
8 changes: 3 additions & 5 deletions PaymentMethods/PayPalCommerce/api/clients/ClientToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ class ClientToken extends ClientsApi
* @param PayPalApi $api
* @param bool $sandbox_mode
*/
public function __construct(
PayPalApi $api,
bool $sandbox_mode
) {
public function __construct(PayPalApi $api, bool $sandbox_mode)
{
parent::__construct($api, $sandbox_mode);
$this->request_url = $this->request_url . "/generate-token";
}
Expand Down Expand Up @@ -70,7 +68,7 @@ public function validateResponse(array $response): array
return [
'valid' => true,
'client_token' => $response[ Domain::API_KEY_CLIENT_TOKEN ],
'expires_in' => $response[ Domain::API_KEY_EXPIRES_IN ]
'expires_in' => $response[ Domain::API_KEY_EXPIRES_IN ],
];
}
}
10 changes: 2 additions & 8 deletions PaymentMethods/PayPalCommerce/api/clients/ClientsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,9 @@
*/
abstract class ClientsApi
{
/**
* @var PayPalApi
*/
protected $api;
protected PayPalApi $api;

/**
* @var string
*/
protected $request_url;
protected string $request_url;


/**
Expand Down
2 changes: 2 additions & 0 deletions PaymentMethods/PayPalCommerce/api/orders/CaptureOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public function __construct(PayPalApi $api, EE_Transaction $transaction, string
* Capture payment for PayPal Order.
*
* @return array
* @throws EE_Error
* @throws ReflectionException
*/
public function capture(): array
{
Expand Down
Loading

0 comments on commit baa30b7

Please sign in to comment.