Braintree/src/main/java/com/braintreepayments/api/PaymentMethod.java
public static void deletePaymentMethod(final BraintreeFragment fragment,
                                           final PaymentMethodNonce paymentMethodNonce)  {

        boolean usesClientToken = fragment.getAuthorization() instanceof ClientToken;

        if (!usesClientToken) {
            fragment.postCallback(new BraintreeException("A client token with a customer id must be used to delete a payment method nonce."));
            return;
        }

        JSONObject base = new JSONObject();
        JSONObject variables = new JSONObject();
        JSONObject input = new JSONObject();

        try {
            base.put(CLIENT_SDK_META_DATA, new MetadataBuilder()
                    .sessionId(fragment.getSessionId())
                    .source("client")
                    .integration(fragment.getIntegrationType())
                    .build());

            base.put(GraphQLConstants.Keys.QUERY, GraphQLQueryHelper.getQuery(
                    fragment.getApplicationContext(), R.raw.delete_payment_method_mutation));
            input.put(SINGLE_USE_TOKEN_ID, paymentMethodNonce.getNonce());
            variables.put(INPUT, input);
            base.put(VARIABLES, variables);
            base.put(GraphQLConstants.Keys.OPERATION_NAME,
                    "DeletePaymentMethodFromSingleUseToken");
        } catch (Resources.NotFoundException | IOException | JSONException e) {
            fragment.postCallback(new BraintreeException("Unable to read GraphQL query"));
        }

        fragment.getGraphQLHttpClient().post(base.toString(), new HttpResponseCallback() {
            @Override
            public void success(String responseBody) {
                fragment.postPaymentMethodDeletedCallback(paymentMethodNonce);
                fragment.sendAnalyticsEvent("delete-payment-methods.succeeded");
            }

            @Override
            public void failure(Exception exception) {
                fragment.postCallback(new PaymentMethodDeleteException(paymentMethodNonce, exception));
                fragment.sendAnalyticsEvent("delete-payment-methods.failed");
            }
        });
    }
public static void deletePaymentMethod(final BraintreeFragment fragment,
                                           final PaymentMethodNonce paymentMethodNonce)  {

        boolean usesClientToken = fragment.getAuthorization() instanceof ClientToken;

        if (!usesClientToken) {
            fragment.postCallback(new BraintreeException("A client token with a customer id must be used to delete a payment method nonce."));
            return;
        }

        JSONObject base = new JSONObject();
        JSONObject variables = new JSONObject();
        JSONObject input = new JSONObject();

        try {
            base.put(CLIENT_SDK_META_DATA, new MetadataBuilder()
                    .sessionId(fragment.getSessionId())
                    .source("client")
                    .integration(fragment.getIntegrationType())
                    .build());

            base.put(GraphQLConstants.Keys.QUERY, GraphQLQueryHelper.getQuery(
                    fragment.getApplicationContext(), R.raw.delete_payment_method_mutation));
            input.put(SINGLE_USE_TOKEN_ID, paymentMethodNonce.getNonce());
            variables.put(INPUT, input);
            base.put(VARIABLES, variables);
            base.put(GraphQLConstants.Keys.OPERATION_NAME,
                    "DeletePaymentMethodFromSingleUseToken");
        } catch (Resources.NotFoundException | IOException | JSONException e) {
            fragment.postCallback(new BraintreeException("Unable to read GraphQL query"));
        }

        fragment.getGraphQLHttpClient().post(base.toString(), new HttpResponseCallback() {
            @Override
            public void success(String responseBody) {
                fragment.postPaymentMethodDeletedCallback(paymentMethodNonce);
                fragment.sendAnalyticsEvent("delete-payment-methods.succeeded");
            }

            @Override
            public void failure(Exception exception) {
                fragment.postCallback(new PaymentMethodDeleteException(paymentMethodNonce, exception));
                fragment.sendAnalyticsEvent("delete-payment-methods.failed");
            }
        });
    }
public static void deletePaymentMethod ( final BraintreeFragment fragment , final PaymentMethodNonce paymentMethodNonce ) { boolean usesClientToken = fragment . getAuthorization ( ) instanceof ClientToken ; if ( ! usesClientToken ) { fragment . postCallback ( new BraintreeException ( "A client token with a customer id must be used to delete a payment method nonce." ) ) ; return ; } JSONObject base = new JSONObject ( ) ; JSONObject variables = new JSONObject ( ) ; JSONObject input = new JSONObject ( ) ; try { base . put ( CLIENT_SDK_META_DATA , new MetadataBuilder ( ) . sessionId ( fragment . getSessionId ( ) ) . source ( "client" ) . integration ( fragment . getIntegrationType ( ) ) . build ( ) ) ; base . put ( GraphQLConstants . Keys . QUERY , GraphQLQueryHelper . getQuery ( fragment . getApplicationContext ( ) , R . raw . delete_payment_method_mutation ) ) ; input . put ( SINGLE_USE_TOKEN_ID , paymentMethodNonce . getNonce ( ) ) ; variables . put ( INPUT , input ) ; base . put ( VARIABLES , variables ) ; base . put ( GraphQLConstants . Keys . OPERATION_NAME , "DeletePaymentMethodFromSingleUseToken" ) ; } catch ( Resources . NotFoundException | IOException | JSONException e ) { fragment . postCallback ( new BraintreeException ( "Unable to read GraphQL query" ) ) ; } fragment . getGraphQLHttpClient ( ) . post ( base . toString ( ) , new HttpResponseCallback ( ) { @ Override public void success ( String responseBody ) { fragment . postPaymentMethodDeletedCallback ( paymentMethodNonce ) ; fragment . sendAnalyticsEvent ( "delete-payment-methods.succeeded" ) ; } @ Override public void failure ( Exception exception ) { fragment . postCallback ( new PaymentMethodDeleteException ( paymentMethodNonce , exception ) ) ; fragment . sendAnalyticsEvent ( "delete-payment-methods.failed" ) ; } } ) ; }
Deletes a payment method owned by the customer whose id was used to generate the {@link ClientToken}
used to create the {@link BraintreeFragment}.
<p/>
Note: This method only works with Android Lollipop (>= 21) and above.
This will invoke {@link com.braintreepayments.api.interfaces.BraintreeErrorListener#onError(Exception)} when
<ul>
<li>A {@link com.braintreepayments.api.models.TokenizationKey} is used.</li>
<li>The device is below Lollipop.</li>
<li>If the request fails.</li>
<ul/>

@param fragment {@link BraintreeFragment}
@param paymentMethodNonce The payment method nonce that references a vaulted payment method.
Deletes a payment method owned by the customer whose id was used to generate the { @link ClientToken } used to create the { @link BraintreeFragment } . <p / > Note : This method only works with Android Lollipop ( > = 21 ) and above . This will invoke { @link com . braintreepayments . api . interfaces . BraintreeErrorListener#onError ( Exception ) } when <ul > <li > A { @link com . braintreepayments . api . models . TokenizationKey } is used . < / li > <li > The device is below Lollipop . < / li > <li > If the request fails . < / li > <ul / >