// Obtain the credentials from your configs credentialObj = new APICredential(); credentialObj.setAPIUsername(getServletConfig() .getInitParameter("PPAPIUsername")); credentialObj.setAPIPassword(getServletConfig() .getInitParameter("PPAPIPassword")); credentialObj.setSignature(getServletConfig() .getInitParameter("PPAPISignature")); // setup your AppID from X.com credentialObj.setAppId(getServletConfig() .getInitParameter("PPAppID")); // setup your Test Business account email // in most cases this would be associated with API Credentials credentialObj.setAccountEmail(getServletConfig() .getInitParameter("PPAccountEmail")); // add required error condition checks //....
try { // CreateSimplePreapproval request to setup a simple // preapproval with no Payment Period Set CreateSimplePreapproval simplePreapproval = new CreateSimplePreapproval(); // set the API Credentials object (as given in the code above) simplePreapproval.setCredentialObj(credentialObj); // starting date in yyyy-MM-dd format simplePreapproval.setStartingDate("2010-06-25"); // ending date in yyyy-MM-dd format // in this case it's for an year from the starting date simplePreapproval.setEndingDate("2011-06-25"); // set max total amount of all Payments simplePreapproval.setMaxTotalAmountOfAllPayments(52.00); // set max amount for each payment - let's say $1 simplePreapproval.setMaxAmountPerPayment(1.00); // set max number of payments allowed - (52 weeks) simplePreapproval.setMaxNumberOfPayments(52); // set where to send the user in case of a cancellation simplePreapproval.setCancelUrl(req.getRequestURL() + "?action=preapproval&cancel=1"); // set where to return the user after successful approval simplePreapproval.setReturnUrl(req.getRequestURL() + "? return=1&action=preapproval&preapprovalKey=${preapprovalKey}"); /* Set other required fields */ // ... // // set memo for user's transaction history simplePreapproval.setMemo("Preapproval for GAE Sample"); // send the request PreapprovalResponse preapprovalResponse = simplePreapproval.makeRequest(); } catch (//...exceptions go here...//) { // handle exceptions as necessary }
Demonstrate your proficiency to design, build and manage solutions on Google Cloud Platform.