Get started
Customization
Troubleshooting
- Embedded checkouts in WooCommerce
- Checkout blocks in WooCommerce
- Error codes
- Compatible plugins
- Known compatibility issues
- Shipping Methods in iframe
- FAQ
- Optimizing your checkout when using an Iframe-based checkout
- Callbacks
- Troubleshooting the checkout flow
- Troubleshooting the Pay for order/Hosted Payment Page flow
- Troubleshooting WooCommerce Subscriptions and KCO
- Klarna Developer logs
- Pending payment orders and held stock
Klarna support information
Additional Klarna plugins
External payment method (EPM)
External payment methods can be configured for use with the Woo KCO plugin. External payment methods and checkouts allow merchants to offer payment methods not available today as an inline experience with Klarna Checkout.
Note: the use of EPM’s is also dependent upon the merchant’s Klarna contract.
Important:
External Payment Methods needs to be activated by Klarna in the merchants account before trying the example code.
This code may be used in a production store, but this code is not supported by Klarna or Krokedil.
- EPM explained in Klarna’s developer docs
https://docs.klarna.com/klarna-checkout/in-depth-knowledge/external-payment-methods/
Example code BACS
/**
* Extend the Klarna Checkout plugin settings.
*/
add_filter( 'kco_wc_gateway_settings', 'kcoepm_form_fields' );
function kcoepm_form_fields( $settings ) {
$settings['epm_bacs_settings_title'] = array(
'title' => __( 'External Payment Method - Direct Bank Transfer', 'kco-epm-wc' ),
'type' => 'title',
);
$settings['epm_bacs_name'] = array(
'title' => __( 'Payment method name*', 'kco-epm-wc' ),
'type' => 'text',
// https://docs.klarna.com/klarna-checkout/in-depth-knowledge/external-payment-methods/#external-payment-methods-in-klarna-checkout-supported-external-payment-methods-in-kco
'description' => __( 'The name of the payment method exactly as it appears in the Klarna documentation. <b>This field is mandatory</b>.', 'kco-epm-wc' ),
'default' => __( 'Bank Transfer', 'kco-epm-wc' ),
);
$settings['epm_bacs_id'] = array(
'title' => __( 'Payment method ID*', 'kco-epm-wc' ),
'type' => 'text',
'description' => __( 'The ID of the relevant WooCommerce payment method. For example, for "Direct bank transfer", the ID is "bacs". <b>This field is mandatory</b>.', 'kco-epm-wc' ),
'default' => __( 'bacs', 'kco-epm-wc' ),
);
$settings['epm_bacs_description'] = array(
'title' => __( 'Description', 'kco-epm-wc' ),
'type' => 'textarea',
'description' => __( 'Add a description under the payment method. If omitted, Klarna will use a default description.', 'kco-epm-wc' ),
'default' => '',
);
$settings['epm_bacs_img_url'] = array(
'title' => __( 'Image URL', 'kco-epm-wc' ),
'type' => 'text',
'description' => __( 'A URL to the payment icon (optional).', 'kco-epm-wc' ),
'default' => '',
);
$settings['epm_bacs_disable_button'] = array(
'title' => __( 'Disable other gateway button', 'kco-epm-wc' ),
'type' => 'checkbox',
'description' => __( 'Whether the "Select another Payment method" button on the Klarna Checkout should be disabled.', 'kco-epm-wc' ),
'default' => 'no',
);
return $settings;
}
/**
* Add Direct Transfer as payment method to the KCO iframe.
*/
add_filter( 'kco_wc_api_request_args', 'kcoepm_create_order_bacs' );
function kcoepm_create_order_bacs( $request_args ) {
$kco_settings = get_option( 'woocommerce_kco_settings' );
$name = $kco_settings['epm_bacs_name'] ?? '';
$id = $kco_settings['epm_bacs_id'] ?? '';
$image_url = $kco_settings['epm_bacs_img_url'] ?? '';
$description = $kco_settings['epm_bacs_description'] ?? '';
$klarna_external_payment = array(
// The name is MANDATORY and must match exactly one of the payment method names as they appear in the Klarna documentation:
// https://docs.klarna.com/klarna-checkout/in-depth-knowledge/external-payment-methods/#external-payment-methods-in-klarna-checkout-supported-external-payment-methods-in-kco.
'name' => $name,
'image_url' => $image_url,
'description' => $description,
'redirect_url' => add_query_arg(
array(
'kco-external-payment' => $id,
'order_id' => isset( $request_args['merchant_reference2'] ) ? $request_args['merchant_reference2'] : '{checkout.order.id}',
),
wc_get_checkout_url()
),
);
$klarna_external_payment = array( $klarna_external_payment );
$request_args['external_payment_methods'] = $klarna_external_payment;
return $request_args;
}
add_action( 'init', 'kcoepm_remove_other_gateway_button' );
function kcoepm_remove_other_gateway_button() {
$kco_settings = get_option( 'woocommerce_kco_settings' );
$disable_button = isset( $kco_settings['epm_bacs_disable_button'] ) ? $kco_settings['epm_bacs_disable_button'] : 'no';
if ( 'yes' === $disable_button ) {
remove_action( 'kco_wc_after_order_review', 'kco_wc_show_another_gateway_button', 20 );
}
}
FAQ
Is it possible to add multiple External Payment Methods to Klarna?
Yes, it is possible to add multiple External Payment Methods to Klarna (provided that you have an agreement with Klarna for this).
Each defined external payment method sent in the request to Klarna should be added as an array as described in the documentation here: https://docs.klarna.com/api/checkout/#operation/createOrderMerchant!path=external_payment_methods&t=request.