Revert authentication
This commit is contained in:
Pedro Silva 2024-02-19 14:48:02 +00:00
parent 288abde752
commit e0dd215d92
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
7 changed files with 41 additions and 43 deletions

View file

@ -74,25 +74,18 @@ class UserIdToken {
$url = trailingslashit( $this->host ) . 'v1/oauth2/token?grant_type=client_credentials&response_type=id_token&intent=sdk_init';
if ( $target_customer_id ) {
// $url = add_query_arg(
// array(
// 'target_customer_id' => $target_customer_id,
// ),
// $url
// );
$url = add_query_arg(
array(
'target_customer_id' => $target_customer_id,
),
$url
);
}
// TODO fix this to use Bearer instead of Basic auth:
$settings = PPCP::container()->get( 'wcgateway.settings' );
$key = $settings->has( 'client_id' ) && $settings->get( 'client_id' ) ? $settings->get( 'client_id' ) : null;
$secret = $settings->has( 'client_secret' ) && $settings->get( 'client_secret' ) ? $settings->get( 'client_secret' ) : null;
$args = array(
'method' => 'POST',
'headers' => array(
// 'Authorization' => 'Bearer ' . $bearer->token(),
'Authorization' => 'Basic ' . base64_encode( "$key:$secret" ),
'Authorization' => 'Bearer ' . $bearer->token(),
'Content-Type' => 'application/x-www-form-urlencoded',
),
);

View file

@ -131,8 +131,8 @@ return array(
$fields,
'allow_card_button_gateway',
array(
'spacer' => array(
'title' => __( '', 'woocommerce-paypal-payments' ),
'spacer' => array(
'title' => '',
'type' => 'ppcp-text',
'text' => '',
'class' => array(),

View file

@ -35,7 +35,7 @@ return array(
$fields,
'vault_enabled',
array(
'axo_enabled' => array(
'axo_enabled' => array(
'title' => __( 'Fastlane', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'Enable Fastlane Checkout', 'woocommerce-paypal-payments' )
@ -67,7 +67,7 @@ return array(
),
),
),
'axo_gateway_title' => array(
'axo_gateway_title' => array(
'title' => __( 'Gateway Title', 'woocommerce-paypal-payments' ),
'type' => 'text',
'classes' => array( 'ppcp-field-indent' ),
@ -86,7 +86,7 @@ return array(
'requirements' => array(),
'gateway' => 'paypal',
),
'axo_email_widget' => array(
'axo_email_widget' => array(
'title' => __( 'Email Widget', 'woocommerce-paypal-payments' ),
'type' => 'select',
'desc_tip' => true,
@ -103,7 +103,7 @@ return array(
'gateway' => 'paypal',
'requirements' => array(),
),
'axo_address_widget' => array(
'axo_address_widget' => array(
'title' => __( 'Address Widget', 'woocommerce-paypal-payments' ),
'type' => 'select',
'desc_tip' => true,
@ -120,7 +120,7 @@ return array(
'gateway' => 'paypal',
'requirements' => array(),
),
'axo_payment_widget' => array(
'axo_payment_widget' => array(
'title' => __( 'Payment Widget', 'woocommerce-paypal-payments' ),
'type' => 'select',
'desc_tip' => true,

View file

@ -15,7 +15,7 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
return array(
'axo.url' => static function ( ContainerInterface $container ): string {
'axo.url' => static function ( ContainerInterface $container ): string {
$path = realpath( __FILE__ );
if ( false === $path ) {
return '';
@ -26,7 +26,7 @@ return array(
);
},
'axo.manager' => static function ( ContainerInterface $container ): AxoManager {
'axo.manager' => static function ( ContainerInterface $container ): AxoManager {
return new AxoManager(
$container->get( 'axo.url' ),
$container->get( 'ppcp.asset-version' ),
@ -39,7 +39,7 @@ return array(
);
},
'axo.gateway' => static function ( ContainerInterface $container ): AxoGateway {
'axo.gateway' => static function ( ContainerInterface $container ): AxoGateway {
return new AxoGateway(
$container->get( 'wcgateway.settings' ),
$container->get( 'wcgateway.url' ),
@ -49,10 +49,22 @@ return array(
'axo.card_icons' => static function ( ContainerInterface $container ): array {
return array(
array('title' => 'Visa', 'file' => 'visa-dark.svg'),
array('title' => 'MasterCard', 'file' => 'mastercard-dark.svg'),
array('title' => 'American Express', 'file' => 'amex.svg'),
array('title' => 'Discover', 'file' => 'discover.svg'),
array(
'title' => 'Visa',
'file' => 'visa-dark.svg',
),
array(
'title' => 'MasterCard',
'file' => 'mastercard-dark.svg',
),
array(
'title' => 'American Express',
'file' => 'amex.svg',
),
array(
'title' => 'Discover',
'file' => 'discover.svg',
),
);
},

View file

@ -159,7 +159,7 @@ class AxoManager {
'email' => $email_widget ?: 'render',
'address' => $address_widget ?: 'render',
'payment' => $payment_widget ?: 'render',
)
),
);
}

View file

@ -38,7 +38,7 @@ class AxoModule implements ModuleInterface {
add_filter(
'woocommerce_payment_gateways',
function ( $methods ) use ( $c ): array {
$methods[] = $c->get('axo.gateway');
$methods[] = $c->get( 'axo.gateway' );
return $methods;
},
1,

View file

@ -44,6 +44,8 @@ class AxoGateway extends WC_Payment_Gateway {
* AXOGateway constructor.
*
* @param ContainerInterface $ppcp_settings The settings.
* @param string $wcgateway_module_url The WcGateway module URL.
* @param array $card_icons The card icons.
*/
public function __construct(
ContainerInterface $ppcp_settings,
@ -66,7 +68,7 @@ class AxoGateway extends WC_Payment_Gateway {
? $this->ppcp_settings->get( 'axo_gateway_title' )
: $this->get_option( 'title', $this->method_title );
$this->description = $this->get_option( 'description', __( '', 'woocommerce-paypal-payments' ) );
$this->description = $this->get_option( 'description', '' );
$this->init_form_fields();
$this->init_settings();
@ -78,15 +80,6 @@ class AxoGateway extends WC_Payment_Gateway {
'process_admin_options',
)
);
// $this->order_endpoint = $order_endpoint;
// $this->purchase_unit_factory = $purchase_unit_factory;
// $this->shipping_preference_factory = $shipping_preference_factory;
// $this->module_url = $module_url;
// $this->logger = $logger;
// $this->icon = esc_url( $this->module_url ) . 'assets/images/axo.svg'; // TODO
// $this->environment = $environment;
}
/**
@ -94,7 +87,7 @@ class AxoGateway extends WC_Payment_Gateway {
*/
public function init_form_fields() {
$this->form_fields = array(
'enabled' => array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'AXO', 'woocommerce-paypal-payments' ),
@ -112,7 +105,7 @@ class AxoGateway extends WC_Payment_Gateway {
* @return array
*/
public function process_payment( $order_id ) {
$wc_order = wc_get_order( $order_id );
$wc_order = wc_get_order( $order_id );
// TODO ...
@ -139,7 +132,7 @@ class AxoGateway extends WC_Payment_Gateway {
}
$images = array();
foreach ($this->card_icons as $card) {
foreach ( $this->card_icons as $card ) {
$images[] = '<img
class="ppcp-card-icon"
title="' . $card['title'] . '"