Skip to main content

SDK Javascript

Integration

tip

You must include aplazame.js on the button and checkout pages.

<script
src="https://cdn.aplazame.com/aplazame.js?public-key=api_public_key&sandbox=true"
async defer>
</script>
ParameterTypeRequiredDescription
public-keystringYesYour public key.
sandboxbooleanYesSet if the requests will be in sandbox mode (true) or production (false).
caution

The value of sandbox must be false for production environment

Check available financing products

To display the Aplazame payment button based on the products configured in your account

<button type="button"
data-aplazame-button
data-amount="12050"
data-currency="EUR"></button>

<div data-aplazame-payment-info="">
Information about payment with Aplazame that will appear and be hidden with the button
</div>
ParameterTypeRequiredDescription
selectorcss selectorNoCSS selector to display/hide Aplazame’s payment method.
amountdecimalYesQuantity to be financed.
currencyISO 4217YesThe currency code of the order.

Check Instalments

To display the payment button with Aplazame based on the limits set in your account

The previous examples are for instalments (by default) type.

Check Pay in 15 days

To display the payment button with Aplazame based on the limits set in your account

To check "Pay later" product, yo need add data-product-type="pay_later", or product: { type: 'pay_later' } field:

<button type="button"
data-aplazame-button
data-amount="12050"
data-currency="EUR"
data-product-type="pay_later"></button>

<div data-aplazame-payment-info="">
Information about payment with Aplazame that will appear and be hidden with the button
</div>

Check Pay in 4

To display the payment button with Aplazame based on the limits set in your account

To check "Pay in 4" product, yo need add data-product-type="pay_in_4", or product: { type: 'pay_in_4' } field:

<button type="button"
data-aplazame-button
data-amount="12050"
data-currency="EUR"
data-product-type="pay_in_4"></button>

<div data-aplazame-payment-info="">
Information about payment with Aplazame that will appear and be hidden with the button
</div>

Checkout start

Here you can see how to integrate the SDK

<script>
(window.aplazame = window.aplazame || []).push(function (aplazame)
// This function is executed when aplazame.js is ready

aplazame.checkout(checkout_id,
// callbacks ...
)
)
</script>

Show result

;(window.aplazame = window.aplazame || []).push(function (aplazame) {
// This function is executed when aplazame.js is ready


aplazame.checkout(checkout_id,
onStatusChange (result_status) {
console.log('IMPORTANT: THE CHECKOUT IS STILL OPEN')

switch (result_status) {
case 'success':
console.log('the checkout has been completed successfully')
break
case 'pending':
console.log('the checkout has been completed but is pending validation')
break
case 'ko':
console.log('the payment process has been rejected by Aplazame')
break
}
},
onClose (result_status) {
switch (result_status) {
case 'success': // equivalent to onSuccess
console.log('the checkout has been completed successfully')
break
case 'pending': // equivalent to onPending
console.log('the checkout has been completed but is pending validation')
break
case 'error': // equivalent to onError
console.log('an error occurred while loading the checkout')
break
case 'dismiss': // equivalent to onDismiss
console.log('the user closed the checkout without completing it')
break
case 'ko': // equivalent to onKO
console.log('the payment process has been rejected by Aplazame')
break
}
})
})
ParameterTypeRequiredDescription
onStatusChangefunctionNofunction onStatusChange(status) { /**/} Function to be called when the Checkout changes its status. Possible statuses: success, pending, ko. (When sending this signal, the checkout will remain open until a callback is made, as mentioned below).
onClosefunctionNoFunction to be called when the Checkout closes. function onClose(status) { /**/} Possible statuses: success, pending, ko, dismiss.
onSuccessfunctionNoFunction to be called when the payment is completed. When defining this function the success_url value is ignored.
onPendingfunctionNoFunction to be called when the payment is pending confirmation. When defining this function the pending_url value is ignored.
onKOfunctionNoFunction to be called when the payment is denied. When defining this function the ko_url value is ignored.
onErrorfunctionNoFunction to be called when an error occurs. When defining this function the error_url value is ignored.
onDismissfunctionNoFunction to be called when the user chooses to return to the store. When defining this function the dismiss_url value is ignored.