/apps-script-paypal-ipn-listener

⚡💵 Simple Google Apps Script Library project for interacting with the PayPal IPN postback service.

Primary LanguageJavaScript

Apps Script PayPal IPN Listener

This is a super-simple Google Apps Script Library project that provides a minimal API for interacting with the PayPal IPN postback service.

Usage

  1. Add the Library to your Google Apps Script project.
    • Use the library's Script ID (not its "Project Key"); the Script ID can be found in this repository's .clasp.json file.
  2. Choose a sensible identifier for the library in your project. The examples below assume the use of the default PayPalIPNListener identifier.
  3. Use this library's API in your code.

Full documentation is provided in JSDoc documentation blocks in the comments preceeding each function.

Example Usage

A simple example:

/**
 * Example project's HTTP POST handler.
 *
 * @see https://developers.google.com/apps-script/guides/triggers/#dogete_and_doposte
 */
function doPost (e) {
    if (PayPalIPNListener.isIpnMessage(e)) {
        if (PayPalIPNListener.isValid(e)) {
            // Verification successul, so continue processing.
            // This means the PayPal payment is valid, not necessarily
            // that it meets your business needs. For example, you
            // should write code that ensures that the payment amount
            // is what you expect it to be, etc.
        } else {
            Logger.log('PayPal verification failed.');
        }
    }
}