Skip to content

fluidpay/fluidpay-dart

Repository files navigation

Dart SDK for using the Fluid Pay API.

Install

  fluidpay:
    git:
      url: git@github.com:fluidpay/fluidpay-dart.git
      ref: v0.4.0

Usage

Before you can use the SDK a pre-initialization is required. This can be done by using API key or logging in.

Initialization - API Key

import 'package:fluidpay/com/fluidpay/gateway.dart';

void main() async {
  String baseUrl = "https://sandbox.fluidpay.com/api";
  Gateway.instance.init(baseUrl, apiKey: "apixxxx");
}

Initialization - User login

If you choose this option you can use the SDK in the name of the user who logged in.

import 'package:fluidpay/com/fluidpay/gateway.dart';

void main() async {
  String baseUrl = "https://sandbox.fluidpay.com/api";
  Gateway.instance.init(baseUrl);
  
  final request = AuthLoginRequest('testUser', 'testPassword');
  await Gateway.instance.login(request);
}

Execute requests

If you have done wny of the steps above, the SDK initialized and ready to send requests. You can execute requests by passing the right request representation to the execute function. You can see the detailed description below about the supported operations.

import 'package:fluidpay/com/fluidpay/gateway.dart';

void main() async {
  // Do the initialization

  final request = TransactionCreateRequest();
  request.paymentMethod = PaymentMethodRequest()
  ..amount = 1000
  ..card = (
    CreditCardRequest()
      ..number = "4111111111111111"
  );
  // Fill other fields

  final response = await Gateway.instance.execute(request); // response will be TransactionCreateResponse
}

Change Auth Header

In case of reauthentication or change of the method of the authentication there is an option to set the Authorization header.

Gateway.instance.setAuthHeaderCreator(() => {'Authorization': 'token/key/etc'});
Save authentication
void setSavedAuthJson() async {
  final sharedPreferences = await SharedPreferences.getInstance();
  final authDataJson = sharedPreferences.getString(KEY_AUTH_DATA);

  Gateway.instance.authData = AuthLoginResponseData.fromJson(jsonDecode(authDataJson));
}

Supported operations

Category
Request Response
Authentication
  • AuthLoginRequest
  • AuthLoginResponse
Common







  • InvoiceCreateRequest
  • InvoiceUpdateRequest
  • InvoiceResendRequest
  • InvoiceMarkAsPaidRequest
  • InvoiceReactivateRequest
  • InvoiceDeleteRequest
  • InvoiceGetRequest
  • InvoiceSearchRequest
  • InvoiceCreateResponse
  • InvoiceUpdateResponse
  • InvoiceResendResponse
  • InvoiceMarkAsPaidResponse
  • InvoiceReactivateResponse
  • InvoiceDeleteResponse
  • InvoiceGetResponse
  • InvoiceSearchResponse
  • Customer Vault










    • CustomerCreateRequest
    • CustomerGetRequest
    • CustomerDeleteRequest
    • CustomerUpdateRequest
    • CustomerSearchRequest
    • CustomerAddressCreateRequest
    • CustomerAddressUpdateRequest
    • CustomerAddressDeleteRequest
    • CustomerPaymentTypeCreateRequest
    • CustomerPaymentTypeUpdateRequest
    • CustomerPaymentTypeDeleteRequest
    • CustomerCreateResponse
    • CustomerGetResponse
    • CustomerDeleteResponse
    • CustomerUpdateResponse
    • CustomerSearchResponse
    • CustomerAddressCreateResponse
    • CustomerAddressUpdateResponse
    • CustomerAddressDeleteResponse
    • CustomerPaymentTypeCreateResponse
    • CustomerPaymentTypeUpdateResponse
    • CustomerPaymentTypeDeleteResponse
    Invoice







    • InvoiceCreateRequest
    • InvoiceUpdateRequest
    • InvoiceResendRequest
    • InvoiceMarkAsPaidRequest
    • InvoiceReactivateRequest
    • InvoiceDeleteRequest
    • InvoiceDeleteRequest
    • InvoiceSearchRequest
    • InvoiceCreateResponse
    • InvoiceUpdateResponse
    • InvoiceResendResponse
    • InvoiceMarkAsPaidResponse
    • InvoiceReactivateResponse
    • InvoiceDeleteResponse
    • InvoiceDeleteResponse
    • InvoiceSearchResponse
    Recurring














    • AddOnCreateRequest
    • AddOnUpdateRequest
    • AddOnSearchRequest
    • AddOnDeleteRequest
    • AddOnRequest
    • CustomerRequest
    • DiscountCreateRequest
    • DiscountUpdateRequest
    • DiscountSearchRequest
    • DiscountDeleteRequest
    • DiscountRequest
    • PlanCreateRequest
    • PlanSearchRequest
    • SubscriptionCreateRequest
    • SubscriptionSearchRequest
    • AddOnCreateResponse
    • AddOnUpdateResponse
    • AddOnSearchResponse
    • AddOnDeleteResponse
    • AddOnResponse
    • CustomerResponse
    • DiscountCreateResponse
    • DiscountUpdateResponse
    • DiscountSearchResponse
    • DiscountDeleteResponse
    • DiscountResponse
    • PlanCreateResponse
    • PlanSearchResponse
    • SubscriptionCreateResponse
    • SubscriptionSearchResponse
    Terminal
    • TerminalGetRequest
    • TerminalGetResponse
    Transaction












    • TransactionCreateRequest
    • TransactionGetRequest
    • TransactionCaptureRequest
    • TransactionVoidRequest
    • TransactionRefundRequest
    • TransactionCreateVaultRequest
    • TransactionEmailReceiptRequest
    • TransactionPrintReceiptRequest
    • TransactionTipAdjustmentRequest
    • TransactionMultiRequest
    • TransactionMultiVoidRequest
    • TransactionMultiRefundRequest
    • TransactionSearchRequest
    • TransactionCreateResponse
    • TransactionGetResponse
    • TransactionCaptureResponse
    • TransactionVoidResponse
    • TransactionRefundResponse
    • TransactionCreateVaultResponse
    • TransactionEmailReceiptResponse
    • TransactionPrintReceiptResponse
    • TransactionTipAdjustmentResponse
    • TransactionMultiResponse
    • TransactionMultiVoidResponse
    • TransactionMultiRefundResponse
    • TransactionSearchResponse
    User













    • ForgotUsernameRequest
    • ForgotPasswordRequest
    • ForgotPasswordResetRequest
    • UserGetRequest
    • UserPasswordChangeRequest
    • UserSetTotpRequest
    • UserRemoveTotpRequest
    • UserCreateRequest
    • UserUpdateRequest
    • UsersRequest
    • UserLoginAsRequest
    • UserDeleteRequest
    • UserCopyRequest
    • UserResendWelcomeEmailRequest
    • ForgotUsernameResponse
    • ForgotPasswordResponse
    • ForgotPasswordResetResponse
    • UserGetResponse
    • UserPasswordChangeResponse
    • UserSetTotpResponse
    • UserRemoveTotpResponse
    • UserCreateResponse
    • UserUpdateResponse
    • UsersResponse
    • UserLoginAsResponse
    • UserDeleteResponse
    • UserCopyResponse
    • UserResendWelcomeEmailResponse

    Development

    For json serialization we use json_serializable package. It generates helper classes we only commited to release branch. Before start, generate the request/response serialize support files with:

    pub run build_runner build

    Contribution

    This is an actively developed library. We will check the new issues soon. But if you wanted to help us with your code, feel free to make a pull request.