Payment Processing
Get Public Key
Retrieves the public key for encrypting credit card information
GET
Get Public Key
Overview
This endpoint retrieves the current public key used for encrypting credit card data before sending it to Firmly’s payment endpoints. The key supports multiple formats to accommodate different encryption libraries and platforms.The public key is rotated periodically for security. Always fetch the current key before encrypting payment data rather than caching it for extended periods.
Authentication
This endpoint requires no authentication and is publicly accessible.Query Parameters
string
default:"JWK"
The format of the public key to returnSupported formats:
JWK- JSON Web Key format (default)PEM- Privacy Enhanced Mail formatRSA- PEM using RSAPublicKey format
Response Headers
string
The key identifier (kid) - present for all formats
Response Formats
JWK Format (Default)
Returns a JSON Web Key with the following properties:string
Key identifier/version
string
Key type (always “RSA”)
string
RSA modulus component (Base64URL encoded)
string
RSA exponent component (Base64URL encoded)
string
Key usage (always “enc” for encryption)
PEM Format
Returns the public key in PEM format as plain text:- Content-Type:
text/plain - Key ID available in
x-firmly-kidheader - Standard PEM header/footer with base64 encoded key
RSA Format
Returns the public key in RSA-specific PEM format:- Content-Type:
text/plain - Key ID available in
x-firmly-kidheader - Uses RSA PUBLIC KEY header/footer
Code Examples
Response Examples
JWK Format Response
PEM Format Response
RSA Format Response
Usage with Encryption Libraries
JavaScript (Web Crypto API)
Python (cryptography)
Node.js (node-jose)
Best Practices
Common Use Cases
- Credit Card Encryption: Primary use is for encrypting credit card data for payment endpoints
- Tokenization: Used with payment tokenization endpoints
- Secure Data Transmission: Any sensitive data sent to Firmly payment endpoints
Checkout Flow Integration
This endpoint is the first step in the secure payment flow:1
Fetch Public Key
Call this endpoint to get the current encryption key
2
Encrypt Credit Card
Use the public key to encrypt card data according to your chosen format
3
Complete Order
Send encrypted card data to one of the complete-order endpoints
Complete Example Flow
Related Endpoints
- Complete Order (Simple Cart) - Complete checkout for Simple Cart API
- Complete Order (Full Cart) - Complete checkout for Full Cart API
- Place Order (Simple Cart) - Create cart and order in one call
- Place Order (Full Cart) - Create cart and order with advanced features
Get Public Key