Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
￴￴ committed Oct 11, 2024
1 parent 26da370 commit 88aa294
Show file tree
Hide file tree
Showing 19 changed files with 61 additions and 13 deletions.
4 changes: 3 additions & 1 deletion package/general_payment/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ linux/flutter/ephemeral
macos/Flutter/ephemeral
windows/ephemeral
tmp/
temp/
temp/

bin/
5 changes: 4 additions & 1 deletion package/general_payment/bin/general_payment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import 'package:general_lib/general_lib.dart';
import 'package:general_payment/general_payment.dart';

void main(List<String> arguments) async {

// production_token: "xnd_production_hstOUOUQoO2IKT7STFXPw9tjaTIPdePNigXoTZ8E0BjubO7xOqHvQSM95YCjm7A",
// development_token: "xnd_production_hstOUOUQoO2IKT7STFXPw9tjaTIPdePNigXoTZ8E0BjubO7xOqHvQSM95YCjm7A",
print("Heelo");

final GeneralPayment generalPayment = GeneralPayment();
generalPayment.ensureInitialized();
final result = await generalPayment.createInvoice(
external_id: "asas",
amount: 100,
generalPaymentAuth: GeneralPaymentAuth.auto(paymentGatewayApiKey: "xnd_development_sapslap", paymentGatewayOwnerId: ""),
generalPaymentAuth: GeneralPaymentAuth.auto(paymentGatewayApiKey: "xnd_production_hstOUOUQoO2IKT7STFXPw9tjaTIPdePNigXoTZ8E0BjubO7xOqHvQSM95YCjm7A", paymentGatewayOwnerId: ""),
);
result.rawData.printPretty();
}
1 change: 1 addition & 0 deletions package/general_payment/lib/api/create_invoice.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extension GeneralPaymentExtensionCreateInvoice on GeneralPayment {
generalPaymentAuth: generalPaymentAuth,
onXendit: (generalPaymentAuth) async {
final result = await xendit.createInvoice(
xenditApiKey: generalPaymentAuth.apiKey,
external_id: external_id,
amount: amount,
forUserId: forUserId,
Expand Down
1 change: 1 addition & 0 deletions package/general_payment/lib/api/get_invoice.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extension GeneralPaymentExtensiongetInvoice on GeneralPayment {
generalPaymentAuth: generalPaymentAuth,
onXendit: (generalPaymentAuth) async {
final result = await xendit.getInvoice(
xenditApiKey: generalPaymentAuth.apiKey,
forUserId: forUserId,
invoice_id: invoice_id,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extension GeneralPaymentExtensiongetWalletAccountbyId on GeneralPayment {
email: "[email protected]",
);
}
final account = await xendit.getAccount(id: wallet_id);
final account = await xendit.getAccount(id: wallet_id, xenditApiKey: generalPaymentAuth.apiKey,);
return Account(account.toJson());
},
onMidtrans: (generalPaymentAuth) {
Expand Down
3 changes: 1 addition & 2 deletions package/general_payment/lib/general_payment_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class GeneralPayment {
if (is_payment_gateway_initialized) {
return;
}
xendit = Xendit(
xendit_api_key: "",
xendit = Xendit(
httpClient: httpClient,
);
is_payment_gateway_initialized = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ extension XenditExtensioncreateAccount on Xendit {
required String email,
required String type,
required String bussiness_name,
required String xenditApiKey,

Map<String, String>? headers,
}) async {
return await invokeBuilder(
endpoint: "POST https://api.xendit.co/v2/accounts",
xenditApiKey: xenditApiKey,
parameters: {
"email": email,
"type": type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ extension XenditExtensionCreateInvoice on Xendit {
List? items,
List? fees,
bool? should_authenticate_credit_card,
required String xenditApiKey,

Map<String, String>? headers,
}) async {
final Map jsonData = {
Expand All @@ -52,6 +54,7 @@ extension XenditExtensionCreateInvoice on Xendit {
};
return await invokeBuilder(
endpoint: "POST https://api.xendit.co/v2/invoices",
xenditApiKey: xenditApiKey,
headers: {
"for-user-id": forUserId,
"with-fee-rule": withFeeRule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ extension XenditExtensioncreatePayOutLink on Xendit {
required String external_id,
required int amount,
required String email,
required String xenditApiKey,

}) async {
return await invokeBuilder(
endpoint: "POST https://api.xendit.co/payouts",
xenditApiKey: xenditApiKey,
headers: {
"for-user-id": forUserId,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import 'package:general_payment/package/xendit/xendit_core.dart';
extension XenditExtensiongetAccount on Xendit {
Future<Account> getAccount({
required String id,
required String xenditApiKey,

Map<String, String>? headers,
}) async {
return await invokeBuilder(
endpoint: "GET https://api.xendit.co/v2/accounts/$id",
headers: headers,
xenditApiKey: xenditApiKey,
onResult: (result) {
return Account(result);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import 'package:general_payment/package/xendit/xendit_core.dart';
extension XenditExtensiongetBalance on Xendit {
Future<Balance> getBalance({
String forUserId = "",
required String account_type,
required String account_type, required String xenditApiKey,

}) async {
return await invokeBuilder(
endpoint: "GET https://api.xendit.co/balance?account_type=$account_type",
xenditApiKey: xenditApiKey,
headers: {
"for-user-id": forUserId,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ extension XenditExtensionGetInvoice on Xendit {
Future<Invoice> getInvoice({
String forUserId = "",
required String invoice_id,
required String xenditApiKey,

}) async {
return await invokeBuilder(
endpoint: "GET https://api.xendit.co/v2/invoices/$invoice_id",
xenditApiKey: xenditApiKey,
headers: {
"for-user-id": forUserId,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ extension XenditExtensionGetInvoiceByExternalId on Xendit {
Future<Invoice> getInvoiceByExternalId({
String forUserId = "",
required String external_id,
required String xenditApiKey,

}) async {
return await invokeBuilder(
endpoint: "GET https://api.xendit.co/v2/invoices/?external_id=$external_id",
xenditApiKey: xenditApiKey,
headers: {
"for-user-id": forUserId,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import 'package:general_payment/package/xendit/xendit_core.dart';
extension XenditExtensionGetInvoices on Xendit {
Future<Invoices> getInvoices({
String forUserId = "",
required String xenditApiKey,

}) async {
return await invokeBuilder(
endpoint: "GET https://api.xendit.co/v2/invoices",
xenditApiKey: xenditApiKey,
headers: {
"for-user-id": forUserId,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ extension XenditExtensiongetPayOutLinkById on Xendit {
Future<PayOutLink> getPayOutLinkById({
String forUserId = "",
required String id,
required String xenditApiKey,

}) async {
return await invokeBuilder(
endpoint: "GET https://api.xendit.co/payouts/$id",
xenditApiKey: xenditApiKey,
headers: {
"for-user-id": forUserId,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ extension XenditExtensionsetInvoiceExpireByInvoiceId on Xendit {
Future<Invoice> setInvoiceExpireByInvoiceId({
String forUserId = "",
required String invoice_id,
required String xenditApiKey,

}) async {
return await invokeBuilder(
endpoint: "POST https://api.xendit.co/invoices/$invoice_id/expire!",
xenditApiKey: xenditApiKey,
headers: {
"for-user-id": forUserId,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ extension XenditExtensionupdateAccount on Xendit {
required String email,
required String bussiness_name,
Map<String, String>? headers,
required String xenditApiKey,

}) async {
return await invokeBuilder(
endpoint: "PATCH https://api.xendit.co/v2/accounts/{id}",
xenditApiKey: xenditApiKey,
parameters: {
"email": email,
"public_profile": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import 'package:general_payment/package/xendit/xendit_core.dart';
extension XenditExtensionvoidPayOutLinkById on Xendit {
Future<PayOutLink> voidPayOutLinkById({
String forUserId = "",
required String xenditApiKey,

required String id,
}) async {
return await invokeBuilder(
endpoint: "POST https://api.xendit.co/payouts/$id/void",
xenditApiKey: xenditApiKey,
headers: {
"for-user-id": forUserId,
},
Expand Down
21 changes: 14 additions & 7 deletions package/general_payment/lib/package/xendit/xendit_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ import 'package:general_payment/package/xendit/extension/map.dart';
import 'package:general_payment/package/xendit/scheme/respond_scheme/respond_scheme.dart';

/// xendit helo world heo gais
class Xendit {
final String xendit_api_key;
class Xendit {
late final Client http_client;

Xendit({
required this.xendit_api_key,
Xendit({
Client? httpClient,
}) {
if (httpClient == null) {
Expand Down Expand Up @@ -126,7 +124,7 @@ class Xendit {
Map? parameters,
Map<String, String>? headers,
Map<String, String>? queryParameters,
String? xenditApiKey,
required String xenditApiKey,
Client? httpClient,
String specialTypeSucces = "ok",
}) async {
Expand All @@ -135,7 +133,7 @@ class Xendit {
parameters: parameters ?? {},
headers: headers ?? {},
queryParameters: queryParameters ?? {},
xenditApiKey: xenditApiKey ?? xendit_api_key,
xenditApiKey: xenditApiKey,
httpClient: httpClient ?? http_client,
specialTypeSucces: specialTypeSucces,
);
Expand All @@ -147,7 +145,7 @@ class Xendit {
Map? parameters,
Map<String, String>? headers,
Map<String, String>? queryParameters,
String? xenditApiKey,
required String xenditApiKey,
Client? httpClient,
String specialTypeSucces = "ok",
required FutureOr<T> Function(Map result) onResult,
Expand All @@ -168,6 +166,8 @@ class Xendit {
required int amount,
required String source_user_id,
required String destination_user_id,
required String xenditApiKey,

Map<String, String>? headers,
}) async {
return await invokeBuilder(
Expand All @@ -179,6 +179,7 @@ class Xendit {
"destination_user_id": destination_user_id,
},
headers: headers,
xenditApiKey: xenditApiKey,
onResult: (result) {
return TransactionBalanceAccount(result);
},
Expand All @@ -188,10 +189,13 @@ class Xendit {
Future<TransactionBalanceAccount> getTransferBalanceAccount({
required String reference,
Map<String, String>? headers,
required String xenditApiKey,

}) async {
return await invokeBuilder(
endpoint: "GET https://api.xendit.co/transfers/reference=${reference}",
headers: headers,
xenditApiKey: xenditApiKey,
onResult: (result) {
return TransactionBalanceAccount(result);
},
Expand All @@ -202,6 +206,8 @@ class Xendit {
required String name,
required String description,
required List<Map> routes,
required String xenditApiKey,

Map<String, String>? headers,
}) async {
final Map jsonData = {
Expand All @@ -213,6 +219,7 @@ class Xendit {
endpoint: "POST https://api.xendit.co/fee_rules",
parameters: jsonData,
headers: headers,
xenditApiKey: xenditApiKey,
onResult: (result) {
return TransactionBalanceAccount(result);
},
Expand Down

0 comments on commit 88aa294

Please sign in to comment.