Skip to content

Commit

Permalink
(update) on currencies and class name
Browse files Browse the repository at this point in the history
  • Loading branch information
Elikem Medehou authored and Elikem Medehou committed Apr 1, 2024
1 parent 61d5cdb commit 184eb6d
Show file tree
Hide file tree
Showing 10 changed files with 296 additions and 126 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [0.1.5] - 2024-04-01

### Update && Minor Breaking Changes

- Adding all the currencies and comment about them
- Adding more comment on payment info class
- Making the core models class start by Moneroo

# Changelog

## [0.1.4] - 2024-04-01

### Chores
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class _MyHomePageState extends State<MyHomePage> {
builder: (context) => Moneroo(
amount: 1,
apiKey: 'YOUR_API_KEY',
currency: MonerooCurency.XOF,
currency: MonerooCurrency.XOF,
customer: MonerooCustomer(
email: 'email@gmail.com',
firstName: 'firstname',
Expand Down
10 changes: 5 additions & 5 deletions lib/src/api/moneroo_api_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MonerooApi {
Future<MonerooPayment> initPayment({
required int amount,
required MonerooCustomer customer,
MonerooCurency currency = MonerooCurency.XOF,
MonerooCurrency currency = MonerooCurrency.XOF,
String? description,
String? callbackUrl,
Map<String, dynamic>? metadata,
Expand All @@ -57,7 +57,7 @@ class MonerooApi {
},
);

final apiResponse = ApiResponse.fromJson(res.data!);
final apiResponse = MonerooApiResponse.fromJson(res.data!);

return MonerooPayment.fromJson(apiResponse.data);
} on DioException catch (e) {
Expand All @@ -76,7 +76,7 @@ class MonerooApi {

/// Allow you to retrieve data about a payment given its paymentID. Can be
/// helpful to get the current status of a payment.
Future<PaymentInfos> getPaymentInfos({
Future<MonerooPaymentInfos> getMonerooPaymentInfos({
required String paymentId,
}) async {
try {
Expand All @@ -85,9 +85,9 @@ class MonerooApi {
'/${apiVersion.name}${Endpoints.payments}/$paymentId${Endpoints.verify}',
);

final apiResponse = ApiResponse.fromJson(res.data!);
final apiResponse = MonerooApiResponse.fromJson(res.data!);

return PaymentInfos.fromJson(apiResponse.data);
return MonerooPaymentInfos.fromJson(apiResponse.data);
} on DioException catch (e) {
if (e.response == null) throw ServiceUnavailableException();

Expand Down
59 changes: 56 additions & 3 deletions lib/src/commons/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,64 @@ enum MonerooVersion {
}

/// Allowed currency on Moneroo
enum MonerooCurency {
enum MonerooCurrency {
CDF, // Airtel Congo (airtel_cd)

MWK, // Airtel Money Malawi (airtel_mw)

/// QR Code Nigeria (qr_ngn),
/// Airtel Money Nigeria (airtel_ng),
/// Bank Transfer NG (bank_transfer_ng), Barter (barter)
NGN,

ZMW, // Airtel Zambia (airtel_zm)

GHS, // Credit Card GHS (card_ghs), Crypto GHS (crypto_ghs), Airtel/Tigo Ghana (tigo_gh), Vodafone Ghana (vodafone_gh)

/// Card Kenya (card_kes), M-Pesa Kenya (mpesa_ke),
/// TNM Mpamba Malawi (tnm_mw)
KES,

/// Airtel Tanzania (airtel_tz),
/// Card Tanzania (card_tzs),
/// Vodacom Tanzania (mpesa_tz), Tigo Tanzania (tigo_tz)
TZS,

/// Airtel Uganda (airtel_ug),
/// Card Uganda (card_ugx), MTN MoMo Uganda (mtn_ug)
UGX,

/// Credit Card USD (card_usd),
/// Crypto USD (crypto_usd),
/// Test Payment Method (moneroo_payment_demo)
USD,

/// Credit Card XAF (card_xaf), Crypto XAF (crypto_xaf)
/// EU Mobile Money Cameroon (eu_mobile_cm)
/// MTN MoMo Cameroon (mtn_cm),
/// Orange Money Cameroon (orange_cm), Wave CI (wave_ci)
XAF,

/// Airtel Niger (airtel_ne), Credit Card XOF (card_xof)
/// Crypto XOF (crypto_xof), Moov Burkina Faso (moov_bf)
/// Moov Money Benin (moov_bj), Moov Money CI (moov_ci),
/// Moov Money Mali (moov_ml), Moov Money Togo (moov_tg),
/// MTN MoMo Benin (mtn_bj), MTN MoMo CI (mtn_ci),
/// E-Money Senegal (e_money_sn), Free Money Senegal (freemoney_sn),
/// Mobi Cash Mali (mobi_cash_ml), Orange Burkina Faso (orange_bf),
/// Orange Money CI (orange_ci), Orange Money Guinea (orange_gn),
/// Orange Money Mali (orange_ml),Orange Money Senegal (orange_sn),
/// Wave Senegal (wave_sn), Wizall Senegal (wizall_sn),
/// Togocel Money (togocel)
XOF,
USD,
NGN,

ZAR, // Credit Card ZAR (card_zar)

EUR, // Crypto EUR (crypto_eur)

GNF, // MTN MoMo Guinea (mtn_gn), Orange Money Guinea (orange_gn)

RWF, //Airtel Rwanda (airtel_rw), MTN MoMo Rwanda (mtn_rw)
}

/// Give the current status of a payment
Expand Down
6 changes: 3 additions & 3 deletions lib/src/models/api_response.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/// Base class to handle API response
class ApiResponse {
class MonerooApiResponse {
///
ApiResponse({
MonerooApiResponse({
// required this.success,
required this.message,
required this.data,
});

///
ApiResponse.fromJson(Map<String, dynamic> json) {
MonerooApiResponse.fromJson(Map<String, dynamic> json) {
// success = json['success'] as bool;
message = json['message'] as String;
data = json['data'] as Map<String, dynamic>;
Expand Down
Loading

0 comments on commit 184eb6d

Please sign in to comment.