Plugin Directory

Changeset 3429302


Ignore:
Timestamp:
12/29/2025 09:37:00 PM (3 months ago)
Author:
getmelon
Message:

Fix: send amount as string to Melon API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • melon-payment-gateway/trunk/assets/js/melon-modal.js

    r3428370 r3429302  
    32533253     
    32543254      // Amount should be in naira (e.g., 950.00)
    3255       const amountInNaira = parseFloat(amount) || 0;
     3255      // Clean input: remove commas and convert to number, then back to string for API
     3256      const cleanedAmount = String(amount || '').replace(/,/g, '');
     3257      const amountInNaira = parseFloat(cleanedAmount) || 0;
    32563258     
    32573259      // Validate amount
     
    32753277      // Build request body - source is required per API docs
    32763278      // Note: order_channels is NOT a valid parameter (API rejects it)
    3277       // Amount is in naira (e.g., 950.00)
     3279      // Amount must be sent as a STRING (API requirement)
    32783280      const requestBody = {
    32793281        public_key: publicKey,
    3280         amount: amountInNaira,
     3282        amount: amountInNaira.toFixed(2),
    32813283        method: method, // 'melon' or 'gateway'
    32823284        melon_id: cleanPhone,
Note: See TracChangeset for help on using the changeset viewer.