Administer > Manage WebSphere Commerce features > Payments subsystem > Configure payment plug-ins > Configuring the Boleto payment method


Customize the Boleto payment method

Create Java classes in the WebSphereCommerceServerExtensionsLogic project to customize the Boleto payment method. For the developer environment, create the classes under the WebSphereCommerceServerExtensionsLogic project. After the development work is done, you can package and deploy the project into the WCS instance.

Sample code is provided to help you customize the Boleto payment method. The sample code is written in adherence to the jBoleto open source libraries. You should review the licences for these packages before using them.

To use a different Boleto generation library, you can use the sample code provided as a model.


Procedure

  1. Copy the required Java jar files to the store library. Download the following files:

    Put the files into the following path:

    • WC_EAR/Stores/WebContent/WEB-INF/lib

    • workspace_dir/wc/Stores.war/WEB-INF/lib

  2. Fix a bug in the jBoleto.jar file. The jBoleto code generates the Linha digitável (human-input number) incorrectly in certain scenarios due to a conversion error. Use the following steps to fix this bug.

    1. Download the jboleto-src.tar.gz file from the Boleto Web site and unzip it.

    2. Find the file JBoletoBean.java file, located in the source code under the path src, in the package org\jboleto.

    3. Search for code that contains replace or replaceAll String methods. This section should be in the getValorTitulo() method String.

    4. Replace the following string:

      replace(".","");
      

      with

      replace("\\.","");
      

      For example, you would change this:

      valor = valor.replace(",","").replace(".","");
      

      to the following:

      valor = valor.replace(",","").replace("\\.","");
      

    5. Compile the changed code, and update the JBoletoBean.class to the jBoleto.jar.

  3. Write the class used to calculate the due date. In the com.ibm.stdwip.commerce.order.commands package, create the task command based on the attached sample files, CalculateDueDateCmdImpl.java and CalculateDueDateCmd.java, then implement the logic of calculating the due date. Usually, the logic is to use the current date plus the "days_pay_boleto" configured when you configure the merchant to access the Boleto payment method.

  4. Write the logic used to read merchant properties that you will when you configure the merchant to access the Boleto payment method. In the com.ibm.stdwip.commerce.payment.boleto package, create the classes based on the attached sample files, MerchantProperties.java and PopulateMerchantProperties.java. These files are used to read the merchant properties when you configure the merchant to access the Boleto plug-in.

    BoletoInterfaceBean.java

    A value object to store the information used to generate the Boleto form

    GenerateBoletoForm.java

    Used to generate the Boleto form by calling the JBoleto API

  5. Write a scheduler command to update the payment on Websphere Commerce, according to the results of the Boleto payment processing from the bank. Write the command based on the attached sample files, BoletoPaymentOrderStatusUpdateCmd.java and BoletoPaymentOrderStatusUpdateCmdImpl.java. These sample files provide a simple example to demonstrate how to update the order status. You need to customize them based on the actual bank interface and reliability requirements.

  6. After the command is ready, change the struts-config-ext.xml of the SiteAdministration.

    1. Open the struts-config-ext.xml file located in the following path:

    2. Add the following action mapping:

      <action
             parameter="com.ibm.commerce.order.scheduled.commands.BoletoPaymentOrderStatusUpdateCmd"
              path="/BoletoPaymentOrderStatusUpdate" type="com.ibm.commerce.struts.BaseAction">        
      <set-property property="https" value="0:0"/>        
      <set-property property="authenticate" value="0:0"/>
      </action>
      

  7. Configure the command as a scheduler...

    1. Open an SQL command console.

    2. Execute the following SQL statement:

      insert into SCHCMD (schcmd_id, storeent_id, pathinfo) values (100,STOREENT_ID,'BoletoPaymentOrderStatusUpdate');
      

      where STOREENT_ID is the store ID.

    3. Execute the following SQL statement and make note of the CHKCMD_ID.

      select * from CHKCMD;
      

    4. Execute the following SQL statement:

      insert into CHKARRANG (chkcmd_id, schcmd_id) values (-1, 100);
      

      where chkcmd_id is the CHKCMD_ID that you noted.

  8. Schedule the BoletoPaymentOrderStatusUpdate job.
    The scheduler reads the payments status information from the boletoPayments.xml file. For each payment, the scheduler updates that payment status from pending to either failed or success, according to the status in the boletoPayments.xml file. Put the boletoPayments.xml file under the path:

    The following is an example of the format used in the boletoPayments.xml file:

    <!-- status codes: 0 (success), 1 (failed) -->
    <boletoPayments>    
    <payment>        
    <boletoNumber>25504</boletoNumber>        
    <status>0</status>    
    </payment>    
    <payment>        
    <boletoNumber>25502</boletoNumber>        
    <status>0</status>    
    </payment>    
    <payment>        
    <boletoNumber>25503</boletoNumber>        
    <status>0</status>    
    </payment>
    </boletoPayments>
    

  9. Check if there is WebSphereCommerceServerExtensionsLogic.jar file already in the path WC_EAR/.


Previous topic: Configure the payment policy for the BoletoBancario payment method


Next topic: Customize the store pages


Related concepts

Boleto Bancário payment method


+

Search Tips   |   Advanced Search