<commit_before>/*
 * Copyright 2014-2019 The Billing Project, LLC
 *
 * The Billing Project licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package org.killbill.billing.plugin.stripe;

import java.util.HashMap;
import java.util.Map;

import com.stripe.model.BankAccount;
import com.stripe.model.Charge;
import com.stripe.model.PaymentIntent;
import com.stripe.model.PaymentMethod;
import com.stripe.model.PaymentMethod.Card;
import com.stripe.model.PaymentSource;
import com.stripe.model.Source;
import com.stripe.model.Source.AchDebit;
import com.stripe.model.checkout.Session;

// Stripe .toJson() is definitively not GDPR-friendly...
public abstract class StripePluginProperties {

    public static Map<String, Object> toAdditionalDataMap(final PaymentSource stripePaymentSource) {
        final Map<String, Object> additionalDataMap = new HashMap<String, Object>();

        if (stripePaymentSource instanceof Source) {
            final Source stripeSource = (Source) stripePaymentSource;
            final Source.Card card = stripeSource.getCard();
            if (card != null) {
                additionalDataMap.put("card_brand", card.getBrand());
                additionalDataMap.put("card_address_line1_check", card.getAddressLine1Check());
                additionalDataMap.put("card_address_postal_code_check", card.getAddressZipCheck());
                additionalDataMap.put("card_cvc_check", card.getCvcCheck());
                additionalDataMap.put("card_country", card.getCountry());
                additionalDataMap.put("card_description", card.getName());
                additionalDataMap.put("card_exp_month", card.getExpMonth());
                additionalDataMap.put("card_exp_year", card.getExpYear());
                additionalDataMap.put("card_fingerprint", card.getFingerprint());
                additionalDataMap.put("card_funding", card.getFunding());
                additionalDataMap.put("card_last4", card.getLast4());
                additionalDataMap.put("card_three_d_secure_usage_support", card.getThreeDSecure());
            }
            final AchDebit achDebit = stripeSource.getAchDebit();<commit_msg>properties: add support for yet another Card object<commit_after>/*
 * Copyright 2014-2019 The Billing Project, LLC
 *
 * The Billing Project licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package org.killbill.billing.plugin.stripe;

import java.util.HashMap;
import java.util.Map;

import com.stripe.model.BankAccount;
import com.stripe.model.Charge;
import com.stripe.model.PaymentIntent;
import com.stripe.model.PaymentMethod;
import com.stripe.model.PaymentMethod.Card;
import com.stripe.model.PaymentSource;
import com.stripe.model.Source;
import com.stripe.model.Source.AchDebit;
import com.stripe.model.checkout.Session;

// Stripe .toJson() is definitively not GDPR-friendly...
public abstract class StripePluginProperties {

    public static Map<String, Object> toAdditionalDataMap(final PaymentSource stripePaymentSource) {
        final Map<String, Object> additionalDataMap = new HashMap<String, Object>();

        if (stripePaymentSource instanceof com.stripe.model.Card) {
            final com.stripe.model.Card card = (com.stripe.model.Card) stripePaymentSource;
            additionalDataMap.put("card_brand", card.getBrand());
            additionalDataMap.put("card_address_line1_check", card.getAddressLine1Check());
            additionalDataMap.put("card_address_postal_code_check", card.getAddressZipCheck());
            additionalDataMap.put("card_cvc_check", card.getCvcCheck());
            additionalDataMap.put("card_country", card.getCountry());
            additionalDataMap.put("card_description", card.getName());
            additionalDataMap.put("card_exp_month", card.getExpMonth());
            additionalDataMap.put("card_exp_year", card.getExpYear());
            additionalDataMap.put("card_fingerprint", card.getFingerprint());
            additionalDataMap.put("card_funding", card.getFunding());
            additionalDataMap.put("card_last4", card.getLast4());
        } else if (stripePaymentSource instanceof Source) {
            final Source stripeSource = (Source) stripePaymentSource;
            final Source.Card card = stripeSource.getCard();
            if (card != null) {
                additionalDataMap.put("card_brand", card.getBrand());
                additionalDataMap.put("card_address_line1_check", card.getAddressLine1Check());
                additionalDataMap.put("card_address_postal_code_check", card.getAddressZipCheck());
                additionalDataMap.put("card_cvc_check", card.getCvcCheck());
                additionalDataMap.put("card_country", card.getCountry());
                additionalDataMap.put("card_description", card.getName());
                additionalDataMap.put("card_exp_month", card.getExpMonth());
                additionalDataMap.put("card_exp_year", card.getExpYear());
                additionalDataMap.put("card_fingerprint", card.getFingerprint());
                additionalDataMap.put("card_funding", card.getFunding());
                additionalDataMap.put("card_last4", card.getLast4());
                additionalDataMap.put("card_three_d_secure_usage_support", card.getThreeDSecure());
            }
            final AchDebit achDebit = stripeSource.getAchDebit();
{'fraction_non_alphanumeric': 0.10368050117462803, 'fraction_numerical': 0.005638214565387627, 'mean_word_length': 3.5290780141843974, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4335567', 'n_tokens_mistral': 1768, 'n_tokens_neox': 1686, 'n_words': 406}