Add payment gateway return URL and action (https://github.com/woocommerce/woocommerce-admin/pull/7095)
* Add return URL argument to connection URL method * Remove 'oauth' from connection URL method * Add changelog entry
This commit is contained in:
parent
abe7d9d39f
commit
e86667de02
|
@ -21,7 +21,7 @@ export const PaymentConnect = ( {
|
|||
} ) => {
|
||||
const {
|
||||
id,
|
||||
oauth_connection_url: oAuthConnectionUrl,
|
||||
connection_url: connectionUrl,
|
||||
setup_help_text: setupHelpText,
|
||||
required_settings_keys: settingKeys,
|
||||
settings,
|
||||
|
@ -126,11 +126,11 @@ export const PaymentConnect = ( {
|
|||
);
|
||||
}
|
||||
|
||||
if ( oAuthConnectionUrl ) {
|
||||
if ( connectionUrl ) {
|
||||
return (
|
||||
<>
|
||||
{ helpText }
|
||||
<Button isPrimary href={ oAuthConnectionUrl }>
|
||||
<Button isPrimary href={ connectionUrl }>
|
||||
{ __( 'Connect', 'woocommerce-admin' ) }
|
||||
</Button>
|
||||
</>
|
||||
|
|
|
@ -48,7 +48,7 @@ Name | Return | Default | Description
|
|||
--- | --- | --- | ---
|
||||
`needs_setup()` | boolean | `false` | Used to determine if the gateway still requires setup in order to be used.
|
||||
`get_required_settings_keys()` | array | `[]` | An array of keys for fields required to properly configure the gateway. The keys must match those of already registered form fields in the payment gateway.
|
||||
`get_oauth_connection_url()` | string | `null` | The oAuth connection URL to be used to quickly connect a payment gateway provider. If provided, this will be used in place of required setting fields.
|
||||
`get_connection_url()` | string | `null` | The connection URL to be used to quickly connect a payment gateway provider. If provided, this will be used in place of required setting fields.
|
||||
`get_post_install_script_handles()` | array | `[]` | An array of script handles previously registered with `wp_register_script` to enqueue after the payment gateway has been installed. This is primarily used to `SlotFill` the payment connection step, but can allow any script to be added to assist in payment gateway setup.
|
||||
`get_setup_help_text()` | string | `null` | Help text to be shown above the connection step's submit button.
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ Release and roadmap notes are available on the [WooCommerce Developers Blog](htt
|
|||
- Add: Add COD method to default payment gateway recommendations #7057
|
||||
- Add: Add BACS as default fallback payment gateway #7073
|
||||
- Add: A/B test of progressive checklist features. #7089
|
||||
- Add: Add payment gateway return URL and action #7095
|
||||
- Dev: Update package-lock to fix versioning of local packages. #6843
|
||||
- Dev: Use rule processing for remote payment methods #6830
|
||||
- Dev: Update E2E jest config, so it correctly creates screenshots on failure. #6858
|
||||
|
|
|
@ -17,6 +17,7 @@ class PaymentGatewaysController {
|
|||
*/
|
||||
public static function init() {
|
||||
add_filter( 'woocommerce_rest_prepare_payment_gateway', array( __CLASS__, 'extend_response' ), 10, 3 );
|
||||
add_filter( 'admin_init', array( __CLASS__, 'possibly_do_connection_return_action' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,8 +35,9 @@ class PaymentGatewaysController {
|
|||
$data['post_install_scripts'] = self::get_post_install_scripts( $gateway );
|
||||
$data['settings_url'] = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . strtolower( $gateway->id ) );
|
||||
|
||||
if ( method_exists( $gateway, 'get_oauth_connection_url' ) ) {
|
||||
$data['oauth_connection_url'] = $gateway->get_oauth_connection_url();
|
||||
if ( method_exists( $gateway, 'get_connection_url' ) ) {
|
||||
$return_url = wc_admin_url( '&task=payments&connection-return=' . strtolower( $gateway->id ) );
|
||||
$data['connection_url'] = $gateway->get_connection_url( $return_url );
|
||||
}
|
||||
|
||||
if ( method_exists( $gateway, 'get_setup_help_text' ) ) {
|
||||
|
@ -73,4 +75,26 @@ class PaymentGatewaysController {
|
|||
|
||||
return $scripts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call an action after a gating has been successfully returned.
|
||||
*/
|
||||
public static function possibly_do_connection_return_action() {
|
||||
// phpcs:disable WordPress.Security.NonceVerification
|
||||
if (
|
||||
! isset( $_GET['page'] ) ||
|
||||
'wc-admin' !== $_GET['page'] ||
|
||||
! isset( $_GET['task'] ) ||
|
||||
'payments' !== $_GET['task'] ||
|
||||
! isset( $_GET['connection-return'] )
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$gateway_id = sanitize_text_field( wp_unslash( $_GET['connection-return'] ) );
|
||||
|
||||
// phpcs:enable WordPress.Security.NonceVerification
|
||||
|
||||
do_action( 'woocommerce_admin_payment_gateway_connection_return', $gateway_id );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue