Skip to content

Commit

Permalink
Support custom name and description for Afterpay (#3399)
Browse files Browse the repository at this point in the history
* Support custom name and description for Afterpay

* Add changelog and readme entries

* Add unit test
  • Loading branch information
annemirasol authored Sep 3, 2024
1 parent cebe0cb commit bf88cd5
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 19 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*** Changelog ***

= 8.7.0 - xxxx-xx-xx =
* Fix - Support custom name and description for Afterpay.
* Fix - Link APM charge IDs in Order Details page to their Stripe dashboard payments page.
* Fix - Fix Indian subscription processing by forcing the recreation of mandates during switches (upgrading/downgrading).
* Fix - Add back support for Stripe Link autofill for shortcode checkout.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,12 @@ public function __construct() {
*/
public function get_title( $payment_details = false ) {
if ( $this->is_gb_country() ) {
return __( 'Clearpay', 'woocommerce-gateway-stripe' );
$this->title = __( 'Clearpay', 'woocommerce-gateway-stripe' );
} else {
$this->title = __( 'Afterpay', 'woocommerce-gateway-stripe' );
}
return __( 'Afterpay', 'woocommerce-gateway-stripe' );
}

/**
* Return the gateway's description.
*
* @return string
*/
public function get_description( $payment_details = false ) {
if ( $this->is_gb_country() ) {
return __(
'Allow customers to pay over time with Clearpay.',
'woocommerce-gateway-stripe'
);
}
return __(
'Allow customers to pay over time with Afterpay.',
'woocommerce-gateway-stripe'
);
return parent::get_title( $payment_details );
}

/**
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ If you get stuck, you can ask for help in the Plugin Forum.
== Changelog ==

= 8.7.0 - xxxx-xx-xx =
* Fix - Support custom name and description for Afterpay.
* Fix - Link APM charge IDs in Order Details page to their Stripe dashboard payments page.
* Fix - Fix Indian subscription processing by forcing the recreation of mandates during switches (upgrading/downgrading).
* Fix - Add back support for Stripe Link autofill for shortcode checkout.
Expand Down
38 changes: 38 additions & 0 deletions tests/phpunit/test-class-wc-stripe-upe-payment-method.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,44 @@ public function test_payment_methods_are_reusable_if_cart_contains_subscription(
}
}

public function test_payment_methods_support_custom_name_and_description() {
$payment_method_ids = [
'card',
'klarna',
'afterpay_clearpay',
'affirm',
'p24',
'eps',
'sepa_debit',
'sofort',
'bancontact',
'ideal',
'boleto',
'multibanco',
'oxxo',
'wechat_pay',
];

foreach ( $payment_method_ids as $payment_method_id ) {
$payment_method = $this->mock_payment_methods[ $payment_method_id ];

// Update the payment method settings to have a custom name and description.
$original_payment_settings = get_option( 'woocommerce_stripe_' . $payment_method_id . '_settings', [] );
$updated_payment_settings = $original_payment_settings;
$custom_name = 'Custom Name for ' . $payment_method_id;
$custom_description = 'Custom description for ' . $payment_method_id;
$updated_payment_settings['title'] = $custom_name;
$updated_payment_settings['description'] = $custom_description;
update_option( 'woocommerce_stripe_' . $payment_method_id . '_settings', $updated_payment_settings );

$this->assertEquals( $custom_name, $payment_method->get_title() );
$this->assertEquals( $custom_description, $payment_method->get_description() );

// Restore original settings.
update_option( 'woocommerce_stripe_' . $payment_method_id . '_settings', $original_payment_settings );
}
}

/**
* Test the type of payment token created for the user.
*/
Expand Down

0 comments on commit bf88cd5

Please sign in to comment.