Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion PluginRazorpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,26 @@ function singlepayment($params)
try {
$payment = $api->payment->fetch($razorpay_payment_id); // Returns a particular payment
$pricePaid = sprintf("%01.2f", round(($payment->amount / 100), 2)); // paise in rupees

// If payment is authorized but not captured, capture it
if ($payment->status === 'authorized') {
try {
$payment->capture(array(
'amount' => $payment->amount,
'currency' => $payment->currency
));

// Refetch to confirm capture
$payment = $api->payment->fetch($razorpay_payment_id);

if ($payment->status !== 'captured') {
throw new Exception('Payment capture failed');
}
} catch (Exception $e) {
$success = false;
$error = 'Razorpay Error : Capture failed - ' . $e->getMessage();
}
}
} catch (Exception $e) {
$pricePaid = $params['invoiceTotal'];
}
Expand Down Expand Up @@ -216,7 +236,7 @@ public function getForm($args)
$orderData = array(
'receipt' => $args['invoiceId'],
'amount' => sprintf("%01.2f", round($args['invoiceBalanceDue'], 2)) * 100, // rupees in paise
'currency' => 'INR',
'currency' => $args['currency'],
'payment_capture' => 1 // auto capture
);
$razorpayOrder = $api->order->create($orderData);
Expand Down