# Service Configuration
source: https://developer.mastercard.com/community-pass-payment-apis/documentation/service_config/index.md

While following [Generate and Configure a Mastercard API Client](https://developer.mastercard.com/platform/documentation/generating-and-configuring-a-mastercard-api-client/) tutorial, You will require to setup [Service Configurations](https://developer.mastercard.com/platform/documentation/generating-and-configuring-a-mastercard-api-client/#step-7-enable-encryption) at step-7.

Please find below Service configuration in Java for Donate APIs.
* Java

```Java
FieldLevelEncryptionConfig fieldLevelEncryptionConfig = FieldLevelEncryptionConfigBuilder.aFieldLevelEncryptionConfig()
                .withEncryptionCertificate(EncryptionUtils.loadEncryptionCertificate("./path/to/your/client-encryption.pem"))
                .withDecryptionKey(decryptionKey)
                .withEncryptionPath("$", "$")
                .withDecryptionPath("$", "$")
                .withOaepPaddingDigestAlgorithm("SHA-256")
                .withEncryptedValueFieldName("encryptedValue")
                .withEncryptedKeyFieldName("encryptedKey")
                .withIvFieldName("iv")
                .withEncryptionKeyFingerprintFieldName("publicKeyFingerprint")
                .withFieldValueEncoding(FieldLevelEncryptionConfig.FieldValueEncoding.BASE64)
                .build();
```

Also Project which will use API client may look like this in Java
* Java

```Java
public static void main(String args[]) throws Exception {
        ApiClient client = new ApiClient();
        OkHttpClient.Builder httpClientBuilder = client.getHttpClient().newBuilder();
        HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
        logging.setLevel(HttpLoggingInterceptor.Level.BODY);

        client.setBasePath("https://sandbox.api.mastercard.com");

        //This code shows you how to setup your signing key using the credentials you got when creating your project
        PrivateKey signingKey = AuthenticationUtils.loadSigningKey("./path/to/your/client-signing.p12",
                "keyalias",
                "keystorepassword");

        PrivateKey decryptionKey = AuthenticationUtils.loadSigningKey("./path/to/your/mastercard-encryption.p12",
                "keyAlias",
                "password");

        FieldLevelEncryptionConfig fieldLevelEncryptionConfig = FieldLevelEncryptionConfigBuilder.aFieldLevelEncryptionConfig()
                .withEncryptionCertificate(EncryptionUtils.loadEncryptionCertificate("./path/to/your/client-encryption.pem"))
                .withDecryptionKey(decryptionKey)
                .withEncryptionPath("$", "$")
                .withDecryptionPath("$", "$")
                .withOaepPaddingDigestAlgorithm("SHA-256")
                .withEncryptedValueFieldName("encryptedValue")
                .withEncryptedKeyFieldName("encryptedKey")
                .withIvFieldName("iv")
                .withEncryptionKeyFingerprintFieldName("publicKeyFingerprint")
                .withFieldValueEncoding(FieldLevelEncryptionConfig.FieldValueEncoding.BASE64)
                .build();

        // this interceptor will make sure all your request are encrypted and responses will be decrypted
        httpClientBuilder.addInterceptor(new OkHttpFieldLevelEncryptionInterceptor(fieldLevelEncryptionConfig));

        // this interceptor will be used for signing request for authorization
        httpClientBuilder.addInterceptor(
                new OkHttpOAuth1Interceptor("you-consumer-key", signingKey))
                .addInterceptor(logging);

        client.setHttpClient(httpClientBuilder.build());

        // Calling all Donation APIs to ensure all calls are working
        doOneTimeDonation(client);
        doGuestDonation(client);
    }
```

