In-store and online
Authentication
Errors
Stronghold.Pay.js
Charge Authorization
BalanceTransfers
Charges
Customers
PayLinks
PaymentSources
Reports
Sandbox
Settlements
Tips
Utility
Models
Countries
Currencies

Stronghold.Pay.js

Use Stronghold.Pay.js’ APIs to link customer information, verify payment method details, and easily accept payments online and in-store at point of sale (POS).

Stronghold.Pay.js tokenizes customer payment details, ensuring sensitive banking information does not touch your servers, reducing the compliance burden.

Using Stronghold.Pay.js on your website

To use Stronghold.Pay.js, start by including the following script inside the head tags on your pages.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://api.strongholdpay.com/v2/js"></script>

Once included,Stronghold.Pay will be available for use in your Javascript code. You will need to use your publishable API key to create a new instance. The publishable API key is safe to include client-side.

var strongholdPay = Stronghold.Pay({
	publishableKey: 'pk_sandbox_...',
	environment: 'sandbox', // Or live
});

Ensure you are using the correct environment sandbox or live for the publishable key you have specified.

Customer Token Generation

A customer token is required in order to make requests to our JS library. This token has a 30 minute life span and is customer specific.

Please follow the API documentation to discover how a customer token is generated.

Real-Time Transaction Intelligence

By including the Stronghold.Pay.js script on every page of your website, not just the checkout page, Stronghold is better able to detect user behavior that may indicate fraudulent activity. This helps to protect you from unwanted returns and chargebacks.

The Stronghold.Pay methods

Onboarding

Charges

Arguments description

customerToken

string

The generated customer token retrieved from the API.

options

The options related to method called.

onSuccess

function (data)

A callback method called once the action is performed successfully.

The type of the data returned is specific to the method called:

Method Returned type Description
addPaymentSource Payment source The newly created payment source
updatePaymentSource Payment source The updated payment source
charge Charge The newly created charge
tip Tip The newly created tip

onExit

function

A callback method called when the action is excited by the customer.

onError

function(error)

A callback method called when an error occurs and is handled by the Stronghold Pay element.

An Error object is returned.

onReady

function

A callback method called when the Stronghold Pay element is ready and shown to the customer.

paymentSourceId

string

Required for the updatePaymentSource method.

The ID of a payment source which belongs to the customer.

authorizeOnly

boolean [Optional]

The charge or tip is created as captured unless authorizeOnly is set to true. A call to the Capture Authorized Charge can be used subsequently to capture the authorized charge.

charge

object

Required for the charge method.

The charge details needed for the creation of a charge.

charge.amount

number

The amount of the charge.

charge.paymentSourceId

string

The payment source ID to use for the charge creation.

charge.externalId

string [Optional]

The payment source ID to use for the charge creation.

tip

object

The tip details.

tip.amount

number

The amount of the tip.

tip.beneficiaryName

string

The name of the beneficiary of the tip.

tip.chargeId

string

The original charge the tip is based on.

tip.paymentSourceId

string

The payment source ID to use for the tip creation.

addPaymentSource(customerToken, options)

Use addPaymentSource to initialize and show the payment source linking drop-in, allowing the customer to connect a payment method.

If successful, the result will contain the newly created payment source. The payment source will have already been saved on Stronghold’s servers.

Example

var customerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6I...';
strongholdPay.addPaymentSource(customerToken, {
	onSuccess: function (paymentSource) { ... }
	onExit: function () { ... }
	onError: function (err) { ... }
});

updatePaymentSource(customerToken, options)

Use updatePaymentSource to update a customer’s existing payment source when a login is required by the financial institution.

This is required when attempting to authorize a charge and the financial institution wishes to reauthenticate/reauthorize the bank link, and the Stronghold API returns the payment_source_login_required error code.

Example

var customerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6I...';
strongholdPay.updatePaymentSource(customerToken, {
	paymentSourceId: 'payment_source_GyaKTRI1RqDyvTRMNo4UFOak',
	onSuccess: function (paymentSource) { ... }
	onExit: function () { ... }
	onError: function (err) { ... }
});	

charge(customerToken, options)

Use charge to initiate and show the charge authorization drop-in, which allows the customer to review and authorize a payment to the merchant.

If successful, the result will be the newly created charge. It is recommended that the charge ID is used to check the charge’s status via the API from a back-end server.

Example

var customerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6I...';
strongholdPay.charge(customerToken, {
	authorizeOnly: false, // Set to true to not capture the charge immediately and create it as `authorized`.
	charge: {
		type: 'bank_debit_cnp',
		amount: 4995, // $49.95
		currency: 'usd',
		paymentSourceId: 'payment_source_XpPw9ylVlqRcun-bFWp6dkY8',
		externalId: 'e34685512545',
	}
	onSuccess: function (charge) { ... }
	onExit: function () { ... }
	onError: function (err) { ... }
});

tip(customerToken, options)

Use tip to initiate and show the tip authorization drop-in, which allows the customer to review and authorize a tip to the merchant.

If successful, the result will be the newly created tip. It is recommended that the tip ID is used to check the tip’s status via the API from a back-end server.

Example

var customerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6I...';
strongholdPay.charge(customerToken, {
	authorizeOnly: false, // Set to true to not capture the charge immediately and create it as `authorized`.
	tip: {
		amount: 300, // $3
		currency: 'usd',
		paymentSourceId: 'payment_source_XpPw9ylVlqRcun-bFWp6dkY8',
		chargeId: 'charge_UzI1NiIsInR5cCI6IIsI',
	}
	onSuccess: function (tip) { ... }
	onExit: function () { ... }
	onError: function (err) { ... }
});