mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Use client credentials
This commit is contained in:
parent
a152027772
commit
bea17db588
4 changed files with 75 additions and 32 deletions
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
* The client credentials.
|
||||
*
|
||||
* @package WooCommerce\PayPalCommerce\ApiClient\Authentication
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\ApiClient\Authentication;
|
||||
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
/**
|
||||
* Class ClientCredentials
|
||||
*/
|
||||
class ClientCredentials {
|
||||
|
||||
/**
|
||||
* The settings.
|
||||
*
|
||||
* @var Settings
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* ClientCredentials constructor.
|
||||
*
|
||||
* @param Settings $settings The settings.
|
||||
*/
|
||||
public function __construct(Settings $settings) {
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
public function credentials(): string {
|
||||
$client_id = $this->settings->has( 'client_id' ) ? $this->settings->get( 'client_id' ) : '';
|
||||
$client_secret = $this->settings->has( 'client_secret' ) ? $this->settings->get( 'client_secret' ) : '';
|
||||
|
||||
return 'Basic ' . base64_encode($client_id . ':' . $client_secret);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue