lib/Webhooks.js
function(opts) {
    if (!opts) {
      throw new Error.StripeError({
        message: 'Options are required',
      });
    }

    opts.timestamp = Math.floor(opts.timestamp) || Math.floor(Date.now() / 1000);
    opts.scheme = opts.scheme || signature.EXPECTED_SCHEME;

    opts.signature = opts.signature ||
      signature._computeSignature(opts.timestamp + '.' + opts.payload, opts.secret);

    var generatedHeader = [
      't=' + opts.timestamp,
      opts.scheme + '=' + opts.signature,
    ].join(',');

    return generatedHeader;
  }
function(opts) {
    if (!opts) {
      throw new Error.StripeError({
        message: 'Options are required',
      });
    }

    opts.timestamp = Math.floor(opts.timestamp) || Math.floor(Date.now() / 1000);
    opts.scheme = opts.scheme || signature.EXPECTED_SCHEME;

    opts.signature = opts.signature ||
      signature._computeSignature(opts.timestamp + '.' + opts.payload, opts.secret);

    var generatedHeader = [
      't=' + opts.timestamp,
      opts.scheme + '=' + opts.signature,
    ].join(',');

    return generatedHeader;
  }
function ( opts ) { if ( ! opts ) { throw new Error . StripeError ( { message : 'Options are required' , } ) ; } opts . timestamp = Math . floor ( opts . timestamp ) || Math . floor ( Date . now ( ) / 1000 ) ; opts . scheme = opts . scheme || signature . EXPECTED_SCHEME ; opts . signature = opts . signature || signature . _computeSignature ( opts . timestamp + '.' + opts . payload , opts . secret ) ; var generatedHeader = [ 't=' + opts . timestamp , opts . scheme + '=' + opts . signature , ] . join ( ',' ) ; return generatedHeader ; }
Generates a header to be used for webhook mocking

@typedef {object} opts
@property {number} timestamp - Timestamp of the header. Defaults to Date.now()
@property {string} payload - JSON stringified payload object, containing the 'id' and 'object' parameters
@property {string} secret - Stripe webhook secret 'whsec_...'
@property {string} scheme - Version of API to hit. Defaults to 'v1'.
@property {string} signature - Computed webhook signature
Generates a header to be used for webhook mocking