Initial commit
diff --git a/includes/notes/class-wc-stripe-upe-availability-note.php b/includes/notes/class-wc-stripe-upe-availability-note.php
new file mode 100644
index 0000000..e044312
--- /dev/null
+++ b/includes/notes/class-wc-stripe-upe-availability-note.php
@@ -0,0 +1,105 @@
+<?php
+/**
+ * Display a notice to merchants to inform about UPE.
+ *
+ * @package WooCommerce\Payments\Admin
+ */
+
+use Automattic\WooCommerce\Admin\Notes\NoteTraits;
+use Automattic\WooCommerce\Admin\Notes\Note;
+use Automattic\WooCommerce\Admin\Notes\WC_Admin_Note;
+
+defined( 'ABSPATH' ) || exit;
+
+/**
+ * Class WC_Stripe_UPE_Availability_Note
+ */
+class WC_Stripe_UPE_Availability_Note {
+ use NoteTraits;
+
+ /**
+ * Name of the note for use in the database.
+ */
+ const NOTE_NAME = 'wc-stripe-upe-availability-note';
+
+ /**
+ * Link to enable the UPE in store.
+ */
+ const ENABLE_IN_STORE_LINK = '?page=wc-settings&tab=checkout§ion=stripe&panel=settings&highlight=enable-upe';
+
+
+ /**
+ * Get the note.
+ */
+ public static function get_note() {
+ $note_class = self::get_note_class();
+ $note = new $note_class();
+
+ $note->set_title( __( 'Boost your sales with the new payment experience in Stripe', 'woocommerce-gateway-stripe' ) );
+ $message = sprintf(
+ /* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
+ __( 'Get early access to an improved checkout experience, now available to select merchants. %1$sLearn more%2$s.', 'woocommerce-gateway-stripe' ),
+ '<a href="https://woocommerce.com/document/stripe/#new-checkout-experience" target="_blank">',
+ '</a>'
+ );
+ $note->set_content( $message );
+ $note->set_type( $note_class::E_WC_ADMIN_NOTE_INFORMATIONAL );
+ $note->set_name( self::NOTE_NAME );
+ $note->set_source( 'woocommerce-gateway-stripe' );
+ $note->add_action(
+ self::NOTE_NAME,
+ __( 'Enable in your store', 'woocommerce-gateway-stripe' ),
+ self::ENABLE_IN_STORE_LINK,
+ $note_class::E_WC_ADMIN_NOTE_UNACTIONED,
+ true
+ );
+
+ return $note;
+ }
+
+ /**
+ * Get the class type to be used for the note.
+ *
+ * @return string
+ */
+ private static function get_note_class() {
+ if ( class_exists( 'Automattic\WooCommerce\Admin\Notes\Note' ) ) {
+ return Note::class;
+ } else {
+ return WC_Admin_Note::class;
+ }
+ }
+
+ public static function init() {
+ /**
+ * No need to display the admin inbox note when
+ * - UPE preview is disabled
+ * - UPE is already enabled
+ * - UPE has been manually disabled
+ * - Stripe is not enabled
+ */
+ if ( ! WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
+ return;
+ }
+
+ if ( WC_Stripe_Feature_Flags::is_upe_checkout_enabled() ) {
+ return;
+ }
+
+ if ( WC_Stripe_Feature_Flags::did_merchant_disable_upe() ) {
+ return;
+ }
+
+ if ( ! woocommerce_gateway_stripe()->connect->is_connected() ) {
+ return;
+ }
+
+ $stripe_settings = get_option( 'woocommerce_stripe_settings', [] );
+ $stripe_enabled = isset( $stripe_settings['enabled'] ) && 'yes' === $stripe_settings['enabled'];
+ if ( ! $stripe_enabled ) {
+ return;
+ }
+
+ self::possibly_add_note();
+ }
+}
diff --git a/includes/notes/class-wc-stripe-upe-stripelink-note.php b/includes/notes/class-wc-stripe-upe-stripelink-note.php
new file mode 100644
index 0000000..81ec439
--- /dev/null
+++ b/includes/notes/class-wc-stripe-upe-stripelink-note.php
@@ -0,0 +1,108 @@
+<?php
+/**
+ * Display a notice to merchants to inform about Stripe Link.
+ *
+ * @package WooCommerce\Payments\Admin
+ */
+
+use Automattic\WooCommerce\Admin\Notes\NoteTraits;
+use Automattic\WooCommerce\Admin\Notes\Note;
+use Automattic\WooCommerce\Admin\Notes\WC_Admin_Note;
+
+defined( 'ABSPATH' ) || exit;
+
+/**
+ * Class WC_Stripe_UPE_StripeLink_Note
+ */
+class WC_Stripe_UPE_StripeLink_Note {
+ use NoteTraits;
+
+ /**
+ * Name of the note for use in the database.
+ */
+ const NOTE_NAME = 'wc-stripe-upe-stripelink-note';
+
+ /**
+ * Link to Stripe Link documentation.
+ */
+ const NOTE_DOCUMENTATION_URL = 'https://woocommerce.com/document/stripe/#stripe-link';
+
+ /**
+ * Get the note.
+ */
+ public static function get_note() {
+ $note_class = self::get_note_class();
+ $note = new $note_class();
+
+ $note->set_title( __( 'Increase conversion at checkout', 'woocommerce-gateway-stripe' ) );
+ $note->set_content( __( 'Reduce cart abandonment and create a frictionless checkout experience with Link by Stripe. Link autofills your customer’s payment and shipping details so they can check out in just six seconds with the Link optimized experience.', 'woocommerce-gateway-stripe' ) );
+
+ $note->set_type( $note_class::E_WC_ADMIN_NOTE_INFORMATIONAL );
+ $note->set_name( self::NOTE_NAME );
+ $note->set_source( 'woocommerce-gateway-stripe' );
+ $note->add_action(
+ self::NOTE_NAME,
+ __( 'Set up now', 'woocommerce-gateway-stripe' ),
+ self::NOTE_DOCUMENTATION_URL,
+ $note_class::E_WC_ADMIN_NOTE_UNACTIONED,
+ true
+ );
+
+ return $note;
+ }
+
+ /**
+ * Get the class type to be used for the note.
+ *
+ * @return string
+ */
+ private static function get_note_class() {
+ if ( class_exists( 'Automattic\WooCommerce\Admin\Notes\Note' ) ) {
+ return Note::class;
+ } else {
+ return WC_Admin_Note::class;
+ }
+ }
+
+ /**
+ * Init Link payment method notification
+ *
+ * @param WC_Stripe_Payment_Gateway $gateway
+ *
+ * @return void
+ * @throws \Automattic\WooCommerce\Admin\Notes\NotesUnavailableException
+ */
+ public static function init( WC_Stripe_Payment_Gateway $gateway ) {
+ if ( ! WC_Stripe_Feature_Flags::is_upe_checkout_enabled() ) {
+ return;
+ }
+
+ // Check if Link payment is available.
+ $available_upe_payment_methods = $gateway->get_upe_available_payment_methods();
+
+ if ( ! in_array( WC_Stripe_UPE_Payment_Method_Link::STRIPE_ID, $available_upe_payment_methods, true ) ) {
+ return;
+ }
+
+ if ( ! is_a( $gateway, 'WC_Stripe_UPE_Payment_Gateway' ) ) {
+ return;
+ }
+
+ // If store currency is not USD, skip
+ if ( 'USD' !== get_woocommerce_currency() ) {
+ return;
+ }
+
+ // Retrieve enabled payment methods at checkout.
+ $enabled_payment_methods = $gateway->get_upe_enabled_at_checkout_payment_method_ids();
+ // If card payment method is not enabled, skip. If Link payment method is enabled, skip.
+ if (
+ ! in_array( WC_Stripe_UPE_Payment_Method_CC::STRIPE_ID, $enabled_payment_methods, true ) ||
+ in_array( WC_Stripe_UPE_Payment_Method_Link::STRIPE_ID, $enabled_payment_methods, true )
+ ) {
+ return;
+ }
+
+ self::possibly_add_note();
+ }
+}
diff --git a/includes/notes/index.html b/includes/notes/index.html
new file mode 100644
index 0000000..017e900
--- /dev/null
+++ b/includes/notes/index.html
@@ -0,0 +1,10 @@
+<html><head><title> - Revision 2844313: /woocommerce-gateway-stripe/trunk/includes/notes</title></head>
+<body>
+ <h2> - Revision 2844313: /woocommerce-gateway-stripe/trunk/includes/notes</h2>
+ <ul>
+ <li><a href="../">..</a></li>
+ <li><a href="class-wc-stripe-upe-availability-note.php">class-wc-stripe-upe-availability-note.php</a></li>
+ <li><a href="class-wc-stripe-upe-stripelink-note.php">class-wc-stripe-upe-stripelink-note.php</a></li>
+ </ul>
+ <hr noshade><em>Powered by <a href="http://subversion.apache.org/">Apache Subversion</a> version 1.9.5 (r1770682).</em>
+</body></html>
\ No newline at end of file