Skip to content

Commit

Permalink
Version update: 3.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Владислав В. Багдей committed Jul 24, 2020
1 parent d5e7776 commit ee63caf
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 37 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Changelog

### 3.0.4
2020-07-24
- Bug fixes and improvements
- Fix scanning of Bank cards on some devices in demo app

### 3.0.3
2020-04-8
- Temporary measure: accepting expired cards (card expiry date must not be earlier than 2020-01-01)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# Документация

Android Checkout mobile SDK - версия 3.0.3 ([changelog](https://github.com/yandex-money/yandex-checkout-android-sdk/blob/master/CHANGELOG.md))
Android Checkout mobile SDK - версия 3.0.4 ([changelog](https://github.com/yandex-money/yandex-checkout-android-sdk/blob/master/CHANGELOG.md))

* [Подключение зависимостей](#подключение-зависимостей)
* [Подключение через Gradle](#подключение-через-Gradle)
Expand Down Expand Up @@ -42,7 +42,7 @@ repositories {
}
dependencies {
implementation 'com.yandex.money:checkout:3.0.3'
implementation 'com.yandex.money:checkout:3.0.4'
}
```

Expand Down Expand Up @@ -277,7 +277,7 @@ public final class MainActivity extends AppCompatActivity {

Поля класса `TestParameters:`
* showLogs (Boolean) - включить отображение логов SDK. Все логи начинаются с тега 'Yandex.Checkout.SDK'
* googlePayTestEnvironment (Boolean) - использовать тестовую среду Google Pay - все транзакции, проведенные через Google Pay, будут использовать `WalletConstants.ENVIRONMENT_TEST`. Подробнее см. на https://developers.google.com/pay/api/android/guides/test-and-deploy/integration-checklist#about-the-test-environment.
* googlePayTestEnvironment (Boolean) - использовать тестовую среду Google Pay - все транзакции, проведенные через Google Pay, будут использовать `WalletConstants.ENVIRONMENT_TEST`. Имейте ввиду, что при попытке оплаты с параметром googlePayTestEnvironment=true произойдет ошибка токенизации. Подробнее см. на https://developers.google.com/pay/api/android/guides/test-and-deploy/integration-checklist#about-the-test-environment.
* mockConfiguration (MockConfiguration) - использовать моковую конфигурацию. Если этот параметр присутствует, SDK будет работать в оффлайн режиме и генерировать тестовый токен. Этот токен нельзя использовать для платежей.

`MockConfiguration`
Expand Down
25 changes: 13 additions & 12 deletions common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ apply from: rootProject.file("sensitive.gradle")
ext {
versionMajor = 3
versionMinor = 0
versionPatch = 3
versionPatch = 4

versionAlpha = null

Expand All @@ -33,20 +33,21 @@ ext {

generateFileName = { project, variant ->
def fileNameParts = [
variant.name,
"msdk",
getBuildBranch().replaceAll(/[^\w-.]/, "-"),
variant.getFlavorName(),
variant.buildType.name,
project.versionName,
project.ext.has('teamcity.buildConfName') ? project.ext['teamcity.buildConfName'] : "local",
project.ext.has('build.number') ? project.ext['build.number'] : "0"
getBuildNumber()
]
return fileNameParts.join('-')
}

if (variant.productFlavors.find { it.name.equalsIgnoreCase("prod") }) {
fileNameParts += optionalProperty('defaultProdYandexAuthToken') ? "hasYandexToken" : "noYandexToken"
fileNameParts += optionalProperty('defaultProdPaymentAuthToken') ? "hasPaymentToken" : "noPaymentToken"
} else if (variant.productFlavors.find { it.name.equalsIgnoreCase("dev") }) {
fileNameParts += optionalProperty('defaultDevYandexAuthToken') ? "hasYandexToken" : "noYandexToken"
fileNameParts += optionalProperty('defaultDevPaymentAuthToken') ? "hasPaymentToken" : "noPaymentToken"
}
getBuildBranch = {
System.getenv('BUILD_BRANCH') ?: 'local'
}

return fileNameParts.join('-')
getBuildNumber = {
System.getenv('BUILD_NUMBER') ?: '0'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ package ru.yandex.money.android.sdk.impl
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.os.PersistableBundle
import android.support.v4.app.FragmentManager
import android.support.v7.app.AppCompatActivity
import android.util.Log
import ru.yandex.money.android.sdk.SavedBankCardPaymentParameters
import ru.yandex.money.android.sdk.PaymentMethodType
import ru.yandex.money.android.sdk.PaymentParameters
Expand Down Expand Up @@ -60,6 +62,13 @@ internal class CheckoutActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
}

override fun onStart() {
super.onStart()
if (!AppModel.isInitialized) {
tokenize()
}
}

override fun onDestroy() {
detachMainDialogFragment()
super.onDestroy()
Expand Down Expand Up @@ -125,9 +134,7 @@ internal class CheckoutActivity : AppCompatActivity() {
}

private fun showDialog(supportFragmentManager: FragmentManager) {
findDialog(supportFragmentManager) ?: MainDialogFragment().apply {
supportFragmentManager.beginTransaction().add(this, TAG_BOTTOM_SHEET).commitNowAllowingStateLoss()
}
findDialog(supportFragmentManager) ?: MainDialogFragment().show(supportFragmentManager, TAG_BOTTOM_SHEET)
}

private fun findDialog(supportFragmentManager: FragmentManager) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ internal class MainDialogFragment : BottomSheetDialogFragment() {

private val paymentOptionListListener: (PaymentOptionListViewModel) -> Unit = {
if (it === PaymentOptionListCloseViewModel) {
dismiss()
dismissAllowingStateLoss()
} else {
if (isHidden) {
fragmentManager?.takeIf { !isStateSaved && isAdded }?.popBackStack()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ internal class ContractFragment : Fragment() {
}

nextButton.setOnClickListener {
view?.hideSoftKeyboard()
AppModel.tokenizeController(
TokenizeInputModel(
paymentOptionId = optionId,
Expand Down Expand Up @@ -133,6 +134,7 @@ internal class ContractFragment : Fragment() {
}

nextButton.setOnClickListener { _ ->
view?.hideSoftKeyboard()
val text = phoneInput.text
if (text != null && text.isPhoneNumber) {
AppModel.tokenizeController(
Expand Down Expand Up @@ -224,6 +226,7 @@ internal class ContractFragment : Fragment() {
requestFocusAndShowSoftKeyboard()
}
nextButton.setOnClickListener {
view?.hideSoftKeyboard()
processPaymentAuth()
}
}
Expand All @@ -238,6 +241,7 @@ internal class ContractFragment : Fragment() {

if (viewModel.googlePayContractViewModel != null) {
nextButton.setOnClickListener {
view?.hideSoftKeyboard()
rootContainer.showChild(loadingView)
AppModel.googlePayIntegration?.startGooglePayTokenization(
fragment = this,
Expand All @@ -264,7 +268,7 @@ internal class ContractFragment : Fragment() {
if (!isStateSaved) {
errorView.setErrorText(it.error)
errorView.setErrorButtonListener(View.OnClickListener {
AppModel.selectPaymentOptionController.retry()
AppModel.tokenizeController.retry()
})
rootContainer.showChild(errorView)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ internal class StateHolder(private val uiExecutor: Executor) {
inline fun <reified T : ViewModel> onEvent(event: T) {
lastState = event
for (entry in stateListeners) {
if (entry.key.java.isInstance(lastState)) {
if (entry.key.java.isInstance(event)) {
for (element in entry.value)
uiExecutor { (element as (T) -> Unit)(event) }
}
Expand Down
6 changes: 4 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ android {
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "ru.yandex.money.android.example"
minSdkVersion 15
minSdkVersion 16
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true

Expand All @@ -40,6 +40,7 @@ android {
buildConfigField "String", "MERCHANT_TOKEN", "${optionalProperty('merchantToken')}"
buildConfigField "String", "GATEWAY_ID", "${optionalProperty('gatewayId')}"
buildConfigField "String", "SHOP_ID", "${optionalProperty('shopId')}"

}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -93,7 +94,8 @@ dependencies {
releaseImplementation project(':library')
debugImplementation project(':library')
implementation 'com.yandex.android:authsdk:2.1.1'
implementation 'cards.pay:paycardsrecognizer:1.1.0'
implementation 'io.card:android-sdk:5.5.1'

testImplementation 'junit:junit:4.12'
testImplementation "org.mockito:mockito-core:$mockito_version"
testImplementation "org.robolectric:robolectric:3.8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,45 @@

package ru.yandex.money.android.example;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import cards.pay.paycardsrecognizer.sdk.Card;
import cards.pay.paycardsrecognizer.sdk.ScanCardIntent;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import io.card.payment.CardIOActivity;
import io.card.payment.CreditCard;
import ru.yandex.money.android.sdk.Checkout;

public class ScanBankCardActivity extends Activity {
public class ScanBankCardActivity extends AppCompatActivity {

public static final int REQUEST_CODE = 1;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Intent intent = new ScanCardIntent.Builder(this).build();
startActivityForResult(intent, REQUEST_CODE);
Intent scanIntent = new Intent(this, CardIOActivity.class);
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true);
startActivityForResult(scanIntent, REQUEST_CODE);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (requestCode == REQUEST_CODE) {
if (resultCode == RESULT_OK && data != null) {
final Card card = data.getParcelableExtra(ScanCardIntent.RESULT_PAYCARDS_CARD);
final String expirationDate = card.getExpirationDate();
if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) {
CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT);
final String cardNumber = scanResult.getFormattedCardNumber();

if (expirationDate != null) {
final String[] expirationDateParts = expirationDate.split("/");
if (scanResult.isExpiryValid() && scanResult.getRedactedCardNumber() != null &&
!scanResult.getRedactedCardNumber().isEmpty()) {
final Intent scanBankCardResult = Checkout.createScanBankCardIntent(
card.getCardNumber(),
Integer.parseInt(expirationDateParts[0]),
Integer.parseInt(expirationDateParts[1]));
cardNumber,
scanResult.expiryMonth,
scanResult.expiryYear % 100
);
setResult(RESULT_OK, scanBankCardResult);
} else {
setResult(RESULT_CANCELED);
Expand Down

0 comments on commit ee63caf

Please sign in to comment.