mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Axo gateway skeleton.
This commit is contained in:
parent
fc7b8022e8
commit
b4b5863cb4
14 changed files with 2872 additions and 9 deletions
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue