SOLVED invalid amount (should be passed in integer paise. minimum value is 100 paise i.e. ₹ 1) Razorpay

SOLVED invalid amount (should be passed in integer paise. minimum value is 100 paise i.e. ₹ 1) Razorpay In the realm of online transactions, seamless payment processing is crucial for businesses

SOLVED invalid amount (should be passed in integer paise. minimum value is 100 paise i.e. ₹ 1) Razorpay

SOLVED invalid amount (should be passed in integer paise. minimum value is 100 paise i.e. ₹ 1) Razorpay

In the realm of online transactions, seamless payment processing is crucial for businesses to thrive. One popular payment gateway that facilitates this seamless experience is Razorpay. However, integrating Razorpay into your website or application can sometimes lead to challenges, such as encountering the “invalid amount” error. In this blog post, we’ll delve into the causes of this error and provide a comprehensive solution to resolve it.

Understanding the Error: The “invalid amount” error typically occurs when the amount parameter passed to Razorpay is not in the correct format. Razorpay requires the amount to be passed as an integer representing the total amount to be paid in the smallest currency subunit (e.g., paise for INR). Additionally, the amount must be greater than or equal to 100 paise (₹ 1).

Identifying the Solution: To resolve the “invalid amount” error, it’s essential to ensure that the amount parameter meets Razorpay’s requirements. Here’s a step-by-step guide to implementing the solution:

Step 1: Convert the Total Payable Amount to Integer Paise: Before passing the amount to Razorpay, convert the total payable amount to an integer value representing the amount in paise. This can be achieved by multiplying the total payable amount by 100 and then casting it to an integer using the intval() function in PHP.

Step 2: Configure Razorpay Options: Once the total payable amount is converted to paise, configure the Razorpay options with the converted amount. Replace the original amount parameter with the converted integer value in the Razorpay options.

Step 3: Verify Currency Subunit and Minimum Amount: Ensure that the currency subunit used matches the currency being transacted (e.g., INR uses paise as the subunit). Additionally, verify that the converted amount meets Razorpay’s minimum requirement of 100 paise (₹ 1).

SOLVED invalid amount (should be passed in integer paise. minimum value is 100 paise i.e. ₹ 1) Razorpay

Implementation in Code: Below is a sample code snippet demonstrating how to implement the solution:

<?php
//start common code of all payment gateway
if($payment_details['is_instructor_payout_user_id'] > 0){
$instructor_details = $this->user_model->get_all_user($payment_details['is_instructor_payout_user_id'])->row_array();
$keys = json_decode($instructor_details['payment_keys'], true);
$keys = $keys[$payment_gateway['identifier']];
}else{
$keys = json_decode($payment_gateway['keys'], true);
}
$test_mode = $payment_gateway['enabled_test_mode'];
//ended common code of all payment gateway

// Convert the total payable amount to an integer value (assuming it's in INR)
$amount_in_paise = intval($payment_details['total_payable_amount'] * 100);
?>
<button id="rzp-button1" class="payment-button float-end gateway <?php echo $payment_gateway['identifier']; ?>-gateway"><i class="fas fa-money-bill"></i> <?php echo get_phrase('pay_by_razorpay'); ?></button>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
var options = {
"key": "<?php echo $keys['key_id']; ?>", // Enter the Key ID generated from the Dashboard
"amount": <?php echo $amount_in_paise; ?>, // Amount is in currency subunits. Default currency is INR. Hence, 50000 refers to 50000 paise
"currency": "<?php echo $payment_gateway['currency']; ?>",
"description": "<?php echo $payment_details['payment_title']; ?>",
"image": "https://s3.amazonaws.com/rzp-mobile/images/rzp.jpg",
config: {
display: {
blocks: {
utib: { //name for Axis block
name: "Pay using Axis Bank",
instruments: [
{
method: "card",
issuers: ["UTIB"]
},
{
method: "netbanking",
banks: ["UTIB"]
},
]
},
other: { // name for other block
name: "Other Payment modes",
instruments: [
{
method: "card",
issuers: ["ICIC"]
},
{
method: 'netbanking',
}
]
}
},
hide: [
{
method: "upi"
}
],
sequence: ["block.utib", "block.other"],
preferences: {
show_default_blocks: false // Should Checkout show its default blocks?
}
}
},
"handler": function (response) {
// alert(response.razorpay_payment_id);
// console.log(response);

window.location.href = '<?php echo $payment_details['success_url'].'/'.$payment_gateway['identifier'];?>'+'?razorpay_payment_id='+response.razorpay_payment_id;
},
"modal": {
"ondismiss": function () {
if (confirm("Are you sure, you want to close the form?")) {
txt = "You pressed OK!";
console.log("Checkout form closed by the user");
} else {
txt = "You pressed Cancel!";
console.log("Complete the Payment")
}
}
}
};
var rzp1 = new Razorpay(options);
document.getElementById('rzp-button1').onclick = function (e) {
rzp1.open();
e.preventDefault();
}
</script>

Conclusion:

By following the steps outlined above, you can effectively resolve the “invalid amount” error encountered during Razorpay integration. Ensuring that the amount parameter is passed in the correct format and meets Razorpay’s requirements is crucial for a smooth payment processing experience. With this solution, you can enhance the reliability and functionality of your payment gateway integration, enabling seamless transactions for your users.

Signup with Razorpay today: CLICK HERE

Checkout Online SEO courses Click HERE

 

 

Dudes Creative

Boost online presence with DudesCreative.com. We specialize in SEO, digital marketing, & web design. Get noticed & drive more traffic to your site. Contact us.