30 lines
913 B
Dart
30 lines
913 B
Dart
import 'dart:convert';
|
|
|
|
import 'package:initial_folder/base_service.dart';
|
|
import 'package:initial_folder/helper/user_info.dart';
|
|
import 'package:http/http.dart' as http;
|
|
|
|
class CancelPaymentService {
|
|
Future<String> cancelPayment(String paymentId) async {
|
|
print("Ini id payment?${paymentId}");
|
|
var token = await UsersInfo().getToken();
|
|
var idUser = await UsersInfo().getIdUser();
|
|
|
|
Uri url = Uri.parse('$baseUrl/payment/cancel-payment');
|
|
|
|
var body = jsonEncode({
|
|
'id_payment': paymentId,
|
|
});
|
|
|
|
http.Response response =
|
|
await http.post(url, headers: headerWithToken(token!), body: body);
|
|
if (response.statusCode == 201) {
|
|
print("Berhasil cancel cuy${response.body}");
|
|
return 'Transaksi berhasil dibatalkan';
|
|
} else {
|
|
print("Ga berhasil cancel cuy${response.body}");
|
|
return 'Gagal, pembayaran sudah dibatalkan atau kadaluwarsa';
|
|
}
|
|
}
|
|
}
|