This repository contains Salesforce Commerce Cloud (SFCC) cartridges for integrating the PayU payment gateway. These cartridges enable seamless handling of online payments through PayU, supporting multiple payment methods and regional requirements across Latin America (LATAM).
The PayU integration provides a comprehensive payment solution for SFCC stores, supporting:
- Multiple payment methods (Credit Cards, Cash payments, Bank transfers, Yape, etc.)
- Multi-country support across LATAM (Argentina, Brazil, Chile, Colombia, Mexico, Panama, Peru)
- Payment processing including authorization, capture, void, and refund operations
- Webhook handling for real-time payment status updates
- Custom job schedulers for payment management
- Payment Methods: Credit card processing, cash payments, bank transfers, and local payment methods
- Multi-regional Support: Configurable for different LATAM countries with localized payment options
- Payment Operations: Authorization, immediate/delayed capture, void, partial/full refunds
- Webhook Integration: Real-time payment status notifications
- Job Scheduling: Automated payment processing jobs for capture, void, and refund operations
- Responsive UI: Modern checkout interface with PayU payment forms
├── cartridges/int_payu/ # Main PayU integration cartridge
│ ├── cartridge/
│ │ ├── controllers/ # SFCC controllers for checkout and payment
│ │ ├── models/ # Business logic models
│ │ ├── scripts/ # Backend scripts and helpers
│ │ │ ├── jobs/ # Payment job scripts (capture, void, refund)
│ │ │ ├── helpers/ # PayU integration helpers
│ │ │ └── hooks/ # Payment hooks and webhooks
│ │ ├── forms/ # Payment form definitions
│ │ ├── templates/ # Frontend templates
│ │ ├── client/ # Frontend assets (JS/SCSS)
│ │ └── static/ # Compiled static assets
│ ├── package.json # Cartridge hooks configuration
│ └── steptypes.json # Custom job step definitions
├── metadata/ # SFCC metadata configuration
│ ├── jobs.xml # Job definitions for payment operations
│ ├── services.xml # Service definitions
│ └── sites/ # Site-specific configurations per country
├── package.json # Main build configuration
├── webpack.config.js # Frontend build configuration
└── README.md # This file
The project uses a modern build system with Webpack and SGMF (StoreFront Reference Architecture) scripts.
- Node.js (version 14 or higher)
- npm or yarn
- Salesforce Commerce Cloud Business Manager access
- PayU merchant account and API credentials
- Clone the repository:
git clone <repository-url>
cd link_payu
- Install dependencies:
npm install
- Lint code:
npm run lint
- Fix linting issues:
npm run lint:fix
- Compile JavaScript:
npm run compile:js
- Compile SCSS:
npm run compile:scss
- Upload cartridge:
npm run uploadCartridge
- Upload files:
npm run upload
- Make your code changes in the appropriate cartridge files
- Run linting:
npm run lint:fix
- Compile assets:
npm run compile:js && npm run compile:scss
- Upload to sandbox:
npm run uploadCartridge
Create a dw.json
file in the project root (this file is gitignored for security):
{
"hostname": "your-sandbox-hostname.demandware.net",
"username": "your-username",
"password": "your-password",
"code-version": "version-name"
}
- Prepare the cartridge:
npm run compile:js
npm run compile:scss
npm run lint
- Upload to sandbox:
npm run uploadCartridge
-
Configure Business Manager:
- Add
int_payu
to your cartridge path - Import metadata (jobs.xml, services.xml, site configurations)
- Configure PayU credentials in Site Preferences
- Set up payment methods and processors per site
- Add
-
Configure PayU Settings:
- API Key, API Login, Merchant ID
- Account IDs for each country
- Payment method configurations
- Webhook endpoints
- Create a code version in Business Manager
- Upload the cartridge to the production instance
- Import metadata configurations
- Update cartridge path in production
- Configure production PayU credentials
- Test payment flows thoroughly
-
Code Quality:
- All lint checks pass:
npm run lint
- No console.log statements in production code
- Proper error handling and logging
- Security best practices followed
- All lint checks pass:
-
Documentation:
- Code is well-commented
- API documentation is complete
- Installation guide is provided
- Configuration instructions are clear
-
Testing:
- All payment methods tested
- Error scenarios handled properly
- Cross-browser compatibility verified
- Mobile responsiveness confirmed
-
Compliance:
- PCI DSS compliance maintained
- No sensitive data logged
- Proper data encryption
- GDPR compliance if applicable
-
Package the cartridge:
- Create a clean build:
npm run compile:js && npm run compile:scss
- Remove development files and node_modules
- Create a ZIP file of the cartridges directory
- Create a clean build:
-
Prepare documentation:
- Installation guide
- Configuration manual
- API documentation
- Testing scenarios
-
Submit to Salesforce:
- Login to Salesforce Partner Portal
- Navigate to App Exchange submission
- Upload cartridge package and documentation
- Fill out compliance questionnaire
- Submit for review
-
Review Process:
- Salesforce security review (2-4 weeks)
- Functional testing by Salesforce team
- Address any feedback or issues
- Final approval and publication
-
Enable debug mode:
- Set
PAYU_DEBUG=true
in site preferences - Enable detailed logging in Business Manager
- Set
-
Log locations:
- Custom logs:
Logs > Custom Logs > payu-debug
- Error logs:
Logs > Error Logs
- Service logs:
Logs > Service Logs
- Custom logs:
-
Common debug points:
// Add to PayU helper functions
var Logger = require('dw/system/Logger');
var logger = Logger.getLogger('payu-debug', 'payu');
logger.info('Payment request: {0}', JSON.stringify(paymentRequest));
-
Use PayU test credentials:
- Test API keys and merchant accounts
- Use test credit card numbers
- Verify different payment scenarios
-
Test scenarios:
- Successful payments
- Failed payments
- Network timeouts
- Webhook processing
- Refund operations
-
Webhook testing:
- Use ngrok for local webhook testing
- Monitor webhook logs in Business Manager
- Verify webhook signature validation
-
Payment failures:
- Check PayU credentials configuration
- Verify API endpoint URLs
- Review payment request format
- Check country-specific requirements
-
Webhook issues:
- Verify webhook URL accessibility
- Check signature validation
- Review webhook payload format
- Ensure proper HTTP response codes
-
Build issues:
- Clear node_modules:
rm -rf node_modules && npm install
- Check Node.js version compatibility
- Verify webpack configuration
- Review SGMF scripts version
- Clear node_modules:
- Monitor payment processing times
- Track API response times
- Review error rates and patterns
- Analyze payment success rates
- PayU Documentation: https://developers.payulatam.com/latam/en/docs/tools/shopping-cart-plugins/salesforce.html
- SFCC Documentation: https://documentation.b2c.commercecloud.salesforce.com/
- Technical Support: Contact PayU technical support for payment gateway issues
- SFCC Support: Use Salesforce Support portal for platform-related issues
- Follow the existing code style and patterns
- Add unit tests for new functionality
- Update documentation for any changes
- Ensure all builds pass before submitting PRs
- Follow semantic versioning for releases