Axo gateway skeleton.

This commit is contained in:
Pedro Silva 2024-02-08 14:37:56 +00:00
parent fc7b8022e8
commit b4b5863cb4
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
14 changed files with 2872 additions and 9 deletions

View file

@ -118,7 +118,7 @@ class PayPalBearer implements Bearer {
private function newBearer(): Token {
$key = $this->settings->has( 'client_id' ) && $this->settings->get( 'client_id' ) ? $this->settings->get( 'client_id' ) : $this->key;
$secret = $this->settings->has( 'client_secret' ) && $this->settings->get( 'client_secret' ) ? $this->settings->get( 'client_secret' ) : $this->secret;
$url = trailingslashit( $this->host ) . 'v1/oauth2/token?grant_type=client_credentials';
$url = trailingslashit( $this->host ) . 'v1/oauth2/token?grant_type=client_credentials&intent=sdk_init';
$args = array(
'method' => 'POST',

View file

@ -11,6 +11,7 @@ use Psr\Log\LoggerInterface;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\RequestTrait;
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\PPCP;
use WP_Error;
/**
@ -71,20 +72,27 @@ class UserIdToken {
public function id_token( string $target_customer_id = '' ): string {
$bearer = $this->bearer->bearer();
$url = trailingslashit( $this->host ) . 'v1/oauth2/token?grant_type=client_credentials&response_type=id_token';
$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' => 'Bearer ' . $bearer->token(),
'Authorization' => 'Basic ' . base64_encode( "$key:$secret" ),
'Content-Type' => 'application/x-www-form-urlencoded',
),
);