mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Use ExperienceContext in APMs
This commit is contained in:
parent
4a8b3b74f1
commit
b0ee2cfc6d
9 changed files with 216 additions and 161 deletions
|
@ -81,7 +81,8 @@ return array(
|
|||
$container->get( 'api.endpoint.orders' ),
|
||||
$container->get( 'api.factory.purchase-unit' ),
|
||||
$container->get( 'wcgateway.processor.refunds' ),
|
||||
$container->get( 'wcgateway.transaction-url-provider' )
|
||||
$container->get( 'wcgateway.transaction-url-provider' ),
|
||||
$container->get( 'wcgateway.builder.experience-context' )
|
||||
);
|
||||
},
|
||||
'ppcp-local-apms.blik.wc-gateway' => static function ( ContainerInterface $container ): BlikGateway {
|
||||
|
@ -89,7 +90,8 @@ return array(
|
|||
$container->get( 'api.endpoint.orders' ),
|
||||
$container->get( 'api.factory.purchase-unit' ),
|
||||
$container->get( 'wcgateway.processor.refunds' ),
|
||||
$container->get( 'wcgateway.transaction-url-provider' )
|
||||
$container->get( 'wcgateway.transaction-url-provider' ),
|
||||
$container->get( 'wcgateway.builder.experience-context' )
|
||||
);
|
||||
},
|
||||
'ppcp-local-apms.eps.wc-gateway' => static function ( ContainerInterface $container ): EPSGateway {
|
||||
|
@ -97,7 +99,8 @@ return array(
|
|||
$container->get( 'api.endpoint.orders' ),
|
||||
$container->get( 'api.factory.purchase-unit' ),
|
||||
$container->get( 'wcgateway.processor.refunds' ),
|
||||
$container->get( 'wcgateway.transaction-url-provider' )
|
||||
$container->get( 'wcgateway.transaction-url-provider' ),
|
||||
$container->get( 'wcgateway.builder.experience-context' )
|
||||
);
|
||||
},
|
||||
'ppcp-local-apms.ideal.wc-gateway' => static function ( ContainerInterface $container ): IDealGateway {
|
||||
|
@ -105,7 +108,8 @@ return array(
|
|||
$container->get( 'api.endpoint.orders' ),
|
||||
$container->get( 'api.factory.purchase-unit' ),
|
||||
$container->get( 'wcgateway.processor.refunds' ),
|
||||
$container->get( 'wcgateway.transaction-url-provider' )
|
||||
$container->get( 'wcgateway.transaction-url-provider' ),
|
||||
$container->get( 'wcgateway.builder.experience-context' )
|
||||
);
|
||||
},
|
||||
'ppcp-local-apms.mybank.wc-gateway' => static function ( ContainerInterface $container ): MyBankGateway {
|
||||
|
@ -113,7 +117,8 @@ return array(
|
|||
$container->get( 'api.endpoint.orders' ),
|
||||
$container->get( 'api.factory.purchase-unit' ),
|
||||
$container->get( 'wcgateway.processor.refunds' ),
|
||||
$container->get( 'wcgateway.transaction-url-provider' )
|
||||
$container->get( 'wcgateway.transaction-url-provider' ),
|
||||
$container->get( 'wcgateway.builder.experience-context' )
|
||||
);
|
||||
},
|
||||
'ppcp-local-apms.p24.wc-gateway' => static function ( ContainerInterface $container ): P24Gateway {
|
||||
|
@ -121,7 +126,8 @@ return array(
|
|||
$container->get( 'api.endpoint.orders' ),
|
||||
$container->get( 'api.factory.purchase-unit' ),
|
||||
$container->get( 'wcgateway.processor.refunds' ),
|
||||
$container->get( 'wcgateway.transaction-url-provider' )
|
||||
$container->get( 'wcgateway.transaction-url-provider' ),
|
||||
$container->get( 'wcgateway.builder.experience-context' )
|
||||
);
|
||||
},
|
||||
'ppcp-local-apms.trustly.wc-gateway' => static function ( ContainerInterface $container ): TrustlyGateway {
|
||||
|
@ -129,7 +135,8 @@ return array(
|
|||
$container->get( 'api.endpoint.orders' ),
|
||||
$container->get( 'api.factory.purchase-unit' ),
|
||||
$container->get( 'wcgateway.processor.refunds' ),
|
||||
$container->get( 'wcgateway.transaction-url-provider' )
|
||||
$container->get( 'wcgateway.transaction-url-provider' ),
|
||||
$container->get( 'wcgateway.builder.experience-context' )
|
||||
);
|
||||
},
|
||||
'ppcp-local-apms.multibanco.wc-gateway' => static function ( ContainerInterface $container ): MultibancoGateway {
|
||||
|
@ -137,7 +144,8 @@ return array(
|
|||
$container->get( 'api.endpoint.orders' ),
|
||||
$container->get( 'api.factory.purchase-unit' ),
|
||||
$container->get( 'wcgateway.processor.refunds' ),
|
||||
$container->get( 'wcgateway.transaction-url-provider' )
|
||||
$container->get( 'wcgateway.transaction-url-provider' ),
|
||||
$container->get( 'wcgateway.builder.experience-context' )
|
||||
);
|
||||
},
|
||||
'ppcp-local-apms.bancontact.payment-method' => static function( ContainerInterface $container ): BancontactPaymentMethod {
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods;
|
|||
|
||||
use WC_Payment_Gateway;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\ExperienceContextBuilder;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
|
@ -52,19 +53,26 @@ class BancontactGateway extends WC_Payment_Gateway {
|
|||
*/
|
||||
protected $transaction_url_provider;
|
||||
|
||||
/**
|
||||
* The ExperienceContextBuilder.
|
||||
*/
|
||||
protected ExperienceContextBuilder $experience_context_builder;
|
||||
|
||||
/**
|
||||
* BancontactGateway constructor.
|
||||
*
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param ExperienceContextBuilder $experience_context_builder The ExperienceContextBuilder.
|
||||
*/
|
||||
public function __construct(
|
||||
Orders $orders_endpoint,
|
||||
PurchaseUnitFactory $purchase_unit_factory,
|
||||
RefundProcessor $refund_processor,
|
||||
TransactionUrlProvider $transaction_url_provider
|
||||
TransactionUrlProvider $transaction_url_provider,
|
||||
ExperienceContextBuilder $experience_context_builder
|
||||
) {
|
||||
$this->id = self::ID;
|
||||
|
||||
|
@ -86,10 +94,11 @@ class BancontactGateway extends WC_Payment_Gateway {
|
|||
|
||||
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
|
||||
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->experience_context_builder = $experience_context_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,8 +148,13 @@ class BancontactGateway extends WC_Payment_Gateway {
|
|||
'intent' => 'CAPTURE',
|
||||
'payment_source' => array(
|
||||
'bancontact' => array(
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'experience_context' => $this->experience_context_builder
|
||||
->with_order_return_urls( $wc_order )
|
||||
->build()
|
||||
->with_locale( 'en-BE' )
|
||||
->to_array(),
|
||||
),
|
||||
),
|
||||
'processing_instruction' => 'ORDER_COMPLETE_ON_PAYMENT_APPROVAL',
|
||||
|
@ -155,11 +169,6 @@ class BancontactGateway extends WC_Payment_Gateway {
|
|||
'invoice_id' => $purchase_unit->invoice_id(),
|
||||
),
|
||||
),
|
||||
'application_context' => array(
|
||||
'locale' => 'en-BE',
|
||||
'return_url' => $this->get_return_url( $wc_order ),
|
||||
'cancel_url' => add_query_arg( 'cancelled', 'true', $this->get_return_url( $wc_order ) ),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods;
|
|||
|
||||
use WC_Payment_Gateway;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\ExperienceContextBuilder;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
|
@ -52,19 +53,26 @@ class BlikGateway extends WC_Payment_Gateway {
|
|||
*/
|
||||
protected $transaction_url_provider;
|
||||
|
||||
/**
|
||||
* The ExperienceContextBuilder.
|
||||
*/
|
||||
protected ExperienceContextBuilder $experience_context_builder;
|
||||
|
||||
/**
|
||||
* BlikGateway constructor.
|
||||
*
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param ExperienceContextBuilder $experience_context_builder The ExperienceContextBuilder.
|
||||
*/
|
||||
public function __construct(
|
||||
Orders $orders_endpoint,
|
||||
PurchaseUnitFactory $purchase_unit_factory,
|
||||
RefundProcessor $refund_processor,
|
||||
TransactionUrlProvider $transaction_url_provider
|
||||
TransactionUrlProvider $transaction_url_provider,
|
||||
ExperienceContextBuilder $experience_context_builder
|
||||
) {
|
||||
$this->id = self::ID;
|
||||
|
||||
|
@ -86,10 +94,11 @@ class BlikGateway extends WC_Payment_Gateway {
|
|||
|
||||
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
|
||||
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->experience_context_builder = $experience_context_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,9 +148,14 @@ class BlikGateway extends WC_Payment_Gateway {
|
|||
'intent' => 'CAPTURE',
|
||||
'payment_source' => array(
|
||||
'blik' => array(
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'email' => $wc_order->get_billing_email(),
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'email' => $wc_order->get_billing_email(),
|
||||
'experience_context' => $this->experience_context_builder
|
||||
->with_order_return_urls( $wc_order )
|
||||
->build()
|
||||
->with_locale( 'en-PL' )
|
||||
->to_array(),
|
||||
),
|
||||
),
|
||||
'processing_instruction' => 'ORDER_COMPLETE_ON_PAYMENT_APPROVAL',
|
||||
|
@ -156,11 +170,6 @@ class BlikGateway extends WC_Payment_Gateway {
|
|||
'invoice_id' => $purchase_unit->invoice_id(),
|
||||
),
|
||||
),
|
||||
'application_context' => array(
|
||||
'locale' => 'en-PL',
|
||||
'return_url' => $this->get_return_url( $wc_order ),
|
||||
'cancel_url' => add_query_arg( 'cancelled', 'true', $this->get_return_url( $wc_order ) ),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods;
|
|||
|
||||
use WC_Payment_Gateway;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\ExperienceContextBuilder;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
|
@ -52,19 +53,26 @@ class EPSGateway extends WC_Payment_Gateway {
|
|||
*/
|
||||
protected $transaction_url_provider;
|
||||
|
||||
/**
|
||||
* The ExperienceContextBuilder.
|
||||
*/
|
||||
protected ExperienceContextBuilder $experience_context_builder;
|
||||
|
||||
/**
|
||||
* EPSGateway constructor.
|
||||
*
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param ExperienceContextBuilder $experience_context_builder The ExperienceContextBuilder.
|
||||
*/
|
||||
public function __construct(
|
||||
Orders $orders_endpoint,
|
||||
PurchaseUnitFactory $purchase_unit_factory,
|
||||
RefundProcessor $refund_processor,
|
||||
TransactionUrlProvider $transaction_url_provider
|
||||
TransactionUrlProvider $transaction_url_provider,
|
||||
ExperienceContextBuilder $experience_context_builder
|
||||
) {
|
||||
$this->id = self::ID;
|
||||
|
||||
|
@ -86,10 +94,11 @@ class EPSGateway extends WC_Payment_Gateway {
|
|||
|
||||
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
|
||||
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->experience_context_builder = $experience_context_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,8 +148,13 @@ class EPSGateway extends WC_Payment_Gateway {
|
|||
'intent' => 'CAPTURE',
|
||||
'payment_source' => array(
|
||||
'eps' => array(
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'experience_context' => $this->experience_context_builder
|
||||
->with_order_return_urls( $wc_order )
|
||||
->build()
|
||||
->with_locale( 'en-AT' )
|
||||
->to_array(),
|
||||
),
|
||||
),
|
||||
'processing_instruction' => 'ORDER_COMPLETE_ON_PAYMENT_APPROVAL',
|
||||
|
@ -155,11 +169,6 @@ class EPSGateway extends WC_Payment_Gateway {
|
|||
'invoice_id' => $purchase_unit->invoice_id(),
|
||||
),
|
||||
),
|
||||
'application_context' => array(
|
||||
'locale' => 'en-AT',
|
||||
'return_url' => $this->get_return_url( $wc_order ),
|
||||
'cancel_url' => add_query_arg( 'cancelled', 'true', $this->get_return_url( $wc_order ) ),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods;
|
|||
|
||||
use WC_Payment_Gateway;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\ExperienceContextBuilder;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
|
@ -52,19 +53,26 @@ class IDealGateway extends WC_Payment_Gateway {
|
|||
*/
|
||||
protected $transaction_url_provider;
|
||||
|
||||
/**
|
||||
* The ExperienceContextBuilder.
|
||||
*/
|
||||
protected ExperienceContextBuilder $experience_context_builder;
|
||||
|
||||
/**
|
||||
* IDealGateway constructor.
|
||||
*
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param ExperienceContextBuilder $experience_context_builder The ExperienceContextBuilder.
|
||||
*/
|
||||
public function __construct(
|
||||
Orders $orders_endpoint,
|
||||
PurchaseUnitFactory $purchase_unit_factory,
|
||||
RefundProcessor $refund_processor,
|
||||
TransactionUrlProvider $transaction_url_provider
|
||||
TransactionUrlProvider $transaction_url_provider,
|
||||
ExperienceContextBuilder $experience_context_builder
|
||||
) {
|
||||
$this->id = self::ID;
|
||||
|
||||
|
@ -86,10 +94,11 @@ class IDealGateway extends WC_Payment_Gateway {
|
|||
|
||||
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
|
||||
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->experience_context_builder = $experience_context_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,8 +148,11 @@ class IDealGateway extends WC_Payment_Gateway {
|
|||
'intent' => 'CAPTURE',
|
||||
'payment_source' => array(
|
||||
'ideal' => array(
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'experience_context' => $this->experience_context_builder
|
||||
->with_order_return_urls( $wc_order )
|
||||
->build()->to_array(),
|
||||
),
|
||||
),
|
||||
'processing_instruction' => 'ORDER_COMPLETE_ON_PAYMENT_APPROVAL',
|
||||
|
@ -155,10 +167,6 @@ class IDealGateway extends WC_Payment_Gateway {
|
|||
'invoice_id' => $purchase_unit->invoice_id(),
|
||||
),
|
||||
),
|
||||
'application_context' => array(
|
||||
'return_url' => $this->get_return_url( $wc_order ),
|
||||
'cancel_url' => add_query_arg( 'cancelled', 'true', $this->get_return_url( $wc_order ) ),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods;
|
|||
|
||||
use WC_Payment_Gateway;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\ExperienceContextBuilder;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
|
@ -52,19 +53,26 @@ class MultibancoGateway extends WC_Payment_Gateway {
|
|||
*/
|
||||
protected $transaction_url_provider;
|
||||
|
||||
/**
|
||||
* The ExperienceContextBuilder.
|
||||
*/
|
||||
protected ExperienceContextBuilder $experience_context_builder;
|
||||
|
||||
/**
|
||||
* MultibancoGateway constructor.
|
||||
*
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param ExperienceContextBuilder $experience_context_builder The ExperienceContextBuilder.
|
||||
*/
|
||||
public function __construct(
|
||||
Orders $orders_endpoint,
|
||||
PurchaseUnitFactory $purchase_unit_factory,
|
||||
RefundProcessor $refund_processor,
|
||||
TransactionUrlProvider $transaction_url_provider
|
||||
TransactionUrlProvider $transaction_url_provider,
|
||||
ExperienceContextBuilder $experience_context_builder
|
||||
) {
|
||||
$this->id = self::ID;
|
||||
|
||||
|
@ -86,10 +94,11 @@ class MultibancoGateway extends WC_Payment_Gateway {
|
|||
|
||||
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
|
||||
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->experience_context_builder = $experience_context_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,16 +166,16 @@ class MultibancoGateway extends WC_Payment_Gateway {
|
|||
$request_body = array(
|
||||
'payment_source' => array(
|
||||
'multibanco' => array(
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'experience_context' => $this->experience_context_builder
|
||||
->with_order_return_urls( $wc_order )
|
||||
->build()
|
||||
->with_locale( 'en-PT' )
|
||||
->to_array(),
|
||||
),
|
||||
),
|
||||
'processing_instruction' => 'ORDER_COMPLETE_ON_PAYMENT_APPROVAL',
|
||||
'application_context' => array(
|
||||
'locale' => 'en-PT',
|
||||
'return_url' => $this->get_return_url( $wc_order ),
|
||||
'cancel_url' => add_query_arg( 'cancelled', 'true', $this->get_return_url( $wc_order ) ),
|
||||
),
|
||||
);
|
||||
|
||||
$response = $this->orders_endpoint->confirm_payment_source( $request_body, $body->id );
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods;
|
|||
|
||||
use WC_Payment_Gateway;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\ExperienceContextBuilder;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
|
@ -52,19 +53,26 @@ class MyBankGateway extends WC_Payment_Gateway {
|
|||
*/
|
||||
protected $transaction_url_provider;
|
||||
|
||||
/**
|
||||
* The ExperienceContextBuilder.
|
||||
*/
|
||||
protected ExperienceContextBuilder $experience_context_builder;
|
||||
|
||||
/**
|
||||
* MyBankGateway constructor.
|
||||
*
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param ExperienceContextBuilder $experience_context_builder The ExperienceContextBuilder.
|
||||
*/
|
||||
public function __construct(
|
||||
Orders $orders_endpoint,
|
||||
PurchaseUnitFactory $purchase_unit_factory,
|
||||
RefundProcessor $refund_processor,
|
||||
TransactionUrlProvider $transaction_url_provider
|
||||
TransactionUrlProvider $transaction_url_provider,
|
||||
ExperienceContextBuilder $experience_context_builder
|
||||
) {
|
||||
$this->id = self::ID;
|
||||
|
||||
|
@ -86,10 +94,11 @@ class MyBankGateway extends WC_Payment_Gateway {
|
|||
|
||||
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
|
||||
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->experience_context_builder = $experience_context_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,8 +148,13 @@ class MyBankGateway extends WC_Payment_Gateway {
|
|||
'intent' => 'CAPTURE',
|
||||
'payment_source' => array(
|
||||
'mybank' => array(
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'experience_context' => $this->experience_context_builder
|
||||
->with_order_return_urls( $wc_order )
|
||||
->build()
|
||||
->with_locale( 'en-IT' )
|
||||
->to_array(),
|
||||
),
|
||||
),
|
||||
'processing_instruction' => 'ORDER_COMPLETE_ON_PAYMENT_APPROVAL',
|
||||
|
@ -155,11 +169,6 @@ class MyBankGateway extends WC_Payment_Gateway {
|
|||
'invoice_id' => $purchase_unit->invoice_id(),
|
||||
),
|
||||
),
|
||||
'application_context' => array(
|
||||
'locale' => 'en-IT',
|
||||
'return_url' => $this->get_return_url( $wc_order ),
|
||||
'cancel_url' => add_query_arg( 'cancelled', 'true', $this->get_return_url( $wc_order ) ),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods;
|
|||
|
||||
use WC_Payment_Gateway;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\ExperienceContextBuilder;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
|
@ -52,19 +53,26 @@ class P24Gateway extends WC_Payment_Gateway {
|
|||
*/
|
||||
protected $transaction_url_provider;
|
||||
|
||||
/**
|
||||
* The ExperienceContextBuilder.
|
||||
*/
|
||||
protected ExperienceContextBuilder $experience_context_builder;
|
||||
|
||||
/**
|
||||
* P24Gateway constructor.
|
||||
*
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param ExperienceContextBuilder $experience_context_builder The ExperienceContextBuilder.
|
||||
*/
|
||||
public function __construct(
|
||||
Orders $orders_endpoint,
|
||||
PurchaseUnitFactory $purchase_unit_factory,
|
||||
RefundProcessor $refund_processor,
|
||||
TransactionUrlProvider $transaction_url_provider
|
||||
TransactionUrlProvider $transaction_url_provider,
|
||||
ExperienceContextBuilder $experience_context_builder
|
||||
) {
|
||||
$this->id = self::ID;
|
||||
|
||||
|
@ -86,10 +94,11 @@ class P24Gateway extends WC_Payment_Gateway {
|
|||
|
||||
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
|
||||
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->experience_context_builder = $experience_context_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,9 +148,14 @@ class P24Gateway extends WC_Payment_Gateway {
|
|||
'intent' => 'CAPTURE',
|
||||
'payment_source' => array(
|
||||
'p24' => array(
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'email' => $wc_order->get_billing_email(),
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'email' => $wc_order->get_billing_email(),
|
||||
'experience_context' => $this->experience_context_builder
|
||||
->with_order_return_urls( $wc_order )
|
||||
->build()
|
||||
->with_locale( 'en-PL' )
|
||||
->to_array(),
|
||||
),
|
||||
),
|
||||
'processing_instruction' => 'ORDER_COMPLETE_ON_PAYMENT_APPROVAL',
|
||||
|
@ -156,11 +170,6 @@ class P24Gateway extends WC_Payment_Gateway {
|
|||
'invoice_id' => $purchase_unit->invoice_id(),
|
||||
),
|
||||
),
|
||||
'application_context' => array(
|
||||
'locale' => 'en-PL',
|
||||
'return_url' => $this->get_return_url( $wc_order ),
|
||||
'cancel_url' => add_query_arg( 'cancelled', 'true', $this->get_return_url( $wc_order ) ),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods;
|
|||
|
||||
use WC_Payment_Gateway;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\ExperienceContextBuilder;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
|
@ -52,19 +53,26 @@ class TrustlyGateway extends WC_Payment_Gateway {
|
|||
*/
|
||||
protected $transaction_url_provider;
|
||||
|
||||
/**
|
||||
* The ExperienceContextBuilder.
|
||||
*/
|
||||
protected ExperienceContextBuilder $experience_context_builder;
|
||||
|
||||
/**
|
||||
* TrustlyGateway constructor.
|
||||
*
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param Orders $orders_endpoint PayPal Orders endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory Purchase unit factory.
|
||||
* @param RefundProcessor $refund_processor The Refund Processor.
|
||||
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
||||
* @param ExperienceContextBuilder $experience_context_builder The ExperienceContextBuilder.
|
||||
*/
|
||||
public function __construct(
|
||||
Orders $orders_endpoint,
|
||||
PurchaseUnitFactory $purchase_unit_factory,
|
||||
RefundProcessor $refund_processor,
|
||||
TransactionUrlProvider $transaction_url_provider
|
||||
TransactionUrlProvider $transaction_url_provider,
|
||||
ExperienceContextBuilder $experience_context_builder
|
||||
) {
|
||||
$this->id = self::ID;
|
||||
|
||||
|
@ -86,10 +94,11 @@ class TrustlyGateway extends WC_Payment_Gateway {
|
|||
|
||||
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
|
||||
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->orders_endpoint = $orders_endpoint;
|
||||
$this->purchase_unit_factory = $purchase_unit_factory;
|
||||
$this->refund_processor = $refund_processor;
|
||||
$this->transaction_url_provider = $transaction_url_provider;
|
||||
$this->experience_context_builder = $experience_context_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,9 +148,13 @@ class TrustlyGateway extends WC_Payment_Gateway {
|
|||
'intent' => 'CAPTURE',
|
||||
'payment_source' => array(
|
||||
'trustly' => array(
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'email' => $wc_order->get_billing_email(),
|
||||
'country_code' => $wc_order->get_billing_country(),
|
||||
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
|
||||
'email' => $wc_order->get_billing_email(),
|
||||
'experience_context' => $this->experience_context_builder
|
||||
->with_order_return_urls( $wc_order )
|
||||
->with_current_locale()
|
||||
->build()->to_array(),
|
||||
),
|
||||
),
|
||||
'processing_instruction' => 'ORDER_COMPLETE_ON_PAYMENT_APPROVAL',
|
||||
|
@ -156,11 +169,6 @@ class TrustlyGateway extends WC_Payment_Gateway {
|
|||
'invoice_id' => $purchase_unit->invoice_id(),
|
||||
),
|
||||
),
|
||||
'application_context' => array(
|
||||
'locale' => $this->valid_bcp47_code(),
|
||||
'return_url' => $this->get_return_url( $wc_order ),
|
||||
'cancel_url' => add_query_arg( 'cancelled', 'true', $this->get_return_url( $wc_order ) ),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
|
@ -228,27 +236,4 @@ class TrustlyGateway extends WC_Payment_Gateway {
|
|||
|
||||
return parent::get_transaction_url( $order );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a PayPal-supported BCP-47 code, for example de-DE-formal becomes de-DE.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function valid_bcp47_code() {
|
||||
$locale = str_replace( '_', '-', get_user_locale() );
|
||||
|
||||
if ( preg_match( '/^[a-z]{2}(?:-[A-Z][a-z]{3})?(?:-(?:[A-Z]{2}))?$/', $locale ) ) {
|
||||
return $locale;
|
||||
}
|
||||
|
||||
$parts = explode( '-', $locale );
|
||||
if ( count( $parts ) === 3 ) {
|
||||
$ret = substr( $locale, 0, strrpos( $locale, '-' ) );
|
||||
if ( false !== $ret ) {
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 'en';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue