Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native gateway icon feature for all gateways (233) #2712

Merged
merged 6 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion modules/ppcp-blocks/resources/js/checkout-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,24 @@ if ( block_enabled ) {
);
}

const PaypalLabel = ( { components, config } ) => {
const { PaymentMethodIcons } = components;

return (
<>
<span
dangerouslySetInnerHTML={ {
__html: config.title,
} }
/>
<PaymentMethodIcons icons={ config.icon } align="right" />
</>
);
};

registerPaymentMethod( {
name: config.id,
label: <div dangerouslySetInnerHTML={ { __html: config.title } } />,
label: <PaypalLabel config={ config } />,
content: descriptionElement,
edit: descriptionElement,
placeOrderButtonLabel: config.placeOrderButtonText,
Expand Down
7 changes: 7 additions & 0 deletions modules/ppcp-blocks/src/PayPalPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,13 @@ public function get_payment_method_data() {
return array(
'id' => $this->gateway->id,
'title' => $this->gateway->title,
'icon' => array(
array(
'id' => 'paypal',
'alt' => 'PayPal',
'src' => $this->gateway->icon,
),
),
'description' => $this->gateway->description,
'smartButtonsEnabled' => $smart_buttons_enabled,
'placeOrderEnabled' => $place_order_enabled,
Expand Down
Empty file modified modules/ppcp-wc-gateway/assets/images/paypal.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions modules/ppcp-wc-gateway/assets/images/paypal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions modules/ppcp-wc-gateway/assets/images/ratepay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion modules/ppcp-wc-gateway/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
$container->get( 'api.endpoint.payment-tokens' ),
$container->get( 'vaulting.vault-v3-enabled' ),
$container->get( 'vaulting.wc-payment-tokens' ),
$container->get( 'wcgateway.url' ),
$container->get( 'wcgateway.settings.admin-settings-enabled' )
);
},
Expand Down Expand Up @@ -1494,7 +1495,8 @@ static function ( ContainerInterface $container ): string {
$container->get( 'wcgateway.pay-upon-invoice-helper' ),
$container->get( 'wcgateway.checkout-helper' ),
$container->get( 'onboarding.state' ),
$container->get( 'wcgateway.processor.refunds' )
$container->get( 'wcgateway.processor.refunds' ),
$container->get( 'wcgateway.url' )
);
},
'wcgateway.fraudnet-source-website-id' => static function ( ContainerInterface $container ): FraudNetSourceWebsiteId {
Expand Down
11 changes: 11 additions & 0 deletions modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ class PayPalGateway extends \WC_Payment_Gateway {
*/
private $wc_payment_tokens;

/**
* The module URL
*
* @var string
*/
private $module_url;

/**
* Whether settings module is enabled.
*
Expand Down Expand Up @@ -232,6 +239,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
* @param PaymentTokensEndpoint $payment_tokens_endpoint Payment tokens endpoint.
* @param bool $vault_v3_enabled Whether Vault v3 module is enabled.
* @param WooCommercePaymentTokens $wc_payment_tokens WooCommerce payment tokens.
* @param string $module_url The module URL.
* @param bool $admin_settings_enabled Whether settings module is enabled.
*/
public function __construct(
Expand All @@ -255,6 +263,7 @@ public function __construct(
PaymentTokensEndpoint $payment_tokens_endpoint,
bool $vault_v3_enabled,
WooCommercePaymentTokens $wc_payment_tokens,
string $module_url,
bool $admin_settings_enabled
) {
$this->id = self::ID;
Expand All @@ -279,6 +288,8 @@ public function __construct(
$this->payment_tokens_endpoint = $payment_tokens_endpoint;
$this->vault_v3_enabled = $vault_v3_enabled;
$this->wc_payment_tokens = $wc_payment_tokens;
$this->module_url = $module_url;
$this->icon = apply_filters( 'woocommerce_paypal_payments_paypal_gateway_icon', esc_url( $this->module_url ) . 'assets/images/paypal.svg' );
$this->admin_settings_enabled = $admin_settings_enabled;

$default_support = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ class PayUponInvoiceGateway extends WC_Payment_Gateway {
*/
protected $refund_processor;

/**
* The module URL
*
* @var string
*/
private $module_url;

/**
* PayUponInvoiceGateway constructor.
*
Expand All @@ -116,6 +123,7 @@ class PayUponInvoiceGateway extends WC_Payment_Gateway {
* @param CheckoutHelper $checkout_helper The checkout helper.
* @param State $state The onboarding state.
* @param RefundProcessor $refund_processor The refund processor.
* @param string $module_url The module URL.
*/
public function __construct(
PayUponInvoiceOrderEndpoint $order_endpoint,
Expand All @@ -127,7 +135,8 @@ public function __construct(
PayUponInvoiceHelper $pui_helper,
CheckoutHelper $checkout_helper,
State $state,
RefundProcessor $refund_processor
RefundProcessor $refund_processor,
string $module_url
) {
$this->id = self::ID;

Expand Down Expand Up @@ -157,6 +166,8 @@ public function __construct(
$this->transaction_url_provider = $transaction_url_provider;
$this->pui_helper = $pui_helper;
$this->checkout_helper = $checkout_helper;
$this->module_url = $module_url;
$this->icon = apply_filters( 'woocommerce_paypal_payments_pay_upon_invoice_gateway_icon', esc_url( $this->module_url ) . 'assets/images/ratepay.svg' );

$this->state = $state;
if ( $state->current_state() === State::STATE_ONBOARDED ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public function setUp(): void
$this->pui_helper,
$this->checkout_helper,
$this->state,
$this->refund_processor
$this->refund_processor,
''
);
}

Expand Down
1 change: 1 addition & 0 deletions tests/PHPUnit/WcGateway/Gateway/WcGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ function ($id) {
$this->paymentTokensEndpoint,
$this->vaultV3Enabled,
$this->wcPaymentTokens,
'',
false
);
}
Expand Down
Loading