This repository provides comprehensive Pay by Link implementations using the Global Payments GP API across six programming languages. Pay by Link allows merchants to create secure payment links that can be shared with customers via email, SMS, or other channels, enabling remote payments without requiring customers to visit a physical location or website.
- .NET Core - (Preview) - ASP.NET Core web application
- Go - (Preview) - Go HTTP server application
- Java - (Preview) - Jakarta EE servlet-based web application
- Node.js - (Preview) - Express.js web application
- PHP - (Preview) - PHP web application
- Python - (Preview) - Flask web application
- Payment Link Creation - Generate secure, time-limited payment links
- Multi-Currency Support - EUR, USD, GBP currency support
- Input Validation - Comprehensive validation and sanitization
- Error Handling - Standardized error responses across all languages
- GP API Integration - Direct integration with Global Payments sandbox/production APIs
- Consistent API - Identical
/create-payment-linkendpoint across all languages - Environment Configuration - Secure credential management with
.envfiles - Responsive Frontend - HTML forms with real-time validation
- Production Ready - Comprehensive error handling and logging
- OWASP Compliant - Input sanitization and security best practices
Navigate to any implementation directory:
cd nodejs/ # Node.js with Express
cd python/ # Python with Flask
cd php/ # Native PHP
cd java/ # Java with Jakarta EE
cd dotnet/ # .NET Core
cd go/ # Go HTTP serverCopy the sample environment file and add your GP API credentials:
cp .env.sample .envEdit .env with your actual GP API credentials:
# GP API App Credentials (required for Pay by Link)
GP_API_APP_ID=your_app_id_here
GP_API_APP_KEY=your_app_key_here
# Environment (sandbox or production)
GP_API_ENVIRONMENT=sandboxNode.js:
npm installPython:
pip install -r requirements.txtPHP:
composer installJava:
mvn clean installGo:
go mod download.NET:
dotnet restoreNode.js:
npm start
# or
node server.jsPython:
python server.pyPHP:
php -S localhost:8000 -t .Java:
mvn cargo:runGo:
go run main.go.NET:
dotnet runVisit http://localhost:8000 and create a test payment link:
- Enter amount in cents (e.g., 1000 = $10.00)
- Select currency (EUR, USD, GBP)
- Provide reference, name, and description
- Click "Create Payment Link"
- Copy the generated payment link to share with customers
Returns configuration data for client-side use:
{
"success": true,
"data": {
"environment": "sandbox",
"supportedCurrencies": ["EUR", "USD", "GBP"],
"supportedPaymentMethods": ["CARD"]
}
}Creates a new payment link. Required fields:
amount(integer) - Amount in centscurrency(string) - Currency code (EUR/USD/GBP)reference(string) - Merchant referencename(string) - Payment name/titledescription(string) - Payment description
Success Response:
{
"success": true,
"message": "Payment link created successfully! Link ID: lnk_xxx",
"data": {
"paymentLink": "https://pay.sandbox.globalpay.com/link/lnk_xxx",
"linkId": "lnk_xxx",
"reference": "ORDER-123",
"amount": 1000,
"currency": "USD"
}
}Error Response:
{
"success": false,
"message": "Payment link creation failed",
"error": {
"code": "MISSING_REQUIRED_FIELDS",
"details": "Missing required fields. Received: amount, currency"
}
}| Brand | Number | CVV | Expiry |
|---|---|---|---|
| Visa | 4263 9826 4026 9299 | 123 | Any future |
| Mastercard | 5425 2334 2424 1200 | 123 | Any future |
Pay by Link generates a hosted payment page. Test cards work when completing payment through the generated link in sandbox mode.
All implementations create payment links with these settings:
- Type: PAYMENT (single-use payment)
- Usage Mode: SINGLE (one-time use)
- Usage Limit: 1
- Expiration: 10 days from creation
- Channel: CNP (Card Not Present)
- Country: GB (Great Britain)
- Shipping: YES with 0 amount
- Payment Methods: CARD only
- Notifications:
- Return URL:
https://www.example.com/returnUrl - Status URL:
https://www.example.com/statusUrl - Cancel URL:
https://www.example.com/returnUrl
- Return URL:
All implementations sanitize the reference field using regex pattern [^\w\s\-#] to remove potentially harmful characters, allowing only:
- Word characters (letters, digits, underscore)
- Spaces, hyphens, and hash symbols
- Limited to 100 characters maximum
- Amount: Must be positive integer (cents)
- Currency: Must be one of EUR, USD, GBP
- Name: Trimmed and limited to 100 characters
- Description: Trimmed and limited to 500 characters
- Reference: Sanitized and limited to 100 characters
Standardized error codes across all implementations:
MISSING_REQUIRED_FIELDS- Required fields missing from requestINVALID_AMOUNT- Amount is not a positive integerTOKEN_GENERATION_ERROR- Failed to generate GP API access tokenAPI_ERROR- GP API request failedINVALID_RESPONSE- Unexpected response format from GP APIUNKNOWN_ERROR- Unexpected system error
- Global Payments Account with GP API credentials
- Development Environment for your chosen language
- Package Manager (npm, pip, composer, maven, dotnet, go)
- GP API Credentials:
- App ID (
GP_API_APP_ID) - App Key (
GP_API_APP_KEY)
- App ID (
Set production environment variables:
GP_API_APP_ID=your_production_app_id
GP_API_APP_KEY=your_production_app_key
GP_API_ENVIRONMENT=production- Use HTTPS for all production deployments
- Validate inputs on both client and server side
- Log transactions for audit and debugging
- Monitor failed requests for potential issues
- Rate limit the API endpoints
- Secure credential storage using environment variables or secrets management
Update notification URLs in production:
notifications: {
return_url: "https://yourdomain.com/payment-return",
status_url: "https://yourdomain.com/payment-webhook",
cancel_url: "https://yourdomain.com/payment-cancel"
}- SDK Implementations: PHP, Java, .NET (use official Global Payments SDKs with
PayByLinkService) - Direct API Implementations: Python, Node.js, Go (use direct HTTP calls to
https://apis.sandbox.globalpay.com/ucp/links) - Consistency: All implementations achieve identical functionality regardless of approach
SDK Approach (PHP, Java, .NET):
- Uses official Global Payments SDK packages (
globalpayments/api,globalpayments-sdk,GlobalPayments.Api) - SDK handles authentication token generation automatically
- Provides type-safe
PayByLinkDataobjects andPayByLinkServiceclasses - Built-in error handling with SDK-specific exception types
- Automatic API endpoint routing based on environment configuration
Direct API Approach (Python, Node.js, Go):
- Makes raw HTTP POST requests to Global Payments REST endpoints
- Handles authentication token generation manually
- Constructs JSON payloads directly
- Processes HTTP responses and error handling manually
- Examples: Python (requests), Go (net/http), Node.js (fetch/axios)
All implementations return identical JSON response formats to ensure consistent client-side handling across different backend languages.
Each implementation includes try-catch blocks with specific error categorization, ensuring consistent error reporting and debugging capabilities.
- π Developer Portal β developer.globalpayments.com
- π¬ Discord β Join the community
- π GitHub Discussions β github.com/orgs/globalpayments/discussions
- π§ Newsletter β Subscribe
- πΌ LinkedIn β Global Payments for Developers
Have a question or found a bug? Open an issue or reach out at communityexperience@globalpay.com.
This project is licensed under the MIT License - see individual implementation directories for specific license details.