Testing the code
It's testing time, but before running the project, we need to define a trusted keystore for Java in order to validate the server's certificate, and for that we use the Java keytool (further usage details on keytool can be found in Oracle's documentation):
keytool -import -keystore clientkeystore -file /path_to/cert.der -alias bip70.com -storepass changeit
Then import the resulting clientkeystore file into the Eclipse project. Afterwards, click Run as then Run Configurations to define the parameter -Djavax.net.ssl.trustStore=clientkeystore—in the Arguments tab in the VM arguments box:
When you finish, compile and run your code. If everything runs correctly, you will be able to visualize in the Eclipse log viewer the SVP wallet activity, the merchant's payment request details, and the memo from the merchant when the payment is successfully processed, along with the invoice ID:
At this point, we have reached our goal of building a Java client to send a payment over the testnet network using the BIP 70 protocol. As you have witnessed, BitcoinJ is an easy-to-use and powerful framework. I would definitely recommend you spend time reading their official documentation and compiling the code samples provided therein.
Finally, I would note that, for the sake of brevity, the overall server and client code is intentionally unoptimized and lacks many features. You could probably go back over the code and try to include new improvements, such as building a GUI. I'll be waiting for your pull requests.