This guide provides step-by-step instructions for integrating Pagsmile into your website for seamless payment processing. Pagsmile offers robust features and security measures to ensure smooth transactions for your customers.
Prerequisites
Pagsmile Account: Ensure you have signed up for a Pagsmile account. You will need your app_id and public_key provided by Pagsmile.
Environment: Access to your website's HTML and JavaScript files for integration.
Step 1: HTML Form Structure
Below is the basic HTML code to create the credit card input fields.
Add the Pagsmile JavaScript library to the <head> section of your HTML file. This script is necessary to initialize and interact with the Pagsmile API.
Step 3: Initialize Pagsmile
After the page loads and the Pagsmile script has loaded, initialize Pagsmile with your credentials (app_id and public_key) other mandatory parameters. This step prepares Pagsmile for handling payment transactions securely.
pre_auth: boolean (optional) Whether pre-authorization is enabled. When set to true, pre-authorization is enabled for payments. Defaults to false.form_id: string (conditional, required for Mexico) The ID of the form element to be used for payment processing. This parameter is required for transactions in Mexico.
form_id: string (conditional, required for Mexico) The ID of the form element to be used for payment processing. This parameter is required for transactions in Mexico.
createOrder Optional Parameters
installments: object (optional) Parameter should be provided if there is installment information is returned by Installment Detail Query endpoint.
phone: string (optional) Mobile phone number
email: string (optional) Personal email address
postal_code:string (optional) Postal code of residential address
payer_id: string (optional) Personal identification number (CPF for Brazil)
address: Object (optional) An optional address object that specifies the country associated with the payment.
country_code: string (optional) A 3-letter ISO country code that specifies the country associated with the payment (e.g., "SWE" for Sweden). If not provided, this field will be omitted.
Step 4: Testing and Deployment
Sandbox Mode: During development and testing, use env: "sandbox". Verify that payments process correctly and error handling works as expected.
Production Mode: Before deploying to production, change the env setting to "prod".