# API

This page documents the functions available on the paysly object returned by initializing the paysly npm module:

const Paysly = require('paysly');
// replace 'pk_test_yourPublicKey-I3gcWtGXPuyWFRk2YD5' with your public key
// from the paysly dashboard
const paysly = await Paysly('pk_test_yourPublicKey-I3gcWtGXPuyWFRk2YD5');
// or
Paysly('pk_test_yourPublicKey-I3gcWtGXPuyWFRk2YD5').then((paysly) => {
  // your code here
});
1
2
3
4
5
6
7
8

If you are looking to do a server-side integration beyond verifying a payment, all of your data is accessible via the stripe APIs and SDKs.

# stripe js functions

Note that in addition to the methods below, the paysly package also exposes all methods of stripe.js. That means you can call stripe functions (like elements()) right on the paysly package:

var elements = paysly.elements();
var cardElement = elements.create('card');
1
2

# createCharge

# paysly.createCharge(cardElement, tokenData, chargeConfig)

Used to create a charge using Stripe Elements.

# Arguments

# Returns

  • A promise. If successful, the promise will be successfully resolved with a charge object, with an added tokenized version of the charge object within its token property. If rejected, it will contain a stripe error object.

# createRecurring

# paysly.createRecurring(paymentMethodData, customerData, subscriptionInformation)

Used to create recurring charge using Stripe Elements.

# Arguments

# Returns

# redirectToCheckout

# paysly.redirectToCheckout(stripeSession)

Used to create a charge using a pre-built checkout page.

# Arguments

# Returns

  • A promise. The success state should never be called (as the user has been redirected). In the case of a failure, the promise will be rejected with a stripe error object.

# validateCheckout

# paysly.validateCheckout()

Used to validate a checkout session. Please see the guide to checkout session verification for instructions on how to use this method.

note

This method only works for payments created with paysly.redirectToCheckout.

# Arguments

  • none

# Returns