* Added Mercado Pago payment gateway

# Conflicts:
#	client/task-list/tasks/payments/index.js
#	client/task-list/tasks/payments/methods.js

* Added tests

* Added plugin's name to constants

* Added default url

* Modified card copy

* Modified copy

* Added changelog

# Conflicts:
#	readme.txt

* Added testing instructions

# Conflicts:
#	TESTING-INSTRUCTIONS.md

* Added "Local Partner" ribbon

* Using local image

* Fixed typo

* Fixed line duplication

Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
This commit is contained in:
Fernando 2021-03-22 15:57:43 -03:00 committed by GitHub
parent 5c99f54828
commit 93cc81206e
9 changed files with 215 additions and 13 deletions

View File

@ -2,6 +2,27 @@
## Unreleased ## Unreleased
### Payments task: include Mercado Pago #6572
- Create a brand new store.
- Set one of the following countries in the first OBW step:
```
Mexico
Brazil
Argentina
Chile
Colombia
Peru
Uruguay
```
- Continue with the OBW and finish it up.
- Select `Choose payment methods` in the setup task list (`Get ready to start selling`).
- Press the `Setup` button in the `Mercado Pago Payments` box.
- Try the links presented after the plugin's installation and verify they are working.
- Confirm that the `Mercado Pago payments for WooCommerce` plugin was installed.
- Press `Continue`.
- Now the `Mercado Pago Payments` option should appear as active.
### Update contrast and hover / active colors for analytics dropdown buttons #6504 ### Update contrast and hover / active colors for analytics dropdown buttons #6504
1. Go to analytics. 1. Go to analytics.

View File

@ -88,9 +88,15 @@ class Payments extends Component {
getRecommendedMethod() { getRecommendedMethod() {
const { methods } = this.props; const { methods } = this.props;
return methods.find( ( m ) => m.key === 'wcpay' && m.visible ) const recommendedMethod = methods.find(
? 'wcpay' ( m ) =>
: 'stripe'; ( m.key === 'wcpay' && m.visible ) ||
( m.key === 'mercadopago' && m.visible )
);
if ( ! recommendedMethod ) {
return 'stripe';
}
return recommendedMethod.key;
} }
async markConfigured( methodName, queryParams = {} ) { async markConfigured( methodName, queryParams = {} ) {
@ -309,17 +315,16 @@ class Payments extends Component {
isRecommended && key !== 'wcpay'; isRecommended && key !== 'wcpay';
const showRecommendedPill = const showRecommendedPill =
isRecommended && key === 'wcpay'; isRecommended && key === 'wcpay';
const recommendedText =
key === 'mercadopago'
? __( 'Local Partner', 'woocommerce-admin' )
: __( 'Recommended', 'woocommerce-admin' );
return ( return (
<Card key={ key } className={ classes }> <Card key={ key } className={ classes }>
{ showRecommendedRibbon && ( { showRecommendedRibbon && (
<div className="woocommerce-task-payment__recommended-ribbon"> <div className="woocommerce-task-payment__recommended-ribbon">
<span> <span>{ recommendedText }</span>
{ __(
'Recommended',
'woocommerce-admin'
) }
</span>
</div> </div>
) } ) }
<CardMedia isBorderless>{ before }</CardMedia> <CardMedia isBorderless>{ before }</CardMedia>
@ -328,10 +333,7 @@ class Payments extends Component {
{ title } { title }
{ showRecommendedPill && ( { showRecommendedPill && (
<span className="woocommerce-task-payment__recommended-pill"> <span className="woocommerce-task-payment__recommended-pill">
{ __( { recommendedText }
'Recommended',
'woocommerce-admin'
) }
</span> </span>
) } ) }
</H> </H>
@ -414,6 +416,7 @@ export default compose(
'woocommerce_mollie_payments_settings', 'woocommerce_mollie_payments_settings',
'woocommerce_payubiz_settings', 'woocommerce_payubiz_settings',
'woocommerce_paystack_settings', 'woocommerce_paystack_settings',
'woocommerce_mercadopago_settings',
]; ];
const options = optionNames.reduce( ( result, name ) => { const options = optionNames.reduce( ( result, name ) => {

View File

@ -0,0 +1,100 @@
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { ADMIN_URL as adminUrl } from '@woocommerce/wc-admin-settings';
import { Stepper, Link } from '@woocommerce/components';
import { Button } from '@wordpress/components';
import interpolateComponents from 'interpolate-components';
import { useSelect } from '@wordpress/data';
import { SETTINGS_STORE_NAME } from '@woocommerce/data';
/**
* Internal dependencies
*/
import { getCountryCode } from '../../../dashboard/utils';
export const MERCADOPAGO_PLUGIN = 'woocommerce-mercadopago';
export const MercadoPago = ( { installStep, markConfigured } ) => {
const { countryCode } = useSelect( ( select ) => {
const { getSettings } = select( SETTINGS_STORE_NAME );
const { general: generalSettings = {} } = getSettings( 'general' );
return {
countryCode: getCountryCode(
generalSettings.woocommerce_default_country
),
};
} );
return (
<Stepper
isVertical
isPending={ ! installStep.isComplete }
currentStep={ installStep.isComplete ? 'connect' : 'install' }
steps={ [
installStep,
{
key: 'connect',
label: __(
'Connect to your Mercado Pago account',
'woocommerce-admin'
),
content: (
<MercadoPagoCredentialsStep
countryCode={ countryCode }
onFinish={ () => markConfigured( 'mercadopago' ) }
/>
),
},
] }
/>
);
};
const MercadoPagoCredentialsStep = ( { countryCode, onFinish } ) => {
const getRegistrationURL = () => {
const mercadoPagoURL = 'https://www.mercadopago.com';
if (
! [ 'AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY' ].includes(
countryCode
)
) {
return mercadoPagoURL;
}
// As each country has its own domain, we will return the correct one. Otherwise, for example, a Spanish speaker could be redirected to a Mercado Pago page in Portuguese, etc.
return `${ mercadoPagoURL }.${ countryCode.toLowerCase() }/registration-company?confirmation_url=${ mercadoPagoURL }.${ countryCode.toLowerCase() }%2Fcomo-cobrar`;
};
const settingsLink = (
<Link
href={ `${ adminUrl }admin.php?page=wc-settings&tab=checkout` }
target="_blank"
type="external"
/>
);
const accountLink = (
<Link href={ getRegistrationURL() } target="_blank" type="external" />
);
const configureText = interpolateComponents( {
mixedString: __(
'Mercado Pago can be configured under your {{settingsLink}}store settings.{{/settingsLink}} Create your Mercado Pago account {{accountLink}}here.{{/accountLink}}',
'woocommerce-admin'
),
components: {
accountLink,
settingsLink,
},
} );
return (
<>
<p>{ configureText }</p>
<Button isPrimary onClick={ onFinish }>
{ __( 'Continue', 'woocommerce-admin' ) }
</Button>
</>
);
};

View File

@ -29,6 +29,7 @@ import {
isWCPaySupported, isWCPaySupported,
} from './wcpay'; } from './wcpay';
import PayPal, { PAYPAL_PLUGIN } from './paypal'; import PayPal, { PAYPAL_PLUGIN } from './paypal';
import { MercadoPago, MERCADOPAGO_PLUGIN } from './mercadopago';
import Klarna from './klarna'; import Klarna from './klarna';
import EWay from './eway'; import EWay from './eway';
import Razorpay from './razorpay'; import Razorpay from './razorpay';
@ -209,6 +210,35 @@ export function getPaymentMethods( {
}; };
}, },
}, },
{
key: 'mercadopago',
title: __(
'Mercado Pago Checkout Pro & Custom',
'woocommerce-admin'
),
content: (
<>
{ __(
'Accept credit and debit cards, offline (cash or bank transfer) and logged-in payments with money in Mercado Pago. Safe and secure payments with the leading payment processor in LATAM.',
'woocommerce-admin'
) }
</>
),
before: (
<img
src={ wcAdminAssetUrl + 'onboarding/mercadopago.png' }
alt=""
/>
),
visible: [ 'AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY' ].includes(
countryCode
),
plugins: [ MERCADOPAGO_PLUGIN ],
container: <MercadoPago />,
isConfigured: activePlugins.includes( MERCADOPAGO_PLUGIN ),
isEnabled: enabledPaymentGateways.includes( 'mercadopago' ),
optionName: 'woocommerce_mercadopago_settings',
},
{ {
key: 'paypal', key: 'paypal',
title: __( 'PayPal Payments', 'woocommerce-admin' ), title: __( 'PayPal Payments', 'woocommerce-admin' ),

View File

@ -148,6 +148,47 @@ describe( 'TaskList > Payments', () => {
} ).find( ( method ) => method.key === 'mollie' ).isConfigured } ).find( ( method ) => method.key === 'mollie' ).isConfigured
).toBe( true ); ).toBe( true );
} ); } );
describe( 'MercadoPago', () => {
it( 'Is enabled for supported countries', () => {
[ 'AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY' ].forEach(
( countryCode ) => {
params.countryCode = countryCode;
const methods = getPaymentMethods( params );
expect(
methods.some(
( method ) => method.key === 'mercadopago'
)
).toBe( true );
}
);
} );
it( 'Detects whether the plugin is enabled based on the received options', () => {
const mercadoPagoParams = {
...params,
onboardingStatus: {
enabledPaymentGateways: [ 'mercadopago' ],
},
};
const mercadoPagoMethod = getPaymentMethods(
mercadoPagoParams
).find( ( method ) => method.key === 'mercadopago' );
expect( mercadoPagoMethod.isEnabled ).toBe( true );
} );
} );
it( 'If the plugin is active `mercadopago` is marked as `isConfigured`', () => {
expect(
getPaymentMethods( {
...params,
activePlugins: [ 'woocommerce-mercadopago' ],
} ).find( ( method ) => method.key === 'mercadopago' )
.isConfigured
).toBe( true );
} );
} ); } );
describe( 'PayPal', () => { describe( 'PayPal', () => {

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -60,6 +60,10 @@ export const pluginNames = {
'WooCommerce ShipStation Gateway', 'WooCommerce ShipStation Gateway',
'woocommerce-admin' 'woocommerce-admin'
), ),
'woocommerce-mercadopago': __(
'Mercado Pago payments for WooCommerce',
'woocommerce-admin'
),
'kliken-marketing-for-google': __( 'Google Ads', 'woocommerce-admin' ), 'kliken-marketing-for-google': __( 'Google Ads', 'woocommerce-admin' ),
'woo-razorpay': __( 'Razorpay', 'woocommerce-admin' ), 'woo-razorpay': __( 'Razorpay', 'woocommerce-admin' ),
mailpoet: __( 'MailPoet', 'woocommerce-admin' ), mailpoet: __( 'MailPoet', 'woocommerce-admin' ),

View File

@ -135,6 +135,7 @@ Release and roadmap notes are available on the [WooCommerce Developers Blog](htt
- Dev: Add TypeScript and page objects to the E2E test suite. #6582 - Dev: Add TypeScript and page objects to the E2E test suite. #6582
- Dev: Introduce Typescript to Navigation utils #6477 - Dev: Introduce Typescript to Navigation utils #6477
- Add: Paystack payment provider to several african countries. #6579 - Add: Paystack payment provider to several african countries. #6579
- Dev: Payments task: include Mercado Pago #6572
== 2.1.3 3/14/2021 == == 2.1.3 3/14/2021 ==

View File

@ -703,6 +703,7 @@ class Onboarding {
$options[] = 'woocommerce_task_list_tracked_completed_tasks'; $options[] = 'woocommerce_task_list_tracked_completed_tasks';
$options[] = 'woocommerce_task_list_dismissed_tasks'; $options[] = 'woocommerce_task_list_dismissed_tasks';
$options[] = 'woocommerce_allow_tracking'; $options[] = 'woocommerce_allow_tracking';
$options[] = 'woocommerce_mercadopago_settings';
$options[] = 'woocommerce_stripe_settings'; $options[] = 'woocommerce_stripe_settings';
$options[] = 'woocommerce-ppcp-settings'; $options[] = 'woocommerce-ppcp-settings';
$options[] = 'woocommerce_ppcp-gateway_settings'; $options[] = 'woocommerce_ppcp-gateway_settings';
@ -768,6 +769,7 @@ class Onboarding {
'mollie-payments-for-woocommerce' => 'mollie-payments-for-woocommerce/mollie-payments-for-woocommerce.php', 'mollie-payments-for-woocommerce' => 'mollie-payments-for-woocommerce/mollie-payments-for-woocommerce.php',
'payu-india' => 'payu-india/index.php', 'payu-india' => 'payu-india/index.php',
'mailpoet' => 'mailpoet/mailpoet.php', 'mailpoet' => 'mailpoet/mailpoet.php',
'woocommerce-mercadopago' => 'woocommerce-mercadopago/woocommerce-mercadopago.php',
) )
); );
return array_merge( $plugins, $onboarding_plugins ); return array_merge( $plugins, $onboarding_plugins );