Payment Screen

Tags: v7

Buttons can be added to the payment screen that can perform operations using the current order object and also change their state.

How does it look in SyrveFront?

For example, here is how the button “SamplePlugin: Show OK popup” looks, added by the SamplePlugin from the SDK.

ButtonOnPaymentScreenView

Suppose the plugin shows a window with a message (see the article API Dialogs).

ButtonOnPaymentScreenView_Click

The plugin can add several buttons to the payment screen at once.

For example, using the SamplePlugin SDK, 2 buttons were added: “SamplePlugin: Show OK popup” and “SamplePlugin: Show input dialog”.

ButtonsOnPaymentScreenView

There may be a situation where there is not enough space for the buttons. In this case, instead of the buttons that did not fit, the button “ADDITIONAL” will appear.

AdditionalButtonOnPaymentScreen

If there is only one button, the button “ADDITIONAL” will not appear in any case.

Different plugins can add their own buttons.

When the button “ADDITIONAL” is pressed, a list of all the buttons that did not fit will be displayed.

ButtonsOnPaymentScreenViewPopup

How to add your own extensions?

Step 1: Register a handler for the payment screen:
// Registering an action on the payment screen
subscription = PluginContext.Operations.AddButtonToPaymentScreen("SamplePlugin: Show ok popup", false, true, ShowOkPopupOnPaymentScreen);

The function for registering an operation on the payment screen AddButtonToPaymentScreen() takes 5 arguments:

The button press function takes the order object IOrder, an instance of IViewManager for showing windows, as well as the current state of the button - (Guid buttonId, string caption, bool isChecked, string iconGeometry) state.

Step 2. Describe the handler for the added button:
private void ShowOkPopupOnPaymentScreen((IOrder order, IOperationService os, IViewManager vm, (Guid buttonId, string caption, bool isChecked, string iconGeometry) state) info)
{
    info.vm.ShowOkPopup("Test Window", "Message displayed using SamplePlugin.");
}

Examples of implementations can be found in the SDK SamplePlugin project in the ButtonsTester class.

How to update the button state?

You can update the state of a previously added button at any time using the function UpdatePaymentScreenButtonState(), which takes 5 arguments:

To track changes on the payment screen, you can subscribe to the event PaymentScreenUpdated. The event is triggered when a payment type is added, changed, or removed, when the payment amount is changed, as well as when an EInvoice is added or removed. This event has 2 arguments: