コード例 #1
0
  /** {@inheritDoc} */
  @Override
  protected void doExecute() throws Exception {
    // Collect parameters.
    final Map<String, String> params = new HashMap<String, String>();
    params.put("_csrf", loginJson.getJSONObject("data").getString("_csrf"));
    params.put("_eventId_submit", "");
    params.put("bp_ks1", "");
    params.put("bp_ks2", "");
    params.put("bp_ks3", "");
    params.put("bp_mid", "");
    params.put("execution", loginJson.getJSONObject("data").getString("flowExecutionKey"));
    params.put("token", getPaypalToken());

    // Send the XHR.
    final WebResponse r =
        new XHR()
            .url(loginJson.getJSONObject("data").getString("flowExecutionUrl"))
            .POST()
            .postParams(params)
            .fire();

    // Create flow control link that points back to the DW system.
    final JSONObject json2 = new JSONObject(r.getContentAsString());
    final HtmlElement a = HtmlPageUtils.createHtmlElement("a", Context.getPage().getBody());
    a.setAttribute(
        "href", json2.getJSONObject("data").getJSONObject("flowControl").getString("location"));

    // Click that link.
    loadPageByClick(a);
  }
コード例 #2
0
 /**
  * Parse PayPal token from URL.
  *
  * @return PayPal token
  */
 private static String getPaypalToken() {
   final String token =
       AjaxUtils.parseUrlParams(Context.getPage().getUrl().getQuery()).get("token");
   Assert.assertNotNull("Could not find PayPal token", token);
   return token;
 }