Stronghold.Pay.js
In-store and online
Charge Authorization
PaymentSources
BalanceTransfers
Customers
Invoices
Merchants
PayLinks
Charges
Reports
Sandbox
Settlements
Tips
Utility
Models
Authentication
Countries
Currencies
v1 Reference (Deprecated)

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({
	environment: 'sandbox',
	publishableKey: 'pk_sandbox_Y2A2NmJcYzItZT40anb2Nm'
});

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

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.

strongholdPay.addPaymentSource(customerToken, options)


Use strongholdPay.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 source’s ID and a display-friendy name. The source will have already been saved on Stronghold’s servers.

var customerToken = 'ctok_qFUVDPlLII0YJc2KDJm.u4Wt';
strongholdPay.addPaymentSource(customerToken, {
	paymentSourceTypes: ['bank'],
	onSuccess: function (source) { ... }
	onExit: function () { ... }
	onError: function (err) { ... }
});
											 

options object:

Field Type Description Example
paymentSourceTypes string[] A list of types of sources the customer can add. [bank]

result object:

Field Type Description Example
id string The payment source ID psrc_GyaKTRI1RqDyvTRMNo4UFOak
label string A display label for the source Bank of America checking ending 6152
type string The type of source the customer linked. bank

strongholdPay.updatePaymentSource(customerToken, options)


Use strongholdPay.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.

var customerToken = 'ctok_qFUVDPlLII0YJc2KDJm.u4Wt';
strongholdPay.updatePaymentSource(customerToken, {
	paymentSourceId: 'psrc_GyaKTRI1RqDyvTRMNo4UFOak',
	onSuccess: function (source) { ... }
	onExit: function () { ... }
	onError: function (err) { ... }
});
											 

options object:

Field Type Description Example
paymentSourceId string The ID of the payment source to update. psrc_GyaKTRI1RqDyvTRMNo4UFOak

result object:

Field Type Description Example
id string The payment source ID psrc_GyaKTRI1RqDyvTRMNo4UFOak
label string A display label for the source Bank of America checking ending 6152
type string The type of source the customer linked. bank

strongholdpay-charge(customerToken, options)


Use strongholdPay.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 contain the newly created charge’s ID and status. It is recommended that the charge ID is used to check the charge’s status via the API from a back-end server. The charge is created as captured unless authorizeOnly is set to true.

var customerToken = 'ctok_qFUVDPlLII0YJc2KDJm.u4Wt';
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: 'psrc_XpPw9ylVlqRcun-bFWp6dkY8',
		externalId: 'e34685512545',
	}
	onSuccess: function (charge) { ... }
	onExit: function () { ... }
	onError: function (err) { ... }
});

options object:

Field Type Description Example
authorizeOnly bool True to not capture the charge immediately and create it as `authorized, otherwise, false. false
charge.type string The type of charge to make. bank_debit_cnp
charge.amount int The amount to charge, specified in the smallest divisible currency unit. For example, number of cents of United States dollar. 4995
charge.currency string The currency for the charge usd
charge.paymentSourceId string The ID of the payment source to charge. psrc_XpPw9ylVlqRcun-bFWp6dkY8
externalId string (optional) A merchant-specific external ID (e.g. a merchant order ID). e34685512545

result object:

Field Type Description Example
id string The charge ID chrg_RFInMTnYkNQh6.UdiUqQwYh6
status string The charge status captured

A charge created from a Stronghold.Pay.js drop-in will always be captured unless you set authorizeOnly to true. A call to the Capture Authorized Charge can be used subsequently to capture the authorized charge.