Prior to following these steps you should have the Kount Java RIS SDK, a valid RIS URL, and a valid API Key.
- Import Kount classes from SDK.
- Create KountRisClient with the URL and API Key.
- Create a new Inquiry() object.
- Use client setters to add the transaction information.
- Add cart information.
- Call client.process(inquiry) and get a Response Object back.
- Process the Response object.
package net.example; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import com.kount.ris.Inquiry; import com.kount.ris.KountRisClient; import com.kount.ris.Response; import com.kount.ris.util.CartItem; import com.kount.ris.util.MerchantAcknowledgment; import com.kount.ris.util.RisException; import com.kount.ris.util.payment.Payment; public class Example { public static void main(String[] args) throws MalformedURLException { URL url = new URL("https://risk.kount.net""); String apiKey = new String("23459856789"); // Create a RIS client object with the target URL and your API key KountRisClient ris = new KountRisClient(url, apiKey); // Create and populate a new Request. The Request will be handed // off to the RIS client to make the call and provide the response. Inquiry req = new Inquiry(); req.setMerchantId(555556); req.setSessionId("faa6370074b53928bc51ef913441e0cd"); Payment payment = new Payment("CARD", "4111111111111111"); req.setCurrency("USD"); req.setPayment(payment); req.setTotal(125); req.setCustomerName("John Doe"); req.setEmail("johndoe@test.com"); req.setIpAddress("127.0.0.1"); req.setMerchantAcknowledgment(MerchantAcknowledgment.YES); req.setWebsite("DEFAULT"); CartItem item0 = new CartItem("SURROUND SOUND", "HTP-2920", "Pioneer High Power 5.1 Surround Sound System", 1, 49999); CartItem item1 = new CartItem("BLURAY PLAYER", "BDP-S500", "Sony 1080p Blu-Ray Disc Player", 1, 69999); Collection<CartItem> cart = new ArrayList<>(); cart.add(item0); cart.add(item1); req.setCart(cart); try { // This is the first point at which the code actually calls the Kount // services. Everything prior to this is simply setting up the payload. Response response = ris.process(req); String responseText = "Transaction ID: " + response.getTransactionId() + "\n\n"; responseText += response; System.out.print(responseText); } catch (RisException risException) { System.out.print(risException.getMessage()); } } }
Comments
0 comments
Article is closed for comments.