Skip to content

Commit

Permalink
Release 1.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adyen-git-manager committed Nov 28, 2017
1 parent 8e166ef commit a6ffee5
Show file tree
Hide file tree
Showing 47 changed files with 755 additions and 236 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ This README provides the usage manual for the SDK itself. For the full documenta
To integrate the Adyen SDK into your project, import the **core**, **utils** and **ui** module by adding the following lines to your build.gradle file.

```
compile 'com.adyen.checkout:core:1.12.0'
compile 'com.adyen.checkout:utils:1.12.0'
compile 'com.adyen.checkout:ui:1.12.0'
compile 'com.adyen.checkout:cardscan:1.12.0'
compile 'com.adyen.checkout:core:1.13.0'
compile 'com.adyen.checkout:utils:1.13.0'
compile 'com.adyen.checkout:ui:1.13.0'
compile 'com.adyen.checkout:cardscan:1.13.0'
```

> For implementing Custom integration, only the **core** module is required. However, you might also want to include the **utils** module to use Adyen's utility methods such as Luhn check, credit card type detection, etc.
Expand Down Expand Up @@ -174,7 +174,7 @@ For your convenience, we included the following demo modules into this repositor

* **checkoutdemo** – A functioning demo of the Checkout SDK using the Quick integration.

* **app** – Also uses the Quick integration, but allows to configure parameters for setting up the payment request.
* **defaultApp** – Also uses the Quick integration, but allows to configure parameters for setting up the payment request.

* **customuiapplication** – An example implementation of the Custom integration where the application fully handles the UI.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ static String getToken(final Context context, final PaymentStateHandler paymentS
deviceInfo.put("sdkVersion", SDK_VERSION);
deviceInfo.put("deviceIdentifier", androidId);
deviceInfo.put("locale", StringUtils.getLocale(context));

deviceInfo.put("integration", (isQuickIntegration) ? "quick" : "custom");
deviceInfo.put("deviceModel", Build.MANUFACTURER + " " + Build.DEVICE);

} catch (final JSONException jsonException) {
Log.e(TAG, "Token could not be created", jsonException);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static class Type {
public static final String SEPA_DIRECT_DEBIT = "sepadirectdebit";
public static final String PAYPAL = "paypal";
public static final String BCMC = "bcmc";
public static final String QIWI_WALLET = "qiwiwallet";
}

private static final long serialVersionUID = 2587948839462686004L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class CreditCardPaymentDetails extends PaymentDetails {
public static final String INSTALLMENTS = "installments";
public static final String BILLING_ADDRESS = "billingAddress";

public static final String CARD_HOLDER_NAME_REQUIRED = "cardHolderNameRequired";

public enum AddressKey {
street,
houseNumberOrName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import java.util.Collection;

/**
* PaymentDetails class for sepa direct debit payments.
* PaymentDetails class for the iDEAL issuer selection.
*/
public class IdealPaymentDetails extends PaymentDetails {

private static final String IDEAL_ISSUER = "idealIssuer";
public static final String IDEAL_ISSUER = "idealIssuer";

public IdealPaymentDetails(Collection<InputDetail> inputDetails) {
super(inputDetails);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.adyen.core.models.paymentdetails;

import java.util.Collection;

/**
* PaymentDetails class for issuer selection.
*/
public class IssuerSelectionPaymentDetails extends PaymentDetails {

public static final String ISSUER = "issuer";

public IssuerSelectionPaymentDetails(Collection<InputDetail> inputDetails) {
super(inputDetails);
}

public boolean fillIssuer(final String issuerId) {
for (InputDetail inputDetail: getInputDetails()) {
if (IdealPaymentDetails.IDEAL_ISSUER.equalsIgnoreCase(inputDetail.getKey())
|| ISSUER.equalsIgnoreCase(inputDetail.getKey())) {
return super.fill(inputDetail.getKey(), issuerId);
}
}
return false;
}

public boolean fillIssuer(final InputDetail.Item issuerItem) {
return fillIssuer(issuerItem.getId());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.adyen.core.models.paymentdetails;

import java.util.Collection;

/**
* PaymentDetails class for Qiwi wallet payments.
*/
public class QiwiWalletPaymentDetails extends PaymentDetails {

private static final String QIWI_TELEPHONE_NUMBER_PREFIX = "qiwiwallet.telephoneNumberPrefix";
private static final String QIWI_TELEPHONE_NUMBER = "qiwiwallet.telephoneNumber";


public QiwiWalletPaymentDetails(Collection<InputDetail> inputDetails) {
super(inputDetails);
}

public boolean fillTelephoneNumber(final String countryCode, final String telephoneNumber) {
return super.fill(QIWI_TELEPHONE_NUMBER, telephoneNumber)
&& super.fill(QIWI_TELEPHONE_NUMBER_PREFIX, countryCode);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
import com.adyen.core.interfaces.UriCallback;
import com.adyen.core.internals.ModuleAvailabilityUtil;
import com.adyen.core.models.PaymentMethod;
import com.adyen.core.models.paymentdetails.IdealPaymentDetails;
import com.adyen.core.models.paymentdetails.InputDetail;
import com.adyen.core.models.paymentdetails.InputDetailsUtil;
import com.adyen.core.models.paymentdetails.IssuerSelectionPaymentDetails;
import com.adyen.core.models.paymentdetails.PaymentDetails;
import com.adyen.core.services.PaymentMethodService;
import com.adyen.ui.activities.CheckoutActivity;
Expand Down Expand Up @@ -120,8 +122,9 @@ public void onReceive(final Context context, final Intent intent) {
public void onPaymentDetailsRequired(@NonNull PaymentRequest paymentRequest,
@NonNull Collection<InputDetail> inputDetails,
@NonNull PaymentDetailsCallback callback) {
if (paymentRequest.getPaymentMethod().getType().equals(PaymentMethod.Type.IDEAL)) {

if (InputDetailsUtil.containsKey(inputDetails, IdealPaymentDetails.IDEAL_ISSUER)
|| InputDetailsUtil.containsKey(inputDetails, IssuerSelectionPaymentDetails.ISSUER)) {
final Intent intent = new Intent(context, CheckoutActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable(PAYMENT_METHOD, paymentRequest.getPaymentMethod());
Expand Down Expand Up @@ -157,6 +160,14 @@ public void onPaymentDetailsRequired(@NonNull PaymentRequest paymentRequest,
intent.putExtra(GENERATION_TIME, paymentRequest.getGenerationTime());
intent.putExtra(CVC_FIELD_STATUS, CreditCardFragmentBuilder.CvcFieldStatus.NOCVC.name());
context.startActivity(intent);
} else if (paymentRequest.getPaymentMethod().getType().equals(PaymentMethod.Type.QIWI_WALLET)) {
final Intent intent = new Intent(context, CheckoutActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable(PAYMENT_METHOD, paymentRequest.getPaymentMethod());
bundle.putSerializable(AMOUNT, paymentRequest.getAmount());
bundle.putInt("fragment", CheckoutActivity.QIWI_WALLET_FRAGMENT);
intent.putExtras(bundle);
context.startActivity(intent);
} else if (paymentRequest.getPaymentMethod().getType().equals(PaymentMethod.Type.PAYPAL)) {
//We can set "storeDetails" to true if we want to set up a recurring contract.
callback.completionWithPaymentDetails(new PaymentDetails(inputDetails));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import com.adyen.core.models.Amount;
import com.adyen.core.models.PaymentMethod;
import com.adyen.core.models.paymentdetails.CreditCardPaymentDetails;
import com.adyen.core.models.paymentdetails.IdealPaymentDetails;
import com.adyen.core.models.paymentdetails.IssuerSelectionPaymentDetails;
import com.adyen.core.models.paymentdetails.QiwiWalletPaymentDetails;
import com.adyen.core.models.paymentdetails.SepaDirectDebitPaymentDetails;
import com.adyen.ui.R;
import com.adyen.ui.fragments.CreditCardFragment;
Expand All @@ -32,6 +33,8 @@
import com.adyen.ui.fragments.LoadingScreenFragment;
import com.adyen.ui.fragments.PaymentMethodSelectionFragment;
import com.adyen.ui.fragments.PaymentMethodSelectionFragmentBuilder;
import com.adyen.ui.fragments.QiwiWalletFragment;
import com.adyen.ui.fragments.QiwiWalletFragmentBuilder;
import com.adyen.ui.fragments.SepaDirectDebitFragment;
import com.adyen.ui.fragments.SepaDirectDebitFragmentBuilder;

Expand All @@ -58,6 +61,7 @@ public class CheckoutActivity extends FragmentActivity {
public static final int ISSUER_SELECTION_FRAGMENT = 2;
public static final int SEPA_DIRECT_DEBIT_FRAGMENT = 3;
public static final int GIROPAY_FRAGMENT = 4;
public static final int QIWI_WALLET_FRAGMENT = 5;
public static final int LOADING_SCREEN_FRAGMENT = 11;

public static final String PREFERED_PAYMENT_METHODS = "preferredPaymentMethods";
Expand Down Expand Up @@ -125,11 +129,9 @@ public void onBackPressed() {
if (backStackEntryCount == 0) {
super.onBackPressed();
} else {
FragmentManager.BackStackEntry backEntry = getSupportFragmentManager().
getBackStackEntryAt(backStackEntryCount - 1);
FragmentManager.BackStackEntry backEntry = getSupportFragmentManager().getBackStackEntryAt(backStackEntryCount - 1);
String tag = backEntry.getName();
if (PaymentMethodSelectionFragment.class.getName().equals(tag)
|| LoadingScreenFragment.class.getName().equals(tag)) {
if (PaymentMethodSelectionFragment.class.getName().equals(tag) || LoadingScreenFragment.class.getName().equals(tag)) {
final Intent cancellationIntent = new Intent(Constants.PaymentRequest.PAYMENT_REQUEST_CANCELLED_INTENT);
LocalBroadcastManager.getInstance(this).sendBroadcast(cancellationIntent);
finish();
Expand Down Expand Up @@ -160,10 +162,8 @@ private void initializeFragment(final Intent intent) {

switch (fragmentId) {
case PAYMENT_METHOD_SELECTION_FRAGMENT: {
final ArrayList<PaymentMethod> preferredPaymentMethods = (ArrayList) bundle
.getSerializable(PREFERED_PAYMENT_METHODS);
final ArrayList<PaymentMethod> paymentMethods = (ArrayList) bundle
.getSerializable(PAYMENT_METHODS);
final ArrayList<PaymentMethod> preferredPaymentMethods = (ArrayList) bundle.getSerializable(PREFERED_PAYMENT_METHODS);
final ArrayList<PaymentMethod> paymentMethods = (ArrayList) bundle.getSerializable(PAYMENT_METHODS);

final PaymentMethodSelectionFragment paymentMethodSelectionFragment
= new PaymentMethodSelectionFragmentBuilder()
Expand All @@ -174,8 +174,7 @@ private void initializeFragment(final Intent intent) {
public void onPaymentMethodSelected(PaymentMethod paymentMethod) {
if (paymentMethod.isRedirectMethod()
|| (paymentMethod.isOneClick() && !paymentMethod.requiresInput())) {
final Intent intent = new Intent(context.getApplicationContext(),
TranslucentLoadingScreenActivity.class);
final Intent intent = new Intent(context.getApplicationContext(), TranslucentLoadingScreenActivity.class);
context.startActivity(intent);
}
Intent intent = new Intent(PAYMENT_METHOD_SELECTED_INTENT);
Expand All @@ -184,11 +183,7 @@ public void onPaymentMethodSelected(PaymentMethod paymentMethod) {
}
})
.build();



replaceFragment(paymentMethodSelectionFragment);

hideKeyboard();
break;
}
Expand All @@ -213,30 +208,24 @@ public void onCreditCardInfoProvided(CreditCardPaymentDetails creditCardPaymentD
}
})
.build();


replaceFragment(creditCardFragment, TAG_CREDIT_CARD_FRAGMENT);

break;
}
case ISSUER_SELECTION_FRAGMENT: {
final PaymentMethod paymentMethod = (PaymentMethod) bundle.getSerializable(PAYMENT_METHOD);

IssuerSelectionFragment issuerSelectionFragment = new IssuerSelectionFragmentBuilder()
.setPaymentMethod(paymentMethod)
.setIssuerSelectionListener(new IssuerSelectionFragment.IssuerSelectionListener() {
@Override
public void onIssuerSelected(String issuer) {
IdealPaymentDetails paymentDetails = new IdealPaymentDetails(paymentMethod.getInputDetails());
IssuerSelectionPaymentDetails paymentDetails = new IssuerSelectionPaymentDetails(paymentMethod.getInputDetails());
paymentDetails.fillIssuer(issuer);
final Intent intent = new Intent(Constants.PaymentRequest.PAYMENT_DETAILS_PROVIDED_INTENT);
intent.putExtra(PAYMENT_DETAILS, paymentDetails);
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
}
})
.build();


replaceFragment(issuerSelectionFragment);
break;
}
Expand All @@ -258,10 +247,30 @@ public void onPaymentDetails(String iban, String accountHolder) {
}
})
.build();

replaceFragment(sepaDirectDebitFragment);
break;
}
case QIWI_WALLET_FRAGMENT: {
final PaymentMethod paymentMethod = (PaymentMethod) bundle.getSerializable(PAYMENT_METHOD);
paymentMethod.getInputDetails();
QiwiWalletFragment qiwiWalletFragment = new QiwiWalletFragmentBuilder()
.setAmount((Amount) intent.getSerializableExtra(AMOUNT))
.setPaymentMethod(paymentMethod)
.setQiwiWalletPaymentDetailsListener(new QiwiWalletFragment.QiwiWalletPaymentDetailsListener() {
@Override
public void onPaymentDetails(String countryCode, String telephoneNumber) {
QiwiWalletPaymentDetails paymentDetails = new QiwiWalletPaymentDetails(paymentMethod.getInputDetails());
paymentDetails.fillTelephoneNumber(countryCode, telephoneNumber);

final Intent intent = new Intent(Constants.PaymentRequest.PAYMENT_DETAILS_PROVIDED_INTENT);
intent.putExtra(PAYMENT_DETAILS, paymentDetails);
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
}
})
.build();
replaceFragment(qiwiWalletFragment);
break;
}
case GIROPAY_FRAGMENT: {
final GiropayFragment giropayFragment = new GiropayFragment();

Expand Down Expand Up @@ -298,9 +307,13 @@ public void onClick(View v) {
}

public void setActionBarTitle(int titleId) {
setActionBarTitle(getString(titleId));
}

public void setActionBarTitle(String title) {
ActionBar actionBar = getActionBar();
if (actionBar != null && actionBar.getCustomView() != null) {
((TextView) actionBar.getCustomView().findViewById(R.id.action_bar_title)).setText(getString(titleId));
((TextView) actionBar.getCustomView().findViewById(R.id.action_bar_title)).setText(title);
actionBar.show();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class CreditCardFragment extends Fragment implements CreditCardEditText.C
private CreditCardInfoListener creditCardInfoListener;
private boolean oneClick;
private boolean nameRequired;
private boolean storeDetailsOptionAvailable;
private Amount amount;
private String shopperReference;
private PaymentMethod paymentMethod;
Expand Down Expand Up @@ -124,8 +125,15 @@ public void setArguments(final Bundle args) {
cvcFieldStatus = CreditCardFragmentBuilder.CvcFieldStatus.valueOf(args.getString(Constants.DataKeys.CVC_FIELD_STATUS));

for (InputDetail inputDetail : paymentMethod.getInputDetails()) {
if (inputDetail.getKey().equals("cardHolderName")) {
nameRequired = true;
if (CreditCardPaymentDetails.ADDITIONAL_DATA_CARD.equals(inputDetail.getKey())) {
if (inputDetail.getConfiguration() != null
&& inputDetail.getConfiguration().containsKey(CreditCardPaymentDetails.CARD_HOLDER_NAME_REQUIRED)
&& "true".equalsIgnoreCase(inputDetail.getConfiguration().get(CreditCardPaymentDetails.CARD_HOLDER_NAME_REQUIRED))) {
nameRequired = true;
}
}
if (inputDetail.getKey().equals("storeDetails")) {
storeDetailsOptionAvailable = true;
}
}

Expand Down Expand Up @@ -305,7 +313,7 @@ public void onReadyStateChanged(boolean isReady) {
}

saveCardCheckBox = (CheckoutCheckBox) fragmentView.findViewById(R.id.save_card_checkbox);
if (!StringUtils.isEmptyOrNull(shopperReference)) {
if (!StringUtils.isEmptyOrNull(shopperReference) && storeDetailsOptionAvailable) {
fragmentView.findViewById(R.id.layout_save_card).setVisibility(VISIBLE);
fragmentView.findViewById(R.id.layout_click_area_save_card).setOnClickListener(new View.OnClickListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
fragmentView = localInflater.inflate(R.layout.issuer_selection_fragment, container, false);

for (InputDetail inputDetail : paymentMethod.getInputDetails()) {
if (inputDetail.getKey().equals("idealIssuer")) {
if (inputDetail.getKey().equals("idealIssuer") || inputDetail.getKey().equals("issuer")) {
issuers = inputDetail.getItems();
break;
}
Expand All @@ -85,7 +85,7 @@ public void onItemClick(final AdapterView<?> adapterView, final View view, final
});

if (getActivity() instanceof CheckoutActivity) {
((CheckoutActivity) getActivity()).setActionBarTitle(R.string.title_issuers);
((CheckoutActivity) getActivity()).setActionBarTitle(paymentMethod.getName());
}
return fragmentView;
}
Expand Down
Loading

0 comments on commit a6ffee5

Please sign in to comment.