/** * Collect device information for fraud identification purposes. * * @param fragment {@link BraintreeFragment} * @param listener to be called with the device data String to send to Braintree. */ public static void collectDeviceData(BraintreeFragment fragment, BraintreeResponseListener<String> listener) { collectDeviceData(fragment, null, listener); }
/** * @deprecated Use {@link #collectDeviceData(BraintreeFragment, BraintreeResponseListener)} instead. */ @Deprecated public static String collectDeviceData(BraintreeFragment fragment) { return collectDeviceData(fragment, BRAINTREE_MERCHANT_ID); }
/** * @deprecated Use {@link #collectDeviceData(BraintreeFragment)} instead. */ @Deprecated public static String collectDeviceData(Context context, BraintreeFragment fragment) { return collectDeviceData(fragment); }
/** * @deprecated Use {@link #collectDeviceData(BraintreeFragment, String)} instead. */ @Deprecated public static String collectDeviceData(Context context, BraintreeFragment fragment, String merchantId) { return collectDeviceData(fragment, merchantId); }
@Override public void onConfigurationFetched(Configuration configuration) { if (getIntent().getBooleanExtra(MainActivity.EXTRA_COLLECT_DEVICE_DATA, false)) { DataCollector.collectDeviceData(mBraintreeFragment, new BraintreeResponseListener<String>() { @Override public void onResponse(String deviceData) { mDeviceData = deviceData; } }); } }
@Test public void collectDeviceData() throws JSONException { BraintreeFragment fragment = new MockFragmentBuilder().build(); String deviceData = DataCollector.collectDeviceData(fragment); JSONObject json = new JSONObject(deviceData); assertFalse(TextUtils.isEmpty(json.getString("device_session_id"))); assertEquals("600000", json.getString("fraud_merchant_id")); assertNotNull(json.getString("correlation_id")); }
@Test public void collectDeviceData_usesDirectMerchantId() throws JSONException { BraintreeFragment fragment = new MockFragmentBuilder().build(); String deviceData = DataCollector.collectDeviceData(fragment, "100"); JSONObject json = new JSONObject(deviceData); assertFalse(TextUtils.isEmpty(json.getString("device_session_id"))); assertEquals("100", json.getString("fraud_merchant_id")); }
@Test(timeout = 1000) public void collectDeviceData_doesNotCollectKountDataIfKountDisabledInConfiguration() throws InterruptedException { BraintreeFragment fragment = getFragmentWithConfiguration(mActivity, new TestConfigurationBuilder().build()); DataCollector.collectDeviceData(fragment, new BraintreeResponseListener<String>() { @Override public void onResponse(String deviceData) { try { JSONObject json = new JSONObject(deviceData); assertNull(Json.optString(json, "device_session_id", null)); assertNull(Json.optString(json, "fraud_merchant_id", null)); assertNotNull(json.getString("correlation_id")); } catch (JSONException e) { fail(e.getMessage()); } mCountDownLatch.countDown(); } }); mCountDownLatch.await(); } }
@Override public void onConfigurationFetched(Configuration configuration) { mConfiguration = configuration; mCardForm.cardRequired(true) .expirationRequired(true) .cvvRequired(configuration.isCvvChallengePresent()) .postalCodeRequired(configuration.isPostalCodeChallengePresent()) .mobileNumberRequired(false) .actionLabel(getString(R.string.purchase)) .setup(this); if (getIntent().getBooleanExtra(MainActivity.EXTRA_COLLECT_DEVICE_DATA, false)) { DataCollector.collectDeviceData(mBraintreeFragment, new BraintreeResponseListener<String>() { @Override public void onResponse(String deviceData) { mDeviceData = deviceData; } }); } }
@Test(timeout = 10000) public void collectDeviceData_withListener_usesDirectMerchantId() throws InterruptedException { String configuration = new TestConfigurationBuilder() .kount(new TestKountConfigurationBuilder() .kountMerchantId("600000")) .build(); BraintreeFragment fragment = getFragmentWithConfiguration(mActivity, configuration); DataCollector.collectDeviceData(fragment, "600001", new BraintreeResponseListener<String>() { @Override public void onResponse(String deviceData) { try { JSONObject json = new JSONObject(deviceData); assertFalse(TextUtils.isEmpty(json.getString("device_session_id"))); assertEquals("600001", json.getString("fraud_merchant_id")); assertNotNull(json.getString("correlation_id")); } catch (JSONException e) { fail(e.getMessage()); } mCountDownLatch.countDown(); } }); mCountDownLatch.await(); }
@Test(timeout = 10000) public void collectDeviceData_withListener() throws InterruptedException { String configuration = new TestConfigurationBuilder() .kount(new TestKountConfigurationBuilder() .kountMerchantId("500000")) .build(); BraintreeFragment fragment = getFragmentWithConfiguration(mActivity, configuration); DataCollector.collectDeviceData(fragment, new BraintreeResponseListener<String>() { @Override public void onResponse(String deviceData) { try { JSONObject json = new JSONObject(deviceData); assertFalse(TextUtils.isEmpty(json.getString("device_session_id"))); assertEquals("500000", json.getString("fraud_merchant_id")); assertNotNull(json.getString("correlation_id")); } catch (JSONException e) { fail(e.getMessage()); } mCountDownLatch.countDown(); } }); mCountDownLatch.await(); }
com.kount.api.DataCollector.getInstance(); DataCollector.collectDeviceData(fragment, new BraintreeResponseListener<String>() { @Override public void onResponse(String s) {
com.kount.api.DataCollector.getInstance(); DataCollector.collectDeviceData(fragment, new BraintreeResponseListener<String>() { @Override public void onResponse(String s) {