# 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
});
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');
2
# createCharge
# paysly.createCharge(cardElement, tokenData, chargeConfig)
Used to create a charge using Stripe Elements.
# Arguments
- a "Stripe Elements" card element (described above)
- token data (pass in
{}
if you don't need to use any token data) - a charge configuration object, which accepts all stripe charge creation 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
- Stripe paymentMethodData, including a Stripe elements card element, and a
type
. - customer data (pass in
{}
if you don't need to use any customer data) - Stripe subscription information, except for
customer
- (a customer will be created based on your customer data).
# Returns
- A promise. If successful, the promise will be resolved with a stripe payment intent object, with an added tokenized version fo the object within its
token
property. If rejected, it will contain a stripe error object.
# 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
- A promise. If successful, the promise will be resolved with a stripe payment intent object, with an added tokenized version fo the object within its
token
property. If rejected, it will contain a stripe error object.