m8ty_client_pis
Package overview
Section titled “Package overview”m8ty_client_pis solves this with typed APIs for payment creation, validation, authorization, beneficiaries, QR bills, instant-payment notifications, and settings, supporting clearer and safer payment journeys.
Payment information services cover all the aspects of payments, beneficiaries, QR bills, instant payments, and payment settings.
Before you start
Section titled “Before you start”Check the documentation of the m8ty_client_pis library to get an idea about the available models and their properties.
Import all needed libraries
Section titled “Import all needed libraries”import 'package:dio/dio.dart';import 'package:m8ty_client_pis/m8ty_client_pis.dart';import 'package:m8ty_client_common/m8ty_client_common.dart';import 'package:built_collection/built_collection.dart';Client Setup
Section titled “Client Setup”final client = M8tyClientPis();client.setOAuthToken('ApiOAuth2', oauthToken);- Default base URL is
https://api.m8ty.eu/api/v1; override withbasePathOverrideonly for non-prod environments. - Catch
DioExceptionand handle status code plus response body frome.response.
API Surface
Section titled “API Surface”PaymentsApi
Section titled “PaymentsApi”| Method | Description |
|---|---|
createPayment |
Initiate a payment |
editByPaymentId |
Edit existing payment |
getByPaymentId |
Get details of a payment |
fetchAllPayments |
Get all payments |
cancelByPaymentId |
Cancellation of a payment |
approveByPaymentId |
Approve payment for the given id |
statusByPaymentId |
Get status of a payment |
validatePayment |
Validates if a payment can be created |
createPaymentAuthorization |
Initiate authorization request |
confirmPaymentAuthorization |
Confirm the authorization of payment |
BeneficiaryApi
Section titled “BeneficiaryApi”| Method | Description |
|---|---|
beneficiaryAutocompletion |
Search for beneficiaries |
InstantPaymentsApi
Section titled “InstantPaymentsApi”| Method | Description |
|---|---|
getStatus |
Get status of instant payment |
getAllInstantPaymentNotifications |
Retrieve instant payment notifications |
markNotificationsAsRead |
Mark instant payment notifications as read |
QrBillApi
Section titled “QrBillApi”| Method | Description |
|---|---|
generateQrBill |
Generate QR bill payment for account |
scanQrBill |
Scan QR bill document and return payment data |
SettingsApi
Section titled “SettingsApi”| Method | Description |
|---|---|
getPaymentsSettings |
Retrieve payments user settings |
updatePaymentsSettings |
Update payments user settings |
How to perform different tasks
Section titled “How to perform different tasks”Here some examples how the dart client can be used
Create a simple payment
Section titled “Create a simple payment” final paymentModel = ModelHelperPayments().createPaymentDetailed( executionDate: Date.now(), accountId: "123", amount: 100, purpose: "Care for me", counterpartIban: "CH9300762011623852957", counterpartName: "Migros", );
final client = M8tyClientPis(); client.setOAuthToken('ApiOAuth2', oauthToken);
final api = client.getPaymentsApi(); await api.createPayment(paymentModel: paymentModel);Create a standing order
Section titled “Create a standing order” final paymentModel = ModelHelperPayments().createPaymentDetailed( executionDate: Date.now(), accountId: "123", amount: 100, purpose: "Care for me", counterpartIban: "CH9300762011623852957", counterpartName: "Migros", standingOrderFrequency: FrequencyEnumModel.QUARTERLY, standingOrderEndDate: DateTime.now().add(Duration(year: 2)).toDate(), );
final client = M8tyClientPis(); client.setOAuthToken('ApiOAuth2', oauthToken);
final api = client.getPaymentsApi(); await api.createPayment(paymentModel: paymentModel);Validate a payment before creation
Section titled “Validate a payment before creation” final client = M8tyClientPis(); client.setOAuthToken('ApiOAuth2', oauthToken);
final api = client.getPaymentsApi();
try { final response = await api.validatePayment( paymentModel: paymentModel, ); print('Validation: ${response.data}'); } on DioException catch (e) { throw Exception( 'Request failed (status: ${e.response?.statusCode}): ${e.response?.data}', ); }Search for beneficiaries (autocompletion)
Section titled “Search for beneficiaries (autocompletion)” final client = M8tyClientPis(); client.setOAuthToken('ApiOAuth2', oauthToken);
final api = client.getBeneficiaryApi(); final response = await api.beneficiaryAutocompletion( beneficiaryAutocompleteRequestModel: BeneficiaryAutocompleteRequestModel((b) { // set search criteria }), );Scan a QR bill
Section titled “Scan a QR bill” final client = M8tyClientPis(); client.setOAuthToken('ApiOAuth2', oauthToken);
final api = client.getQrBillApi(); final response = await api.scanQrBill( // provide QR bill document );© m8ty GmbH 2023 · m8ty.eu
