createPaymentUrl method
Create a payment session and return the payment URL
Implementation
@override
Future<PaymentUrlResponse> createPaymentUrl(PaymentRequest request) async {
final response = await makeBackendRequest(
endpoint: '/api/payments/create',
method: 'POST',
body: {
'provider': 'paystack',
'amount': (request.amount * 100).round(), // Convert to kobo
'currency': request.currency.toUpperCase(),
'description': request.description,
'reference': request.orderId,
'email': request.customerEmail ?? '',
'name': request.customerName,
'phone': request.customerPhone,
'callback_url':
request.successUrl ?? '${config.backendUrl}/api/payments/success',
'cancel_url':
request.cancelUrl ?? '${config.backendUrl}/api/payments/cancel',
'metadata': request.metadata,
'public_key': config.apiKey,
'environment': config.environment.name,
},
);
final data = handleResponse(response);
return PaymentUrlResponse.fromJson(data);
}