Sources

A Source is a resource to generate your customer's payment instrument.

The Source Resource

A Source is a resource to generate your customer's payment instrument. This is normally used to generate check out URLs for e-wallet payments. To learn more about e-wallet integrations, you can visit GCash or GrabPay integration.

More Details

Creating a Source

/**
 * These are the required properties
 * @param {Object} data Data paypload
 * @param {Object} data.attributes Payload attributes
 * @param {string} data.attributes.type The type of source. Possible values are gcash and grab_pay.
 * @param {number} data.attributes.amount Amount int32
 * @param {string} data.attributes.currency Three-letter ISO currency code, in uppercase. PHP is the only supported currency as of the moment.
 * @param {Object} data.attributes.redirect
 * @param {string} data.attributes.redirect.success Success url
 * @param {string} data.attributes.redirect.failed Error url
 */
const result = await paymongo.sources.create(data);
{
  data: {
    attributes: {
      type: 'gcash',
      amount: 20000, // PHP200,
      currency: 'PHP',
      redirect: {
        success: 'https://yoururl.com/success',
        failed: 'https://yoururl.com/failed'
      }
    }
  }
}

Retrieving a Source

/**
 * @param {string} id Source id
 */
const result = await paymongo.sources.retrieve(id);

Last updated