Initial commit: Penyerahan final Source code Tugas Akhir
This commit is contained in:
29
lib/services/cancel_payment_service.dart
Normal file
29
lib/services/cancel_payment_service.dart
Normal file
@ -0,0 +1,29 @@
|
||||
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';
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user