Search in sources :

Example 1 with DropInResult

use of com.braintreepayments.api.dropin.DropInResult in project braintree_android by braintree.

the class MainActivity method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
        if (requestCode == DROP_IN_REQUEST) {
            DropInResult result = data.getParcelableExtra(DropInResult.EXTRA_DROP_IN_RESULT);
            displayNonce(result.getPaymentMethodNonce(), result.getDeviceData());
        } else {
            Parcelable returnedData = data.getParcelableExtra(EXTRA_PAYMENT_RESULT);
            String deviceData = data.getStringExtra(EXTRA_DEVICE_DATA);
            if (returnedData instanceof PaymentMethodNonce) {
                displayNonce((PaymentMethodNonce) returnedData, deviceData);
            } else if (returnedData instanceof BraintreePaymentResult) {
                displayBraintreeResult((BraintreePaymentResult) returnedData);
            }
            mCreateTransactionButton.setEnabled(true);
        }
    } else if (resultCode != RESULT_CANCELED) {
        showDialog(((Exception) data.getSerializableExtra(DropInActivity.EXTRA_ERROR)).getMessage());
    }
}
Also used : BraintreePaymentResult(com.braintreepayments.api.models.BraintreePaymentResult) DropInResult(com.braintreepayments.api.dropin.DropInResult) Parcelable(android.os.Parcelable) PaymentMethodNonce(com.braintreepayments.api.models.PaymentMethodNonce)

Aggregations

Parcelable (android.os.Parcelable)1 DropInResult (com.braintreepayments.api.dropin.DropInResult)1 BraintreePaymentResult (com.braintreepayments.api.models.BraintreePaymentResult)1 PaymentMethodNonce (com.braintreepayments.api.models.PaymentMethodNonce)1