Skip to content

Fixed VA

Generating Closed Amount Fixed Virtual Account

Please kindly follow these steps below to create close amount fixed Virtual Account:

  1. try catch the getAvailableBank method from VirtualAccount class
    1
    2
    3
    4
    5
    6
    try {
        AvailableBank[] banks = FixedVirtualAccount.getAvailableBank();
        System.out.println(Arrays.toString(banks));
    } catch (XenditException e) {
        e.printStackTrace();
    }
    
  2. Create a Map object with String as a key and Object as the value, like this:
    1
    Map<String, Object> closedVAMap = new HashMap<String, Object>();
    
  3. You can fill the map with any optional key like this:
    1. virtual_account_number = String - The virtual account number you want to assign. If you do not send one, one will be picked at random (Please do not include merchant code)
    2. is_closed = boolean - When set to true, the virtual account will be closed and will only accept the amount specified in expected_amount
    3. expected_amount = integer - The amount that the virtual account will expect if is_closed is set to true
    4. is_single_use = boolean - When set to true, the virtual account will be inactive after it is paid
    5. expiration_date = ISO Date - The time when the virtual account will be expired
    6. description = String - The virtual account description. (This field is only supported for BRI)
  4. You can skip some key above beside expected_amount and is_closed
  5. Call the createClosed method from VirtualAccount Class with the first parameter as your external ID (you can consider this as reference ID), bank code from getAvailableBanks, the payer name, and amount in long type and the last is your Map object, like this:
    1
    VirtualAccount virtualAccount3 = VirtualAccount.createClosed("my_external_id", BankCode.MANDIRI.getText(), "John Doe", 100000L, closedVAMap);
    
  6. Set your callback URL in your Xendit dashboard settings, in Fixed Virtual Accounts section or you can go to Xendit Dashboard on Settings menu > Configuration > Fixed Virtual Accounts section
  7. You are good to go to test your virtual account!

Generating Open Amount Fixed Virtual Account

Please kindly follow these steps below to create closed open fixed Virtual Account:

  1. try catch the getAvailableBank method from VirtualAccount class
    1
    2
    3
    4
    5
    6
    try {
        AvailableBank[] banks = FIxedVirtualAccount.getAvailableBank();
        System.out.println(Arrays.toString(banks));
    } catch (XenditException e) {
        e.printStackTrace();
    }
    
  2. Create a Map object with String as a key and Object as the value, like this:
    1
    Map<String, Object> openVAMap = new HashMap<String, Object>();
    
  3. You can fill the map with any optional key like this:
    1. virtual_account_number = String - The virtual account number you want to assign. If you do not send one, one will be picked at random (Please do not include merchant code)
    2. suggested_amount = integer - The suggested amount you want to assign. (Suggested amounts is only supported for Mandiri and BRI)
    3. is_single_use = boolean - When set to true, the virtual account will be inactive after it is paid
    4. expiration_date = ISO Date - The time when the virtual account will be expired
    5. description = String - The virtual account description. (This field is only supported for BRI)
  4. Call the createOpen method from VirtualAccount Class with the first parameter as your external ID (you can consider this as reference ID), bank code from getAvailableBanks, the payer name, and amount in long type and the last is your Map object, like this:
    1
    VirtualAccount virtualAccount3 = VirtualAccount.createOpen("my_external_id", BankCode.MANDIRI.getText(), "John Doe", openVAMap);
    
  5. Set your callback URL in your Xendit dashboard settings, in Fixed virtual accounts section or you can go to Xendit Dashboard on Settings menu > Configuration > Fixed virtual accounts section
  6. You are good to go to test your virtual account!

Get Fixed Virtual Account

Please kindly follow these steps below to get your VA data:

  1. try catch the getFixedVA method from VirtualAccount class, please have the Virtual Account ID as the parameter inside the method
    1
    2
    3
    4
    5
    try {
        FixedVirtualAccount virtualAccount = FixedVirtualAccount.getFixedVA(virtualAccountId);
    } catch (XenditException e) {
            e.printStackTrace();
    }
    
  2. You will get your Virtual Account data as an object of FixedVirtualAccount