Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Implementing deprecated filters

If you for some strange reason would like to implement filters that has been used in the old plugin, implementation should look like this. In this live example, you actually execute the deprecated filter before executing the up-to-date one. Doing this, you get the chance to inject old values on the way through the new filter.

Code Block
themeEmacs
$deprecatedStoreId = WordPress::applyFiltersDeprecated('set_storeid', null);
$storeId = (int)WordPress::applyFilters('setStoreId', $deprecatedStoreId);

Implemented and available filters

This plugin offers a bunch of internal filters and actions. Below is a list of them.

_can_process_order

Specially designed responses that occurs during process_payment. In short, the event that happens here are after a successful payment. Currently the plugin uses this part itself to approve and redirect to success when RCO is in use. See example below:

public function canProcessOrderResponse($return, $order) { $returnUrl = WC_Payment_Gateway::get_returnurl($order); if (Data::getCheckoutType() === ResursDefault::TYPE_RCO) { // Updating the required response without cleaning the rest. $return['result'] = 'success'; $return['redirect'] = $returnUrl; } return $return; } rbwc_Currently not fully implemented
Filter nameTypeInReturnDescription
rbwc_admin_dynamic_contentfilter$content
$current_section
$yourContentRenders dynamic content for each section. If something specific, that is not included in the form fields, this could be used and will be appended in the bottom of each section.
rbwc_get_dependentcustom_form_settingsfieldsfilter$currentArray$yourArrayIf settings are dependent of other activated options in the configuration, this filter should be used. The plugin use this internally, to enable/disable the developer-options tab.
rbwc_get_plugin_informationfilter$content$yourContent

Content added to this section will be shown in the information/support, as a part of the "version view". If you for example need to show openssl releases or other vital data for your platform, you should add it here.

Example:

Code Block
languagejs
[
   'OpenSSL version' => defined('OPENSSL_VERSION_TEXT') ? OPENSSL_VERSION_TEXT : ''
]


rbwc_can_display_order_info_after_detailsfilterbooleanboolean

rbwc_can_display_order_info_after_<WHERE>

The can_display-trio is used to disable each payment info section in the admin view. The details section also has a separate action that triggers instead of the standard action from woocommerce. That action delivers all payment information required to recreate the "bluebox information" from v2.x.

rbwc_show_order_detailsaction$orderDataIs echoThis action is executed right after the rbwc_can_display_order_info_after_details-filter. By disabling the three can_display_order_info and execute this hook with a full order representation, it is possible to create your own view right after the order details in the admin. This is pushed in here, in case the future requires a different view from this plugin.
rbwc_can_display_order_info_after_billingfilterbooleanboolean

rbwc_can_display_order_info_after_<WHERE>

The can_display-trio is used to disable each payment info section in the admin view.

rbwc_can_display_order_info_after_shippingfilterbooleanboolean

rbwc_can_display_order_info_after_<WHERE>

The can_display-trio is used to disable each payment info section in the admin view.

rbwc_get_payment_field_sizefilter$size, $fieldNameintegerIf you believe you need a shorter or longer value for the default payment field lenght, that is set to 24, you can apply for that value here.
rbwcactionWC_OrderIs actionThis is not a filter that returns a true or false value - if developers or other plugins for example needs to stop something before process_order initialized a payment for Resurs Bank, this is a place to push out an exception. Any exception thrown here will reflect back to the checkout and show that exception as a custom error message.rbwc_can_process_order_responsefilterarrayarray
Code Block
languagephp
themeEmacs
_prefer_article_number_skufilterbooleanbooleanIf you have further requirements of how article numbers are fetched, you could return true for this, to make the plugin use Sku instead - if it exists.
This is not configurable through the admin interface as it is handled as a filter instead. If it is really necessary to use SKU, use this filter.
rbwc_get_article_numberfilter

$currentArticleNumber, WC_Product

$theArticleNumberIf you have further ways of fetching an article from a WC_Product object, this is where you do it.
rbwc_coupons_ex_taxfilterboolean, WC_CouponbooleanFor special occasions when the options should remain untouched but we still need to make exceptions for coupons.
rbwc_get_coupon_vat_pctfilterintegerintegerDefault value for vat percent in the coupon calculcation method is 0. Coupons are normally, at least in Sweden, already applied with vat.
rbwc_get_address_disabledfilterbooleanbooleanDisable getAddress form in checkout (where it is implementable).
rbwc_js_loaders_checkoutfilterarrayarrayList of javascripts (frameworks?) that should be loaded during RCO.
rbwc_get_shipping_namefilterstringstringGenerates own article number for shipping if the default "shipping" is not preferred, or if another translation is needed.
rbwc_get_shipping_descriptionfilterstringstringGenerates a orderline description for the shipping, if the preferred translation for "Shipping" is not preferred.
rbwc_set_store_idfilterstringstringSet a store id for the payment request.
rbwc_trigger_callbackfilterarrayarrayExternal code to handle test callbacks.
rbwc_get_address_field_controllerfilterarrayarraygetTransformedAddressResponse, ability to use other fields than the defaults, generated by the internal filter.
rbwc_get_address_button_textfilterstringstringAlternative naming or translation for the getAddress request button. Default is "Get address".
resurs_trigger_test_callbackfilterstringstring

External trigger for the test callback.

Status
colourRed
title2.x-deprecated

set_storeidfilterstringstring

Store id, old filter.

Status
colourRed
title2.x-deprecated

resurs_getaddress_enabledfilterbooleanboolean

Sets, in the old fashioned way, a state if getAddress should be enabled where it is normally disabled.

Status
colourRed
title2.x-deprecated

rbwc_customer_synchronizetrigger
$('body').trigger(
'rbwc_customer_synchronize', {
version: 2
}
)
-

Javascript frontend trigger. Used to synchronize customer billing/shipping fields. Event contains. depending on version.

Code Block
languagejs
themeEmacs
titleWhen v1 is sending data
collapsetrue
{
  version: 1
}

resursBankRcoDataContainer Version 1 sample data:

Code Block
languagejs
themeEmacs
{
	"rco_customer": {
		"paymentMethod": "INVOICE",
		"customerData": {
			"address": {
				"firstname": "Korv",
				"surname": "Alexandersson",
				"address": "Glassgatan 15",
				"addressExtra": "",
				"postal": "41655",
				"city": "Göteborg",
				"countryCode": "SE",
				"telephone": "0701122334",
				"email": "noreply@resurs.se"
			},
			"delivery": {},
			"ssn": "198001010001",
			"paymentMethod": "INVOICE"
		}
	},
	"rco_payment": "INVOICE"
}


Code Block
languagejs
themeEmacs
titleWhen v2 is sending data
collapsetrue
{
  version: 1
}

resursBankRcoDataContainer Version 2 sample data (when deliveryAddress has constent it looks similarly as billingAddress):

Code Block
languagejs
themeEmacs
titleresursBankRcoDataContainer Version 2
{
	"rco_customer": {
		"type": "CustomerChangeEvent",
		"ts": 1632576948828,
		"source": "@rco-app",
		"phone": "0701122334",
		"email": "noreply@resurs.se",
		"billingAddress": {
			"firstName": "Vincent",
			"lastName": "Alexandersson",
			"addressRow1": "Glassgatan 15",
			"addressRow2": null,
			"postalCode": "41655",
			"city": "Göteborg"
		},
		"deliveryAddress": {
			"firstName": null,
			"lastName": null,
			"addressRow1": null,
			"addressRow2": null,
			"postalCode": null,
			"city": null
		}
	},
	"rco_payment": {
		"type": "PSP_DEBIT_CARD",
		"ts": 1632576948828,
		"source": "@rco-app",
		"method": "PSPCARD_DEBIT",
		"id": "PSPCARD_DEBIT",
		"fee": 0
	}
}


rbwc_purchase_rejecttrigger
$('body').trigger(
'rbwc_purchase_reject', {
type: '<type>'
}
);
-Then ResursCheckout framework v1 or v2 rejects a payment, either because of a failure or a denied payment (v1 only), this trigger executes and can be picked up by integrated plugins to handle a rejected order.
rbwc_purchase_reject_customer_messagefilterstringstring

When Resurs Bank Checkout rejects a payment due to failure/deny, this filter adds an extra note to customer in a front-end message. The default looks like below:

Code Block
languagephp
themeEmacs
$failNote = sprintf(
    __('Order was rejected by Resurs Bank with status %s.', 'trbwc'),
    $rejectType
);

The above message is always injected in order notices and in the default customer message. After this message has been added to the order, further text are added:

Code Block
languagephp
themeEmacs
$failNote .= ' ' . WordPress::applyFilters(
    'purchaseRejectCustomerMessage',
    __('Please contact customer service for more information.', 'trbwc')
);

The above "Contact customer service"-message is added with a filter setup (which is this). If you want to change this message, you can use the mentioned filter to update the string with your own.

rbwc_get_payment_method_iconfilter$url, $paymentMethodDatastring

When logos are active for payment methods, you can customize the look of the icon by adding this filter. The output string should be a URL to your custom logo. For each payment method. $paymentMethodData contains details about type, specificType and id that is vital for method type detection.

This also deprecates

Jira
serverTornevall Networks
columnIdsissuekey,summary,issuetype,created,updated,duedate,assignee,reporter,priority,status,resolution
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverIdef1f2374-e58a-319f-9d38-10348dbac859
keyRWC-33
.

rbwc_get_specific_type_fieldsfilter$return (array), $keyarrayCustomizable customer form fields for checkouts. See this section.
rbwc_get_minimum_annuity_pricefilter$integer, $customerCountryintegerWhen annuity factors are handled, the minimum payment price is 150 SEK/DKK/NOK or 15 EUR for FI. If you really need to change this value to something lower, this is the filter to use.
rbwc_part_payment_stringfilterstring, [
'monthlyPrice' => $monthlyPrice,
'monthlyDuration' => $annuityDuration,
'paymentLimit' => $minimumPaymentLimit
]
string

When displaying part payment information on product pages, the below string is set to be default. This filter executes an internal feature that makes it possible to show part payment information via a WordPress page. It also helps if you want to generate your own information without a page. The second variable in this filter is the the default values for duration and months.

Part pay from %s per month.

rbwc_method_min_limitfilterint, $paymentMethodInformationint

If you want to limit the minimum allowed payment amount for a specific payment method, this is the one to set the data with.

For example, you require payment amounts to be higher than 1000, to turn on the INVOICE, but the payment method allows payments from 500.

The minAmount of the payment method can never be exceeded.

rbwc_method_max_limitfilterint, $paymentMethodInformationint

If you want to limit the maximum allowed payment amount for a specific payment method, this is the one to set the data with.

For example, you require SWISH to not be higher than 10000 but the payment method allows payments up to 20000.

The maxAmount of the payment method can never be exceeded.