mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Fix lint
Revert authentication
This commit is contained in:
parent
288abde752
commit
e0dd215d92
7 changed files with 41 additions and 43 deletions
|
@ -74,25 +74,18 @@ class UserIdToken {
|
||||||
|
|
||||||
$url = trailingslashit( $this->host ) . 'v1/oauth2/token?grant_type=client_credentials&response_type=id_token&intent=sdk_init';
|
$url = trailingslashit( $this->host ) . 'v1/oauth2/token?grant_type=client_credentials&response_type=id_token&intent=sdk_init';
|
||||||
if ( $target_customer_id ) {
|
if ( $target_customer_id ) {
|
||||||
// $url = add_query_arg(
|
$url = add_query_arg(
|
||||||
// array(
|
array(
|
||||||
// 'target_customer_id' => $target_customer_id,
|
'target_customer_id' => $target_customer_id,
|
||||||
// ),
|
),
|
||||||
// $url
|
$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(
|
$args = array(
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'headers' => array(
|
'headers' => array(
|
||||||
// 'Authorization' => 'Bearer ' . $bearer->token(),
|
'Authorization' => 'Bearer ' . $bearer->token(),
|
||||||
'Authorization' => 'Basic ' . base64_encode( "$key:$secret" ),
|
|
||||||
|
|
||||||
'Content-Type' => 'application/x-www-form-urlencoded',
|
'Content-Type' => 'application/x-www-form-urlencoded',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -131,8 +131,8 @@ return array(
|
||||||
$fields,
|
$fields,
|
||||||
'allow_card_button_gateway',
|
'allow_card_button_gateway',
|
||||||
array(
|
array(
|
||||||
'spacer' => array(
|
'spacer' => array(
|
||||||
'title' => __( '', 'woocommerce-paypal-payments' ),
|
'title' => '',
|
||||||
'type' => 'ppcp-text',
|
'type' => 'ppcp-text',
|
||||||
'text' => '',
|
'text' => '',
|
||||||
'class' => array(),
|
'class' => array(),
|
||||||
|
|
|
@ -35,7 +35,7 @@ return array(
|
||||||
$fields,
|
$fields,
|
||||||
'vault_enabled',
|
'vault_enabled',
|
||||||
array(
|
array(
|
||||||
'axo_enabled' => array(
|
'axo_enabled' => array(
|
||||||
'title' => __( 'Fastlane', 'woocommerce-paypal-payments' ),
|
'title' => __( 'Fastlane', 'woocommerce-paypal-payments' ),
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'label' => __( 'Enable Fastlane Checkout', 'woocommerce-paypal-payments' )
|
'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' ),
|
'title' => __( 'Gateway Title', 'woocommerce-paypal-payments' ),
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'classes' => array( 'ppcp-field-indent' ),
|
'classes' => array( 'ppcp-field-indent' ),
|
||||||
|
@ -86,7 +86,7 @@ return array(
|
||||||
'requirements' => array(),
|
'requirements' => array(),
|
||||||
'gateway' => 'paypal',
|
'gateway' => 'paypal',
|
||||||
),
|
),
|
||||||
'axo_email_widget' => array(
|
'axo_email_widget' => array(
|
||||||
'title' => __( 'Email Widget', 'woocommerce-paypal-payments' ),
|
'title' => __( 'Email Widget', 'woocommerce-paypal-payments' ),
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
|
@ -103,7 +103,7 @@ return array(
|
||||||
'gateway' => 'paypal',
|
'gateway' => 'paypal',
|
||||||
'requirements' => array(),
|
'requirements' => array(),
|
||||||
),
|
),
|
||||||
'axo_address_widget' => array(
|
'axo_address_widget' => array(
|
||||||
'title' => __( 'Address Widget', 'woocommerce-paypal-payments' ),
|
'title' => __( 'Address Widget', 'woocommerce-paypal-payments' ),
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
|
@ -120,7 +120,7 @@ return array(
|
||||||
'gateway' => 'paypal',
|
'gateway' => 'paypal',
|
||||||
'requirements' => array(),
|
'requirements' => array(),
|
||||||
),
|
),
|
||||||
'axo_payment_widget' => array(
|
'axo_payment_widget' => array(
|
||||||
'title' => __( 'Payment Widget', 'woocommerce-paypal-payments' ),
|
'title' => __( 'Payment Widget', 'woocommerce-paypal-payments' ),
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
|
|
|
@ -15,7 +15,7 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
|
||||||
'axo.url' => static function ( ContainerInterface $container ): string {
|
'axo.url' => static function ( ContainerInterface $container ): string {
|
||||||
$path = realpath( __FILE__ );
|
$path = realpath( __FILE__ );
|
||||||
if ( false === $path ) {
|
if ( false === $path ) {
|
||||||
return '';
|
return '';
|
||||||
|
@ -26,7 +26,7 @@ return array(
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
'axo.manager' => static function ( ContainerInterface $container ): AxoManager {
|
'axo.manager' => static function ( ContainerInterface $container ): AxoManager {
|
||||||
return new AxoManager(
|
return new AxoManager(
|
||||||
$container->get( 'axo.url' ),
|
$container->get( 'axo.url' ),
|
||||||
$container->get( 'ppcp.asset-version' ),
|
$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(
|
return new AxoGateway(
|
||||||
$container->get( 'wcgateway.settings' ),
|
$container->get( 'wcgateway.settings' ),
|
||||||
$container->get( 'wcgateway.url' ),
|
$container->get( 'wcgateway.url' ),
|
||||||
|
@ -49,10 +49,22 @@ return array(
|
||||||
|
|
||||||
'axo.card_icons' => static function ( ContainerInterface $container ): array {
|
'axo.card_icons' => static function ( ContainerInterface $container ): array {
|
||||||
return array(
|
return array(
|
||||||
array('title' => 'Visa', 'file' => 'visa-dark.svg'),
|
array(
|
||||||
array('title' => 'MasterCard', 'file' => 'mastercard-dark.svg'),
|
'title' => 'Visa',
|
||||||
array('title' => 'American Express', 'file' => 'amex.svg'),
|
'file' => 'visa-dark.svg',
|
||||||
array('title' => 'Discover', 'file' => 'discover.svg'),
|
),
|
||||||
|
array(
|
||||||
|
'title' => 'MasterCard',
|
||||||
|
'file' => 'mastercard-dark.svg',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'title' => 'American Express',
|
||||||
|
'file' => 'amex.svg',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'title' => 'Discover',
|
||||||
|
'file' => 'discover.svg',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ class AxoManager {
|
||||||
'email' => $email_widget ?: 'render',
|
'email' => $email_widget ?: 'render',
|
||||||
'address' => $address_widget ?: 'render',
|
'address' => $address_widget ?: 'render',
|
||||||
'payment' => $payment_widget ?: 'render',
|
'payment' => $payment_widget ?: 'render',
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ class AxoModule implements ModuleInterface {
|
||||||
add_filter(
|
add_filter(
|
||||||
'woocommerce_payment_gateways',
|
'woocommerce_payment_gateways',
|
||||||
function ( $methods ) use ( $c ): array {
|
function ( $methods ) use ( $c ): array {
|
||||||
$methods[] = $c->get('axo.gateway');
|
$methods[] = $c->get( 'axo.gateway' );
|
||||||
return $methods;
|
return $methods;
|
||||||
},
|
},
|
||||||
1,
|
1,
|
||||||
|
|
|
@ -44,6 +44,8 @@ class AxoGateway extends WC_Payment_Gateway {
|
||||||
* AXOGateway constructor.
|
* AXOGateway constructor.
|
||||||
*
|
*
|
||||||
* @param ContainerInterface $ppcp_settings The settings.
|
* @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(
|
public function __construct(
|
||||||
ContainerInterface $ppcp_settings,
|
ContainerInterface $ppcp_settings,
|
||||||
|
@ -66,7 +68,7 @@ class AxoGateway extends WC_Payment_Gateway {
|
||||||
? $this->ppcp_settings->get( 'axo_gateway_title' )
|
? $this->ppcp_settings->get( 'axo_gateway_title' )
|
||||||
: $this->get_option( 'title', $this->method_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_form_fields();
|
||||||
$this->init_settings();
|
$this->init_settings();
|
||||||
|
@ -78,15 +80,6 @@ class AxoGateway extends WC_Payment_Gateway {
|
||||||
'process_admin_options',
|
'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() {
|
public function init_form_fields() {
|
||||||
$this->form_fields = array(
|
$this->form_fields = array(
|
||||||
'enabled' => array(
|
'enabled' => array(
|
||||||
'title' => __( 'Enable/Disable', 'woocommerce-paypal-payments' ),
|
'title' => __( 'Enable/Disable', 'woocommerce-paypal-payments' ),
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'label' => __( 'AXO', 'woocommerce-paypal-payments' ),
|
'label' => __( 'AXO', 'woocommerce-paypal-payments' ),
|
||||||
|
@ -112,7 +105,7 @@ class AxoGateway extends WC_Payment_Gateway {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function process_payment( $order_id ) {
|
public function process_payment( $order_id ) {
|
||||||
$wc_order = wc_get_order( $order_id );
|
$wc_order = wc_get_order( $order_id );
|
||||||
|
|
||||||
// TODO ...
|
// TODO ...
|
||||||
|
|
||||||
|
@ -139,7 +132,7 @@ class AxoGateway extends WC_Payment_Gateway {
|
||||||
}
|
}
|
||||||
|
|
||||||
$images = array();
|
$images = array();
|
||||||
foreach ($this->card_icons as $card) {
|
foreach ( $this->card_icons as $card ) {
|
||||||
$images[] = '<img
|
$images[] = '<img
|
||||||
class="ppcp-card-icon"
|
class="ppcp-card-icon"
|
||||||
title="' . $card['title'] . '"
|
title="' . $card['title'] . '"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue