@NonNull
    public static SourceParams createCardParams(@NonNull Card card) {
        final SourceParams params = new SourceParams().setType(Source.CARD);

        // Not enforcing all fields to exist at this level.
        // Instead, the server will return an error for invalid data.
        final AbstractMap<String, Object> basicInfoMap = new HashMap<>();
        basicInfoMap.put(FIELD_NUMBER, card.getNumber());
        basicInfoMap.put(FIELD_EXP_MONTH, card.getExpMonth());
        basicInfoMap.put(FIELD_EXP_YEAR, card.getExpYear());
        basicInfoMap.put(FIELD_CVC, card.getCVC());
        removeNullAndEmptyParams(basicInfoMap);

        params.setApiParameterMap(basicInfoMap);

        final Map<String, Object> addressMap = new HashMap<>();
        addressMap.put(FIELD_LINE_1, card.getAddressLine1());
        addressMap.put(FIELD_LINE_2, card.getAddressLine2());
        addressMap.put(FIELD_CITY, card.getAddressCity());
        addressMap.put(FIELD_COUNTRY, card.getAddressCountry());
        addressMap.put(FIELD_STATE, card.getAddressState());
        addressMap.put(FIELD_POSTAL_CODE, card.getAddressZip());
        removeNullAndEmptyParams(addressMap);

        // If there are any keys left...
        final Map<String, Object> ownerMap = new HashMap<>();
        ownerMap.put(FIELD_NAME, card.getName());
        if (addressMap.keySet().size() > 0) {
            ownerMap.put(FIELD_ADDRESS, addressMap);
        }
        removeNullAndEmptyParams(ownerMap);
        if (ownerMap.keySet().size() > 0) {
            params.setOwner(ownerMap);
        }

        final Map<String, String> metadata = card.getMetadata();
        if (metadata != null) {
            params.setMetaData(metadata);
        }

        return params;
    }
@ NonNull public static SourceParams createCardParams ( @ NonNull Card card ) { final SourceParams params = new SourceParams ( ) . setType ( Source . CARD ) ; final AbstractMap < String , Object > basicInfoMap = new HashMap < > ( ) ; basicInfoMap . put ( FIELD_NUMBER , card . getNumber ( ) ) ; basicInfoMap . put ( FIELD_EXP_MONTH , card . getExpMonth ( ) ) ; basicInfoMap . put ( FIELD_EXP_YEAR , card . getExpYear ( ) ) ; basicInfoMap . put ( FIELD_CVC , card . getCVC ( ) ) ; removeNullAndEmptyParams ( basicInfoMap ) ; params . setApiParameterMap ( basicInfoMap ) ; final Map < String , Object > addressMap = new HashMap < > ( ) ; addressMap . put ( FIELD_LINE_1 , card . getAddressLine1 ( ) ) ; addressMap . put ( FIELD_LINE_2 , card . getAddressLine2 ( ) ) ; addressMap . put ( FIELD_CITY , card . getAddressCity ( ) ) ; addressMap . put ( FIELD_COUNTRY , card . getAddressCountry ( ) ) ; addressMap . put ( FIELD_STATE , card . getAddressState ( ) ) ; addressMap . put ( FIELD_POSTAL_CODE , card . getAddressZip ( ) ) ; removeNullAndEmptyParams ( addressMap ) ; final Map < String , Object > ownerMap = new HashMap < > ( ) ; ownerMap . put ( FIELD_NAME , card . getName ( ) ) ; if ( addressMap . keySet ( ) . size ( ) > 0 ) { ownerMap . put ( FIELD_ADDRESS , addressMap ) ; } removeNullAndEmptyParams ( ownerMap ) ; if ( ownerMap . keySet ( ) . size ( ) > 0 ) { params . setOwner ( ownerMap ) ; } final Map < String , String > metadata = card . getMetadata ( ) ; if ( metadata != null ) { params . setMetaData ( metadata ) ; } return params ; }
Create parameters necessary for creating a card source.

@param card A {@link Card} object containing the details necessary for the source.
@return a {@link SourceParams} object that can be used to create a card source.

@see <a href="https://stripe.com/docs/sources/cards">https://stripe.com/docs/sources/cards</a>