Skip to main content

Security Libraries

Sopague provides specialized libraries to ensure maximum security in your payment transactions.


Available libraries

Integrated solution

The Sopague Library is our most complete solution, combining RSA encryption and anti-fraud in a single JavaScript library.

Key features:

  • RSA-OAEP encryption with SHA-256
  • Built-in anti-fraud system
  • Zero dependencies
  • Lightweight and fast (~5KB minified)
  • Compatible with all modern browsers

See full documentation →


Quick start guide

1. Choose your library

For new projects: We recommend the Sopague Library because it provides integrated functionality.

For existing projects: You can continue using the dedicated libraries (Anti-fraud or 3DS).

2. Installation

<!-- To obtain the CDN URL for the Sopague library, contact support -->
<script src="https://cdn.exemplo.com/sopague/sopague.min.js"></script>

<!-- Or download and reference it locally -->
<script src="/libs/sopague-integration-library-1.0.0.min.js"></script>

3. Basic setup

// Set public key
Sopague.setEncryptPublicKey('your-public-key-here');

// Initialize anti-fraud
const sessionId = Sopague.initAntiFraud('your-session-id');

// Encrypt data
const encrypted = await Sopague.encryptCard('card-number');

Practical examples

Full e-commerce

See full example →

A practical integration example in an e-commerce system with:

  • Payment form
  • Data validation
  • Card encryption
  • Anti-fraud system
  • Responsive UI

NextJS integration

See React/NextJS example →

Custom hook and payment component for React/NextJS applications with:

  • TypeScript
  • State management
  • Error handling
  • Form validation

Vanilla JavaScript

See Vanilla JS example →

Simple HTML + JavaScript implementation for:

  • Static pages
  • Quick prototypes
  • Legacy system integrations

Advanced configuration

Environment variables

# RSA public key
NEXT_PUBLIC_RSA_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----..."

# Organization ID
NEXT_PUBLIC_ORG_ID="your_organization_id"

# Library version
NEXT_PUBLIC_SOPAGUE_VERSION="1.0.0"

Server configuration

// Example endpoint to process payments
app.post('/api/payments', async (req, res) => {
const { encryptedCard, antiFraudSessionId, amount } = req.body;

// Validate required security data
if (!encryptedCard || !antiFraudSessionId) {
return res.status(400).json({
message: 'Dados de segurança obrigatórios'
});
}

// Process payment with the SoPague API
// ...
});

Tests and validation

Encryption test

async function testEncryption() {
const testCard = '4111111111111111';
const encrypted = await Sopague.encryptCard(testCard);
console.log('Encryption test:', encrypted ? '✅ Success' : '❌ Failure');
}

Anti-fraud test

function testAntiFraud() {
const sessionId = Sopague.initAntiFraud('test-session');
const currentSession = Sopague.getAntiFraudSessionId();
console.log('Anti-fraud test:', currentSession ? '✅ Success' : '❌ Failure');
}

Compatibility

BrowserMinimum versionStatus
Chrome37+✅ Supported
Firefox34+✅ Supported
Safari11+✅ Supported
Edge79+✅ Supported
Opera24+✅ Supported

Requirements:

  • HTTPS required (Web Crypto API)
  • JavaScript enabled
  • Promise support

Support and resources

Additional documentation

Useful resources


Next steps

  1. Choose the library that best fits your needs
  2. Implement following the provided examples
  3. Test in a development environment
  4. Configure environment variables
  5. Integrate with your Payments API
  6. Monitor behavior in production

For questions or support, contact our technical team.