payViaPaygateV1 function

Future<NewTransactionResponse> payViaPaygateV1({
  1. required String authToken,
  2. required String phoneNumber,
  3. required PaygateProvider provider,
  4. required double amount,
  5. required String identifier,
  6. String? description,
})

Pour initier une transaction, faites un simple appel HTTP de type Post vers le service web de PayGateGlobal et passer les param├Ętres requis. Uniquement pour le service Flooz.

Implementation

Future<NewTransactionResponse> payViaPaygateV1({
  required String authToken,
  required String phoneNumber,
  required PaygateProvider provider,
  required double amount,
  required String identifier,
  String? description,
}) async {
  _NewTransactionResponseV1 response;

  try {
    http.Response post = await http.post(
      uriPayV1Post,
      body: _ParamsNewTransactionV1(
        authToken,
        phoneNumber,
        provider,
        amount,
        identifier,
        description: description,
      ).body,
    );

    response = _NewTransactionResponseV1.fromJson(jsonDecode(post.body));
  } catch (e) {
    response = _NewTransactionResponseV1(
      null,
      status: NewTransactionResponseStatus.none,
      exception: e.toString(),
    );
  }

  return response.bridge(identifier);
}