Web Form Integration
Payments app extends Frappe Web Forms with seamless payment acceptance capabilities.
Payment Fields in Web Form
Custom fields added to Web Form doctype:
| Field | Type | Purpose |
|---|---|---|
payments_tab |
Tab Break | Payments section in form |
accept_payment |
Check | Enable payment for this form |
payment_gateway |
Link | Select payment gateway |
payment_button_label |
Data | Custom button text (default: "Buy Now") |
amount_based_on_field |
Check | Dynamic amount from field |
amount_field |
Select | Field to pull amount from |
amount |
Currency | Fixed payment amount |
currency |
Link | Transaction currency |
Payment Web Form Override
The PaymentWebForm class extends standard web form behavior:
class PaymentWebForm(WebForm):
def validate_payment_amount(self):
"""Validate payment amount configuration."""
if self.amount_based_on_field and not self.amount_field:
frappe.throw("Please select an Amount Field.")
if not flt(self.amount) > 0:
frappe.throw("Amount must be greater than 0.")
def get_payment_gateway_url(self, doc):
"""Generate payment URL for form submission."""
Configuration Pattern:
- Enable "Accept Payment" in web form
- Select payment gateway
- Configure amount (fixed or field-based)
- Set currency
- Customize button label
Last updated 2 months ago
Was this helpful?