Dart SDK for using the Fluid Pay API.
fluidpay:
git:
url: git@github.com:fluidpay/fluidpay-dart.git
ref: v0.4.0
Before you can use the SDK a pre-initialization is required. This can be done by using API key or logging in.
import 'package:fluidpay/com/fluidpay/gateway.dart';
void main() async {
String baseUrl = "https://sandbox.fluidpay.com/api";
Gateway.instance.init(baseUrl, apiKey: "apixxxx");
}
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);
}
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
}
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'});
void setSavedAuthJson() async {
final sharedPreferences = await SharedPreferences.getInstance();
final authDataJson = sharedPreferences.getString(KEY_AUTH_DATA);
Gateway.instance.authData = AuthLoginResponseData.fromJson(jsonDecode(authDataJson));
}
Category |
Request | Response |
---|---|---|
Authentication |
|
|
Common |
|
|
Customer Vault |
|
|
Invoice |
|
|
Recurring |
|
|
Terminal |
|
|
Transaction |
|
|
User |
|
|
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
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.