Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PaymentSheet] Fix issue when used with hyperion and mochi #5321

Merged
merged 17 commits into from Jul 26, 2022

Conversation

michelleb-stripe
Copy link
Contributor

@michelleb-stripe michelleb-stripe commented Jul 25, 2022

Summary

When hyperion is present PaymentSheetLoading is not at the top of the stack. So instead of checking if it is at the top of the stack, check to see if it is anywhere in the stack.

Motivation

RUN_MOBILESDK-1268

Testing

  • Added tests
  • Modified tests
  • Manually verified by adding the hyperion dependencies and making sure PaymentSheet loads.

Changelog

[FIXED] Fixed issue when PaymentSheet never finishes loading.

@michelleb-stripe michelleb-stripe changed the title Fix issue when used with hyperion [Not ready for review] Fix issue when used with hyperion Jul 25, 2022
@@ -20,12 +20,5 @@
"schema": {
"nameType": "city"
}
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THis is a duplicate field, removing the duplicate

@@ -163,7 +163,12 @@ internal class PaymentSheetActivity : BaseSheetActivity<PaymentSheetResult>() {
if (config != null) {
// We only want to do this if the loading fragment is shown. Otherwise this causes
// a new fragment to be created if the activity was destroyed and recreated.
if (supportFragmentManager.fragments.firstOrNull() is PaymentSheetLoadingFragment) {
// If hyperion is an added dependency it is loaded on top of the
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix for when hyperion is a dependency

@@ -28,7 +28,7 @@ internal class LpmSerializer {
emptyList()
} else {
try {
format.decodeFromString<List<SharedDataSpec>>(serializer(), str)
format.decodeFromString<ArrayList<SharedDataSpec>>(serializer(), str)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ArrayList works for finding the deserializer

@github-actions
Copy link
Contributor

github-actions bot commented Jul 25, 2022

Diffuse output:

OLD: paymentsheet-example-release-master.apk (signature: none)
NEW: paymentsheet-example-release-pr.apk (signature: none)

          │           compressed           │           uncompressed           
          ├───────────┬───────────┬────────┼───────────┬───────────┬──────────
 APK      │ old       │ new       │ diff   │ old       │ new       │ diff     
──────────┼───────────┼───────────┼────────┼───────────┼───────────┼──────────
      dex │  15.3 MiB │  15.3 MiB │ +369 B │  51.7 MiB │  51.7 MiB │ +2.5 KiB 
     arsc │   1.8 MiB │   1.8 MiB │    0 B │   1.8 MiB │   1.8 MiB │      0 B 
 manifest │     4 KiB │     4 KiB │    0 B │  18.5 KiB │  18.5 KiB │      0 B 
      res │ 870.7 KiB │ 870.7 KiB │    0 B │   1.4 MiB │   1.4 MiB │      0 B 
   native │   2.5 MiB │   2.5 MiB │    0 B │   5.9 MiB │   5.9 MiB │      0 B 
    asset │     3 MiB │     3 MiB │ -531 B │     3 MiB │     3 MiB │   -635 B 
    other │  81.7 KiB │  81.7 KiB │    0 B │ 155.5 KiB │ 155.5 KiB │      0 B 
──────────┼───────────┼───────────┼────────┼───────────┼───────────┼──────────
    total │  23.5 MiB │  23.5 MiB │ -162 B │  63.9 MiB │  63.9 MiB │ +1.8 KiB 

         │          raw           │             unique              
         ├────────┬────────┬──────┼────────┬────────┬───────────────
 DEX     │ old    │ new    │ diff │ old    │ new    │ diff          
─────────┼────────┼────────┼──────┼────────┼────────┼───────────────
   files │      4 │      4 │    0 │        │        │               
 strings │ 250182 │ 250191 │   +9 │ 213288 │ 213298 │ +10 (+29 -19) 
   types │  44123 │  44125 │   +2 │  40501 │  40503 │  +2 (+3 -1)   
 classes │  37703 │  37705 │   +2 │  37703 │  37705 │  +2 (+3 -1)   
 methods │ 220549 │ 220564 │  +15 │ 212594 │ 212606 │ +12 (+33 -21) 
  fields │ 162584 │ 162588 │   +4 │ 161549 │ 161553 │  +4 (+9 -5)   

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  292 │  292 │  0   
 entries │ 6223 │ 6223 │  0
APK
    compressed    │    uncompressed     │                               
─────────┬────────┼──────────┬──────────┤                               
 size    │ diff   │ size     │ diff     │ path                          
─────────┼────────┼──────────┼──────────┼───────────────────────────────
 7.8 KiB │ -529 B │  7.7 KiB │   -529 B │ ∆ assets/dexopt/baseline.prof 
 3.2 MiB │ +346 B │    9 MiB │ +2.4 KiB │ ∆ classes4.dex                
 2.2 MiB │  +23 B │  6.8 MiB │   +108 B │ ∆ classes3.dex                
   259 B │   -2 B │    329 B │   -106 B │ ∆ assets/addressinfo/CI.json  
─────────┼────────┼──────────┼──────────┼───────────────────────────────
 5.4 MiB │ -162 B │ 15.8 MiB │ +1.8 KiB │ (total)
DEX
STRINGS:

   old    │ new    │ diff          
  ────────┼────────┼───────────────
   213288 │ 213298 │ +10 (+29 -19) 
  + SMAP
  PaymentSheetActivity.kt
  Kotlin
  *S Kotlin
  *F
  + 1 PaymentSheetActivity.kt
  com/stripe/android/paymentsheet/PaymentSheetActivity
  + 2 ActivityViewModelLazy.kt
  androidx/activity/ActivityViewModelLazyKt
  + 3 View.kt
  androidx/core/view/ViewKt
  + 4 FragmentManager.kt
  androidx/fragment/app/FragmentManagerKt
  + 5 _Collections.kt
  kotlin/collections/CollectionsKt___CollectionsKt
  *L
  1#1,364:1
  75#2,13:365
  254#3,2:378
  254#3,2:380
  38#3:382
  54#3:383
  254#3,2:396
  254#3,2:413
  254#3,2:415
  254#3,2:417
  26#4,12:384
  1547#5:398
  1618#5,3:399
  798#5,11:402
  *S KotlinDebug
  *F
  + 1 PaymentSheetActivity.kt
  com/stripe/android/paymentsheet/PaymentSheetActivity
  *L
  56#1:365,13
  125#1:378,2
  126#1:380,2
  134#1:382
  134#1:383
  260#1:396,2
  296#1:413,2
  297#1:415,2
  298#1:417,2
  215#1:384,12
  286#1:398
  286#1:399,3
  169#1:402,11
  *E
  
  + �
  ���
  ���
  
  ���
  ����Ç��2�0�J�����0�H�ø�ø��ø��¢���������
  ���
  ��!
  ��¡�0�¨��
  + 
  ���
  ��
  ���
  ���
  ��&
  ���
  ���
  ���
  ����2�0�B���¢����J��)��0�2��*��0+J��,��0�2��-��0+H�J��.������0�0/HÆ�R�����0�¢��
  ������R�����0�¢��
  ������R��	��0�¢��
  ���
  ��R�����0�¢��
  �����R��
  ��0�¢��
  ������R�����0�¢��
  ������R�����0�¢��
  ������R�����0�¢��
  ������R�����0�¢��
  ������R�����0�¢��
  ������R�����0�¢��
  ������R�����0�¢��
  ������R�����0�¢��
  ������R�����0�¢��
  ��� ��R��!��0�¢��
  �����R��#��0�¢��
  ���_��R��%��0�¢��
  ���&��R��'��0�¢��
  ���(��¨�0
  + &
  ���
  ���
  
  ���
  
  ���
  
  ���
  ���
  ���
  ������ �2�����00�:���B!��������0�������0���������0�¢����J�����0�H�ø�ø��ø��¢�����
  R�����0�¢��
  ���	�
  R�����0�¢��
  �����R�����0�¢��
  ���
  ��j���j���j���j���j���j���j���j������
  ���
  ��!
  ��¡�0�¨��
  + H
  ���
  ��
  
  ���
  
  ���
  
  ���
  ���
  ���
  
  ���
  
  ���
  ��
  ���
  ���
  ���
  
  ���
  ������ !2�0�:� !BM��������0���������0�������������0���0�j
  ����0���	�
  ���
  ����0��������0
  ¢����B1��������0�������������0�0�j�����0�	���
  ��0�¢����J!����0�2�����02�����0�2�����0�HÇ�R,��������0�0�j�����0�	8�X��¢��
  ������������R�����0�8�X��¢��
  ������������R��
  ��0�8�X��¢��
  ������������¨�
  + H
  ���
  ��
  
  ���
  
  ���
  
  ���
  
  ���
  ���
  ���
  
  ���
  ���
  ���
  ���
  ���
  
  ���
  ������� *2�0�:�)*BM��������0��
  ��������0���������0�������������0
  ��0	j
  ����0
  ����������0
  ¢����B1������0���������0�������������0
  0	j�����0
  �¢����J	����0�HÆ�J	����0�HÆ�J���������0
  0	j�����0
  �H�J7����02�������0�2�������0�2�����������0
  0	j�����0
  �HÆ�J�����0�2�������0�HÖ�J	� ��0�HÖ�J	�!��0�HÖ�J!���0#2��_��02��%��0&2��'��0(HÇ�R�����0�8�X��¢��
  ������������R,��������0
  0	j�����0
  �8�X��¢��
  ������������R�����0�8�X��¢��
  ������������¨�+
  + P
  
  ���
  
  �� 
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  ���
  ���
  
  ���
  ���
  ���
  ���
  ���
  �������������0�0�2��������0�0�H���������0�2��	����0
  H�������02��
  ����0�H�ø�¢����������0�2�����0�H�������0�2�����0�2�����0�H��&��������0���0�j
  ����0����2��	����0
  H����������0�0�*�����0�0�H����0�X��¢��
  ���
  ���¨��
  + (ILjava/lang/String;ZLjava/util/ArrayList;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
  + (IZLjava/util/ArrayList;Lcom/stripe/android/ui/core/address/NameType;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
  + (Ljava/lang/String;ILjava/lang/String;Lcom/stripe/android/ui/core/elements/IdentifierSpec;I)V
  + (Ljava/lang/String;ZLjava/util/ArrayList;)V
  + (ZLjava/util/ArrayList;Lcom/stripe/android/ui/core/address/NameType;)V
  + DependentLocality
  + Lcom/stripe/android/ui/core/address/FieldType__serializer;
  + Lcom/stripe/android/ui/core/address/FieldType_PostalCode;
  + Lcom/stripe/android/ui/core/address/FieldType_SortingCode;
  + SMAP
  FieldValuesToParamsMapConverter.kt
  Kotlin
  *S Kotlin
  *F
  + 1 FieldValuesToParamsMapConverter.kt
  com/stripe/android/ui/core/FieldValuesToParamsMapConverter_Companion
  + 2 Maps.kt
  kotlin/collections/MapsKt__MapsKt
  + 3 _Collections.kt
  kotlin/collections/CollectionsKt___CollectionsKt
  *L
  1#1,122:1
  438#2:123
  388#2:124
  453#2:129
  399#2:130
  1236#3,4:125
  1236#3,4:131
  1849#3,2:135
  *S KotlinDebug
  *F
  + 1 FieldValuesToParamsMapConverter.kt
  com/stripe/android/ui/core/FieldValuesToParamsMapConverter_Compa
...✂

@@ -103,7 +103,10 @@ class LpmRepository constructor(
serverLpmSpecs: String?,
force: Boolean = false
) {
if (!isLoaded() || force) {
// If the expectedLpms is different form last time, we still need to reload.
var lpmsNotParsedFromServerSpec = expectedLpms
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we get passed two different PMs with different values, we might need to reparse in the library to deserialize the new LPMs that we need.

showOptionalLabel = !addressField.required
val countryAddressElements = this
.filterNot {
it.type == FieldType.SortingCode ||
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are two new types that are valid, but we don't support showing.

import kotlinx.serialization.json.Json
import java.io.InputStream
import java.util.UUID

@Serializable(with = FieldTypeAsStringSerializer::class)
@Serializable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored this so we don't require a special deserializer.

@michelleb-stripe michelleb-stripe changed the title [Not ready for review] Fix issue when used with hyperion [PaymentSheet] Fix issue when used with hyperion and mochi Jul 26, 2022
CHANGELOG.md Outdated Show resolved Hide resolved
@michelleb-stripe michelleb-stripe merged commit 344d101 into master Jul 26, 2022
@michelleb-stripe michelleb-stripe deleted the michelleb/hyperion branch July 26, 2022 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants