verifyPaymentViaPaygateV2 function

Future<Transaction> verifyPaymentViaPaygateV2(
  1. String token, {
  2. required String identifier,
})

@param txReference : Identifiant Unique précédemment généré par PayGateGlobal pour la transaction

Implementation

Future<Transaction> verifyPaymentViaPaygateV2(
  String token, {
  required String identifier,
}) async {
  Transaction response;

  try {
    http.Response post = await http.post(uriVerifyV2Post, body: {
      "auth_token": token,
      "identifier": identifier,
    });

    dynamic json = jsonDecode(post.body);

    if (json['tx_reference'] == null) {
      response = Transaction.fail(
        identifier: identifier,
      );
    } else {
      response = Transaction.fromV2(jsonDecode(post.body));
    }
  } catch (e) {
    response = Transaction.fail(
      exception: e.toString(),
      identifier: identifier,
    );
  }

  return response;
}