Socket
Socket
Sign inDemoInstall

ampsalesfunnels-functions

Package Overview
Dependencies
513
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ampsalesfunnels-functions

https://ampsalesfunnels.com - lib to support functions - Build blazingly fast sales funnels, learn coding, and get rich


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

ampsalesfunnels-functions

Set with helper functions for the implementation of Netlify functions.

Functions

printEnv(additionalAMPSFVars, additionalNetlifyVars)void

Print values of important Netlify provided built-in environment variables, and environment variables used by AMPSalesFunnels.

isProductionBasedOnHostname()boolean

Is site in production mode? Based on the host name.

getEnv(envName)

Get the value of the given environment variable, depending on production parameter. If production is true get PRODUCTION_ with fallback to . If production is false get SANDBOX_ with fallback to . If variable does not exist throw exception.

prepareFunction(event, context, dirname, additionalAMPSFVars, additionalNetlifyVars)void

Prepare a Netlify function for execution.

getAMPRedirectToFunctionResult(url)*

Get a Netlify function result object that will do an AMP redirect to an url.

getEmptyFunctionResult()Object

Get a Netlify 200 function result with empty JSON body.

getMessageFunctionResult(message)Object

Get a Netlify 200 function result with message.

getObjectFunctionResult(obj)*

Get a Netlify 200 function result with body.

getErrorFunctionResult(statusCode, error)Object

Get a Netlify function error result object.

sendEmailWithMailgen(nodemailerTransporter, from, to, name, sku, dirname)Promise.<void>

Send email using nodemailer with body generated using mailgen.

makeQueryString(params)string

Convert a dictionary object into a query string with URI encoded values

ifttt_event(key, eventname, value1, value2, value3)

Log an event to IFTTT.

log_event(production, eventname, valueA, valueB)

Log an event to available providers.

log_event_error(production, functionFilename, name, email, message)

Log an error event to available providers.

log_event_information(production, functionFilename, name, email, message)

Log an information event to available providers.

log_event_interest(production, name, email, sku, price)

Log an interested in sku event to available providers.

log_event_sale(production, name, email, sku, price)

Log a sale of sku event to available providers.

getPayPalBaseUrl(production)string

Get the PayPal base URL.

getPayPalMerchantEmail(production)string

Get the PayPal merchant email address.

getPayPalIpnNotificationUrl(production)string

Get the PayPal IPN notification URL.

getPayPalProductUrl(sku, formData, customData, siteUrl, returnPage, cancelPage, logoUrl, dirname, production)string

Get the PayPal url to do the checkout for a product.

payPalIpnValidate(ipnMessage, production)Promise.<void>

Validate the contents of a PayPal IPN message with PayPal. Throws an exception if the IPN message is INVALID.

payPalIpnToOrder(body)*

Convert PayPal IPN message to an order object. The field custom in the order contains the order form fields.

printEnv(additionalAMPSFVars, additionalNetlifyVars) ⇒ void

Print values of important Netlify provided built-in environment variables, and environment variables used by AMPSalesFunnels.

Kind: global function

ParamTypeDescription
additionalAMPSFVarsArray.<string>

additional AMPSalesFunnels specific environment variables to print

additionalNetlifyVarsArray.<string>

additional Netlify specific environment variables to print

isProductionBasedOnHostname() ⇒ boolean

Is site in production mode? Based on the host name.

Kind: global function

getEnv(envName)

Get the value of the given environment variable, depending on production parameter. If production is true get PRODUCTION_ with fallback to . If production is false get SANDBOX_ with fallback to . If variable does not exist throw exception.

Kind: global function

ParamType
envName*

prepareFunction(event, context, dirname, additionalAMPSFVars, additionalNetlifyVars) ⇒ void

Prepare a Netlify function for execution.

Kind: global function

ParamTypeDescription
eventAPIGatewayProxyEvent
contextany
dirnamestring

path to the directory containing the function

additionalAMPSFVarsArray.<string>

additional AMPSalesFunnels specific environment variables to print

additionalNetlifyVarsArray.<string>

additional Netlify specific environment variables to print

getAMPRedirectToFunctionResult(url) ⇒ *

Get a Netlify function result object that will do an AMP redirect to an url.

Kind: global function

ParamTypeDescription
urlstring

url to redirect to

getEmptyFunctionResult() ⇒ Object

Get a Netlify 200 function result with empty JSON body.

Kind: global function

getMessageFunctionResult(message) ⇒ Object

Get a Netlify 200 function result with message.

Kind: global function

ParamTypeDescription
messagestring

the message to return in body: { "message": message }

getObjectFunctionResult(obj) ⇒ *

Get a Netlify 200 function result with body.

Kind: global function

ParamTypeDescription
obj*

the obj to return in body: { ... }

getErrorFunctionResult(statusCode, error) ⇒ Object

Get a Netlify function error result object.

Kind: global function

ParamTypeDescription
statusCodenumber

status code

errorError | string

the error object (or a string), error message wil be returned in body: { "error": "message" }

sendEmailWithMailgen(nodemailerTransporter, from, to, name, sku, dirname) ⇒ Promise.<void>

Send email using nodemailer with body generated using mailgen.

Kind: global function

ParamTypeDescription
nodemailerTransporterTransporter

the nodemailer transporter to use

fromstring

email address of the sender

tostring

email address to send the mail to

namestring

name of the customer

skustring

unique identifier for the product (stock-keeping unit)

dirnamestring

path to the directory containing the mailgen files

makeQueryString(params) ⇒ string

Convert a dictionary object into a query string with URI encoded values

Kind: global function
Returns: string -

the query string

ParamTypeDescription
paramsObject.<string, string>

dictionary object with name-value pairs

ifttt_event(key, eventname, value1, value2, value3)

Log an event to IFTTT.

Kind: global function
Category: IFTTT

ParamTypeDescription
keystring

IFTTT key, available at https://ifttt.com/maker_webhooks/settings (after /use/)

eventnamestring

the name of the event to report

value1string

first value

value2string

second value

value3string

third value

log_event(production, eventname, valueA, valueB)

Log an event to available providers.

Kind: global function
Category: IFTTT

ParamTypeDescription
productionboolean

true if production; false if sandbox

eventnamestring

the name of the event to report, can be ERROR, LOG, INTERESTED, SALE, ...

valueAstring

first value

valueBstring

second value

log_event_error(production, functionFilename, name, email, message)

Log an error event to available providers.

Kind: global function
Category: IFTTT

ParamTypeDescription
productionboolean

true if production; false if sandbox

functionFilenamestring

filename of the function

namestring

name of user

emailstring

email of user

messagestring

error message

log_event_information(production, functionFilename, name, email, message)

Log an information event to available providers.

Kind: global function
Category: IFTTT

ParamTypeDescription
productionboolean

true if production; false if sandbox

functionFilenamestring

filename of the function

namestring

name of user

emailstring

email of user

messagestring

message to log

log_event_interest(production, name, email, sku, price)

Log an interested in sku event to available providers.

Kind: global function
Category: IFTTT

ParamTypeDefaultDescription
productionboolean

true if production; false if sandbox

namestring

name of user

emailstring

email of user

skustring"unknown"

sku of the product user is interested in

pricestring"unknown"

price of sku

log_event_sale(production, name, email, sku, price)

Log a sale of sku event to available providers.

Kind: global function
Category: IFTTT

ParamTypeDefaultDescription
productionboolean

true if production; false if sandbox

namestring

name of user

emailstring

email of user

skustring"unknown"

sku of the product user is interested in

pricestring"unknown"

price of sku

getPayPalBaseUrl(production) ⇒ string

Get the PayPal base URL.

Kind: global function
Returns: string -

The PayPal base URL https://www.sandbox.paypal.com or https://www.paypal.com'


Category: PayPal

ParamTypeDescription
productionboolean

in production mode if true; in sandbox mode if false

getPayPalMerchantEmail(production) ⇒ string

Get the PayPal merchant email address.

Kind: global function
Returns: string -

email address of merchant


Category: PayPal

ParamTypeDescription
productionboolean

in production mode if true; in sandbox mode if false

getPayPalIpnNotificationUrl(production) ⇒ string

Get the PayPal IPN notification URL.

Kind: global function
Returns: string -

The IPN notification URL


Category: PayPal

ParamTypeDescription
productionboolean

in production mode if true; in sandbox mode if false

getPayPalProductUrl(sku, formData, customData, siteUrl, returnPage, cancelPage, logoUrl, dirname, production) ⇒ string

Get the PayPal url to do the checkout for a product.

Kind: global function
Returns: string -

  • production url if in production mode, sandbox url otherwise
**Category**: PayPal
ParamTypeDescription
skustring

unique identifier for the product (stock-keeping unit)

formDataobject

form data as posted on the salesfunnel page

customDataobject

custom data to add to the PayPal URL

siteUrlstring

url of the site hosting the salesfunnel page

returnPagestring

relative url of page to go to when PayPal checkout completed, e.g. salesfunnel-thanks.html page)

cancelPagestring

relative url of page to go to when PayPal flow is canceled (salesfunnel page)

logoUrlstring

relative url to a 150x50 product log image used in PayPal checkout

dirnamestring

path to the directory containing the products.json file

productionboolean

in production mode if true; in sandbox mode if false

payPalIpnValidate(ipnMessage, production) ⇒ Promise.<void>

Validate the contents of a PayPal IPN message with PayPal. Throws an exception if the IPN message is INVALID.

Kind: global function
Returns: Promise.<void> -

  • a Promise than can be awaited
**Category**: PayPal
ParamTypeDescription
ipnMessagestring

the body of the PayPal IPN message

productionboolean

in production mode if true; in sandbox mode if false

payPalIpnToOrder(body) ⇒ *

Convert PayPal IPN message to an order object. The field custom in the order contains the order form fields.

Kind: global function
Returns: * -

an order object with all IPN fields


Category: PayPal

ParamTypeDescription
bodystring

POST body as PayPal sends to IPN endpoint

=== © 2021 Dellariva Solutions

Keywords

FAQs

Last updated on 05 Nov 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc