我正在使用剃刀支付Flutter包,使支付Flutter在测试模式。我有选项来处理事件,也保存在我的数据库中的付款ID。我想根据付款id退款。我没有太多关于如何做同样的澄清。这是我发送付款请求的代码
Razorpay? _razorpay = Razorpay();
void openPaymentPortal() async {
var options = {
'key': 'My_key',
'amount': 100000,
'name': 'test',
'description': 'Payment for Pro account',
'prefill': {'contact': '9999999999', 'email': 'build@test.com'},
'external': {
'wallets': ['paytm']
}
};
try {
_razorpay?.open(options);
} catch (e) {
debugPrint(e.toString());
}
}
void _handlePaymentSuccess(PaymentSuccessResponse response) {
Fluttertoast.showToast(
msg: "SUCCESS PAYMENT: ${response.paymentId}", timeInSecForIosWeb: 5);
onSubmit(false, response.paymentId.toString());
}
void _handlePaymentError(PaymentFailureResponse response) {
Fluttertoast.showToast(
msg: "ERROR HERE: ${response.code} - ${response.message}",
timeInSecForIosWeb: 4);
}
void _handleExternalWallet(ExternalWalletResponse response) {
Fluttertoast.showToast(
msg: "EXTERNAL_WALLET IS : ${response.walletName}",
timeInSecForIosWeb: 4);
}
如何处理退款给用户?我按照下面的代码,但它是不工作的东西
void processRefund(String paymentId) async {
var url =
Uri.parse('https://api.razorpay.com/v1/payments/$paymentId/refund');
try {
var response = await http.post(
url,
headers: {
'Authorization': 'Bearer My_Key',
'Content-Type': 'application/json'
},
);
if (response.statusCode == 200) {
// Refund processed successfully
print('Refund processed successfully');
} else {
// Refund failed
print('Refund failed with status code: ${response.statusCode}');
print('Response body: ${response.body}');
}
} catch (e) {
// Error occurred while making the refund request
print('Error occurred during refund process: $e');
}
}
2条答案
按热度按时间kkih6yb81#
cxfofazt2#
我是这样解决我的案子的