createPaymentJson method
Future<Response<RazorpayPaymentS2SJson> >
createPaymentJson({
- required dynamic params,
- void callback(
- RazorpayApiException?,
- Response<
RazorpayPaymentS2SJson> ?
Create payment json (S2S flow)
@param params - Check docs for S2S or TPV card payments. Accepts RazorpayPaymentS2SCreateRequestBody or RazorpayPaymentThirdPartyCreateRequestBody.
Implementation
Future<Response<RazorpayPaymentS2SJson>> createPaymentJson({
required dynamic params, // Use dynamic for union type
void Function(RazorpayApiException?, Response<RazorpayPaymentS2SJson>?)?
callback,
}) async {
Map<String, dynamic> requestData;
if (params is RazorpayPaymentS2SCreateRequestBody ||
params is RazorpayPaymentThirdPartyCreateRequestBody) {
requestData = params is RazorpayPaymentS2SCreateRequestBody
? params.toJson()
: params is RazorpayPaymentThirdPartyCreateRequestBody
? params.toJson()
: {};
} else {
throw ArgumentError('Invalid params type for createPaymentJson.');
}
return api.post<RazorpayPaymentS2SJson>(
{
'url': '$BASE_URL/create/json',
'data': requestData,
},
fromJsonFactory: RazorpayPaymentS2SJson.fromJson,
callback: callback,
);
}