diff --git a/assets/css/admin.css b/assets/css/admin.css
index 9fbffb21907..baf66dcee88 100644
--- a/assets/css/admin.css
+++ b/assets/css/admin.css
@@ -67,6 +67,10 @@
background-image: url( '../images/cards/visa.svg' );
}
+.payment-method__brand--cartes_bancaires {
+ background-image: url( '../images/cards/cartes_bancaires.svg' );
+}
+
.payment-method__brand--unknown {
background-image: url( '../images/cards/unknown.svg' );
}
diff --git a/assets/css/admin.rtl.css b/assets/css/admin.rtl.css
index ea319683a6a..d43de4d4b7f 100644
--- a/assets/css/admin.rtl.css
+++ b/assets/css/admin.rtl.css
@@ -67,6 +67,10 @@
background-image: url( '../images/cards/visa.svg' );
}
+.payment-method__brand--cartes_bancaires {
+ background-image: url( '../images/cards/cartes_bancaires.svg' );
+}
+
.payment-method__brand--unknown {
background-image: url( '../images/cards/unknown.svg' );
}
diff --git a/assets/images/cards/cartes_bancaires.svg b/assets/images/cards/cartes_bancaires.svg
new file mode 100644
index 00000000000..94f51339e65
--- /dev/null
+++ b/assets/images/cards/cartes_bancaires.svg
@@ -0,0 +1,4 @@
+
diff --git a/changelog/cobranded-cards b/changelog/cobranded-cards
new file mode 100644
index 00000000000..7788a04abff
--- /dev/null
+++ b/changelog/cobranded-cards
@@ -0,0 +1,4 @@
+Significance: minor
+Type: add
+
+Added support to Cartes Bancaires
diff --git a/client/components/payment-method-details/index.js b/client/components/payment-method-details/index.js
index d47e3cd3086..a1f447d4672 100755
--- a/client/components/payment-method-details/index.js
+++ b/client/components/payment-method-details/index.js
@@ -59,10 +59,14 @@ const PaymentMethodDetails = ( props ) => {
return –;
}
- const brand =
- paymentMethod && paymentMethod.brand
- ? paymentMethod.brand
- : payment.type;
+ let brand = payment.type;
+ if ( paymentMethod && paymentMethod.brand ) {
+ brand = paymentMethod.brand;
+ }
+ if ( paymentMethod && paymentMethod.network ) {
+ brand = paymentMethod.network;
+ }
+
const details = formatDetails( payment );
return (
diff --git a/client/payment-methods/constants.ts b/client/payment-methods/constants.ts
index ac661f2a079..4ca2b2d7dc4 100644
--- a/client/payment-methods/constants.ts
+++ b/client/payment-methods/constants.ts
@@ -38,6 +38,7 @@ export const PAYMENT_METHOD_TITLES = {
bancontact: __( 'Bancontact', 'woocommerce-payments' ),
card: __( 'Card Payment', 'woocommerce-payments' ),
card_present: __( 'In-Person Card Payment', 'woocommerce-payments' ),
+ cartes_bancaires: __( 'Cartes Bancaires', 'woocommerce-payments' ),
diners: __( 'Diners Club', 'woocommerce-payments' ),
discover: __( 'Discover', 'woocommerce-payments' ),
eps: __( 'EPS', 'woocommerce-payments' ),
diff --git a/includes/class-wc-payments-token-service.php b/includes/class-wc-payments-token-service.php
index a2ae107f9bb..37fa25ced0e 100644
--- a/includes/class-wc-payments-token-service.php
+++ b/includes/class-wc-payments-token-service.php
@@ -86,7 +86,7 @@ public function add_token_to_user( $payment_method, $user ) {
$token->set_gateway_id( CC_Payment_Gateway::GATEWAY_ID );
$token->set_expiry_month( $payment_method[ Payment_Method::CARD ]['exp_month'] );
$token->set_expiry_year( $payment_method[ Payment_Method::CARD ]['exp_year'] );
- $token->set_card_type( strtolower( $payment_method[ Payment_Method::CARD ]['brand'] ) );
+ $token->set_card_type( strtolower( $payment_method[ Payment_Method::CARD ]['display_brand'] ?? $payment_method[ Payment_Method::CARD ]['networks']['preferred'] ?? $payment_method[ Payment_Method::CARD ]['brand'] ) );
$token->set_last4( $payment_method[ Payment_Method::CARD ]['last4'] );
}
diff --git a/includes/payment-methods/class-cc-payment-method.php b/includes/payment-methods/class-cc-payment-method.php
index afa8b5991e9..dc85cf662af 100644
--- a/includes/payment-methods/class-cc-payment-method.php
+++ b/includes/payment-methods/class-cc-payment-method.php
@@ -50,12 +50,14 @@ public function get_title( string $account_country = null, $payment_details = fa
'unknown' => __( 'unknown', 'woocommerce-payments' ),
];
- $card_network = $details['network'] ?? $details['networks']['available'][0];
+ $card_network = $details['display_brand'] ?? $details['network'] ?? $details['networks']['preferred'] ?? $details['networks']['available'][0];
+ // Networks like `cartes_bancaires` may use underscores, so we replace them with spaces.
+ $card_network = str_replace( '_', ' ', $card_network );
$payment_method_title = sprintf(
// Translators: %1$s card brand, %2$s card funding (prepaid, credit, etc.).
__( '%1$s %2$s card', 'woocommerce-payments' ),
- ucfirst( $card_network ),
+ ucwords( $card_network ),
$funding_types[ $details['funding'] ]
);
diff --git a/tests/unit/test-class-wc-payments-token-service.php b/tests/unit/test-class-wc-payments-token-service.php
index e7fce174370..f9465769f89 100644
--- a/tests/unit/test-class-wc-payments-token-service.php
+++ b/tests/unit/test-class-wc-payments-token-service.php
@@ -100,6 +100,56 @@ public function test_add_token_to_user() {
$this->assertEquals( $expiry_year, $token->get_expiry_year() );
}
+ public function test_add_cobranded_token_to_user_with_preferred_network() {
+ $expiry_year = intval( gmdate( 'Y' ) ) + 1;
+ $mock_payment_method = [
+ 'id' => 'pm_mock',
+ 'card' => [
+ 'brand' => 'visa',
+ 'networks' => [ 'preferred' => 'cartes_bancaires' ],
+ 'last4' => '4242',
+ 'exp_month' => 6,
+ 'exp_year' => $expiry_year,
+ ],
+ 'type' => Payment_Method::CARD,
+ ];
+
+ $token = $this->token_service->add_token_to_user( $mock_payment_method, wp_get_current_user() );
+
+ $this->assertEquals( 'woocommerce_payments', $token->get_gateway_id() );
+ $this->assertEquals( 1, $token->get_user_id() );
+ $this->assertEquals( 'pm_mock', $token->get_token() );
+ $this->assertEquals( 'cartes_bancaires', $token->get_card_type() );
+ $this->assertEquals( '4242', $token->get_last4() );
+ $this->assertEquals( '06', $token->get_expiry_month() );
+ $this->assertEquals( $expiry_year, $token->get_expiry_year() );
+ }
+
+ public function test_add_cobranded_token_to_user_with_display_brand() {
+ $expiry_year = intval( gmdate( 'Y' ) ) + 1;
+ $mock_payment_method = [
+ 'id' => 'pm_mock',
+ 'card' => [
+ 'brand' => 'visa',
+ 'display_brand' => 'cartes_bancaires',
+ 'last4' => '4242',
+ 'exp_month' => 6,
+ 'exp_year' => $expiry_year,
+ ],
+ 'type' => Payment_Method::CARD,
+ ];
+
+ $token = $this->token_service->add_token_to_user( $mock_payment_method, wp_get_current_user() );
+
+ $this->assertEquals( 'woocommerce_payments', $token->get_gateway_id() );
+ $this->assertEquals( 1, $token->get_user_id() );
+ $this->assertEquals( 'pm_mock', $token->get_token() );
+ $this->assertEquals( 'cartes_bancaires', $token->get_card_type() );
+ $this->assertEquals( '4242', $token->get_last4() );
+ $this->assertEquals( '06', $token->get_expiry_month() );
+ $this->assertEquals( $expiry_year, $token->get_expiry_year() );
+ }
+
/**
* Test add SEPA token to user.
*/
@@ -261,6 +311,68 @@ public function test_add_payment_method_to_user() {
$this->assertEquals( $expiry_year, $token->get_expiry_year() );
}
+ public function test_add_cobranded_payment_method_to_user_with_preferred_network() {
+ $expiry_year = intval( gmdate( 'Y' ) ) + 1;
+ $mock_payment_method = [
+ 'id' => 'pm_mock',
+ 'card' => [
+ 'brand' => 'visa',
+ 'networks' => [ 'preferred' => 'cartes_bancaires' ],
+ 'last4' => '4242',
+ 'exp_month' => 6,
+ 'exp_year' => $expiry_year,
+ ],
+ 'type' => Payment_Method::CARD,
+ ];
+
+ $this->mock_api_client
+ ->expects( $this->once() )
+ ->method( 'get_payment_method' )
+ ->with( 'pm_mock' )
+ ->willReturn( $mock_payment_method );
+
+ $token = $this->token_service->add_payment_method_to_user( $mock_payment_method['id'], wp_get_current_user() );
+
+ $this->assertEquals( 'woocommerce_payments', $token->get_gateway_id() );
+ $this->assertEquals( 1, $token->get_user_id() );
+ $this->assertEquals( 'pm_mock', $token->get_token() );
+ $this->assertEquals( 'cartes_bancaires', $token->get_card_type() );
+ $this->assertEquals( '4242', $token->get_last4() );
+ $this->assertEquals( '06', $token->get_expiry_month() );
+ $this->assertEquals( $expiry_year, $token->get_expiry_year() );
+ }
+
+ public function test_add_cobranded_payment_method_to_user_with_display_brand() {
+ $expiry_year = intval( gmdate( 'Y' ) ) + 1;
+ $mock_payment_method = [
+ 'id' => 'pm_mock',
+ 'card' => [
+ 'brand' => 'visa',
+ 'display_brand' => 'cartes_bancaires',
+ 'last4' => '4242',
+ 'exp_month' => 6,
+ 'exp_year' => $expiry_year,
+ ],
+ 'type' => Payment_Method::CARD,
+ ];
+
+ $this->mock_api_client
+ ->expects( $this->once() )
+ ->method( 'get_payment_method' )
+ ->with( 'pm_mock' )
+ ->willReturn( $mock_payment_method );
+
+ $token = $this->token_service->add_payment_method_to_user( $mock_payment_method['id'], wp_get_current_user() );
+
+ $this->assertEquals( 'woocommerce_payments', $token->get_gateway_id() );
+ $this->assertEquals( 1, $token->get_user_id() );
+ $this->assertEquals( 'pm_mock', $token->get_token() );
+ $this->assertEquals( 'cartes_bancaires', $token->get_card_type() );
+ $this->assertEquals( '4242', $token->get_last4() );
+ $this->assertEquals( '06', $token->get_expiry_month() );
+ $this->assertEquals( $expiry_year, $token->get_expiry_year() );
+ }
+
public function test_woocommerce_payment_token_deleted() {
$this->mock_api_client
->expects( $this->once() )