--- title: "Implement Payment Provider with Payment Flow Footer" slug: "implement-payment-method-with-payment-flow-footer" updated: 2024-05-26T19:00:15Z published: 2024-05-26T19:00:15Z canonical: "support.ordercentral.io/implement-payment-method-with-payment-flow-footer" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.ordercentral.io/llms.txt > Use this file to discover all available pages before exploring further. # Implement Payment Method with Payment Flow Footer You may implement a new Payment Method with Flow and Payment Flow Footer: 1. Create an Apex class implements **IPaymentHandler interface** 2. Add the following 2 methods in the new Apex class ``` InitializePaymentResult initialize (PaymentContext context); HandlePaymentResult handle(Payment payment, PaymentContext context); ``` 1. Provide the following property values in method **initialize**: - action.type - action.actionTypeName - action.componentName(= name of flow) - payment.totalAmount Sample of method initialize: ``` global virtual InitializePaymentResult initialize (PaymentContext context) { InitializePaymentResult result = new InitializePaymentResult(); result.payment = new Payment(); result.payment.totalAmount = context.totalAmount; result.action = new PaymentAction(); result.action.type = PaymentAction.ActionType.ScreenFlow; result.action.actionTypeName = String.valueOf(result.action.type); result.action.componentName = 'default_payment_flow'; return result; } ``` 1. The method **handle** should return the result of payment or the error message. Sample of method handle: ``` global virtual HandlePaymentResult handle(Payment payment, PaymentContext context) { HandlePaymentResuLt result = new HandlePaymentResult(); result.success = validatePayment (payment, context); // provide value for error // result.success = false; // result.message = 'test error'; return result; } private Boolean validatePayment (Payment payment, PaymentContext context) { return true; } ``` 1. Create new **Payment Method**: *Setup -> Custom Metadata Types -> Payment Method -> Manage Payment method -> New* 2. Add the new Apex class name to Handler and save 3. Create a **new Flow**: *Setup -> Flows -> New Flow* 4. Set **input and output variables**. 5. Add a **Screen component** in the flow, drag and drop **custom component Custom Flow Footer** to the bottom of the Screen component, the API Name is **PaymentFlowFooter**. 6. **Remove the tick from Show Footer** in Configure Footer, then save the flow with the new Apex class name (same as what you filled in Handler of new Payment Method), and activate the flow. Note - If payment failed, then on the flow modal text of the error will appear and Web_Order__c will not be created. Customer can read the failed message and close modal. - If payment succeeded, Web_Order__c will be created and lookup field Payment__c.Web_Order__c will be populated. - If result.action.type = PaymentAction.ActionType.None, then after clicking “Place Order” button, Web_Order__c will be just created, and the lookup field Payment__c.Web_Order__c will be populated.