Processes a charge on a specified payment method under the merchant's account.
The Charge a Payment Method endpoint allows you to process a payment by charging a specified payment method under the merchant's account. This operation authorizes and captures funds in a single transaction, creating a transaction record with type = charge in the system.
This endpoint is used for processing immediate payments where both authorization and capture occur simultaneously. It's suitable for most standard payment processing scenarios, such as one-time purchases in e-commerce applications.
Usage Scenarios
E-commerce Purchases: Charging a customer's credit card for an online order.
Service Payments: Collecting payment for services rendered immediately after completion.
Subscription Setups: Charging an initial fee when a customer subscribes to a service.
Response Structure
| Code | Response | Reason |
|---|---|---|
| 200 | Success | A successful response returns a transaction object containing details about the processed charge, including transaction ID, type, status, amount, currency, payment method ID, customer ID, creation timestamp, and any metadata provided. |
| 400 | Bad Request | The request was invalid due to incorrect parameters. |
| 401 | Unauthorized | Authentication failed due to invalid or missing authentication tokens. |
| 422 | Unprocessable Entity | Validation errors occurred, such as missing required fields or invalid values. |
| 500 | Internal Server Error | An unexpected error occurred on the server. |
Detailed Parameter Descriptions
payment_method_id:Obtain this ID by creating a payment method using the POST /payment-methods endpoint or retrieving existing payment methods associated with a customer.
total: The amount to charge, specified in the smallest currency unit. Ensure accuracy to avoid incorrect charges.
pre_auth: When true, the transaction is a pre-authorization, holding the specified amount without capturing it. Useful when the final amount may change or services are delivered later.
idempotency_id: Use a unique identifier (e.g., a UUID) to prevent duplicate transactions in case of retries.
meta: Include additional information such as Level 2 Processing data (tax, poNumber, shippingAmount), custom fields, and descriptors.
meta.lineitems: is restricted to the ID, Quantity, Price, Item name, and Description.
Usage Notes
Level 2 Processing: To qualify for Level 2 Processing rates, include tax, poNumber, and shippingAmount in the meta object. The tax amount must be between 0.1% and 30% of the total.
Idempotency: It's crucial to use idempotency_id to prevent duplicate charges. If a request with the same idempotency_id is received, the API returns the original transaction.
Error Handling: Implement robust error handling to capture and address issues promptly. Check for validation errors and provide meaningful feedback to users.
Webhooks: This endpoint triggers the create_transaction webhook. Ensure your application handles webhooks to stay synchronized with transaction statuses.
Additional Considerations
Settlement Timing: Funds are typically captured immediately, but actual settlement to the merchant's account may vary based on banking processes.
Fraud Prevention: Utilize security measures such as AVS (Address Verification System) and CVV checks to reduce the risk of fraudulent transactions.
Recurring Payments: For recurring charges, store the payment_method_id securely and comply with all applicable regulations regarding the storage of payment information.
PCI Compliance: Ensure your application complies with PCI DSS (Payment Card Industry Data Security Standard) when handling payment data.
