package Ġabi 4 5 _ 0 _ 0 . host . exp . exponent . modules . api . components . react n ativ est ri pes dk Ċ Ċ import Ġandroid . app . Activity Ċ import Ġandroid . content . Broadcast Receiver Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . content . Intent Filter Ċ import Ġandroid . os . Parcelable Ċ import Ġandroid . util . Log Ċ import Ġandroidx . activity . Component Activity Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroidx . local broadcast manager . content . Local Broadcast Manager Ċ import Ġabi 4 5 _ 0 _ 0 . com . facebook . react . bridge .* Ċ import Ġabi 4 5 _ 0 _ 0 . com . facebook . react . module . annotations . React Module Ċ import Ġcom . stripe . android .* Ċ import Ġcom . stripe . android . google pay launcher . Google Pay Launcher Ċ import Ġcom . stripe . android . google pay launcher . Google Pay PaymentMethod Launcher Ċ import Ġcom . stripe . android . model .* Ċ import Ġcom . stripe . android . payments heet . Payment Sheet Result Ċ import Ġcom . stripe . android . view . Add PaymentMethod Activity Starter Ċ import Ġkotlinx . coroutines . Coroutine Scope Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . launch Ċ Ċ @ React Module ( name Ġ= ĠStripe Sdk Module . NAME ) Ċ class ĠStripe Sdk Module ( react Context : ĠReact ApplicationContext ) Ġ: ĠReact Context Base Java Module ( react Context ) Ġ{ ĊĠ Ġvar Ġcard Field View : ĠCard Field View ? Ġ= Ġnull ĊĠ Ġvar Ġcard Form View : ĠCard Form View ? Ġ= Ġnull ĊĊĠ Ġoverride Ġfun ĠgetName (): ĠString Ġ{ ĊĠĠĠ Ġreturn Ġ" Stripe Sdk " ĊĠ Ġ} ĊĠ Ġprivate Ġlateinit Ġvar Ġstripe : ĠStripe ĊĊĠ Ġprivate Ġlateinit Ġvar Ġpayment Launcher Fragment : ĠPayment Launcher Fragment ĊĊĠ Ġprivate Ġlateinit Ġvar Ġpublish able Key : ĠString ĊĠ Ġprivate Ġvar Ġstripe AccountId : ĠString ? Ġ= Ġnull ĊĠ Ġprivate Ġvar Ġpayment Sheet Fragment : ĠPayment Sheet Fragment ? Ġ= Ġnull ĊĊĠ Ġprivate Ġvar Ġurl Scheme : ĠString ? Ġ= Ġnull ĊĠ Ġprivate Ġvar Ġconfirm Promise : ĠPromise ? Ġ= Ġnull ĊĠ Ġprivate Ġvar Ġconfirm Setup Intent Promise : ĠPromise ? Ġ= Ġnull ĊĠ Ġprivate Ġvar Ġconfirm Payment Sheet Payment Promise : ĠPromise ? Ġ= Ġnull ĊĠ Ġprivate Ġvar Ġpresent Payment Sheet Promise : ĠPromise ? Ġ= Ġnull ĊĠ Ġprivate Ġvar Ġinit Payment Sheet Promise : ĠPromise ? Ġ= Ġnull ĊĠ Ġprivate Ġvar Ġconfirm Payment Client Secret : ĠString ? Ġ= Ġnull ĊĊĠ Ġprivate Ġvar Ġgoogle Pay Fragment : ĠGoogle Pay Fragment ? Ġ= Ġnull ĊĠ Ġprivate Ġvar Ġinit Google Pay Promise : ĠPromise ? Ġ= Ġnull ĊĠ Ġprivate Ġvar Ġpresent Google Pay Promise : ĠPromise ? Ġ= Ġnull ĊĊĠ Ġprivate Ġval Ġm Activity EventListener Ġ= Ġobject Ġ: ĠBase Activity EventListener () Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġon Activity Result ( activity : ĠActivity , Ġrequest Code : ĠInt , ĠresultCode : ĠInt , Ġdata : ĠIntent ?) Ġ{ ĊĠĠĠĠĠ Ġif Ġ(:: stripe . isInitialized ) Ġ{ ĊĠĠĠĠĠĠĠ Ġstripe . on Setup Result ( ĊĠĠĠĠĠĠĠĠĠ Ġrequest Code , Ġdata , ĊĠĠĠĠĠĠĠĠĠ Ġobject Ġ: ĠApi Result Callback < Setup Intent Result > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun ĠonSuccess ( result : ĠSetup Intent Result ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġsetup Intent Ġ= Ġresult . intent ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġwhen Ġ( setup Intent . status ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠStripe Intent . Status . Succeeded Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġconfirm Setup Intent Promise ?. resolve ( create Result (" setup Intent ", Ġmap From Setup Intent Result ( setup Intent ))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠStripe Intent . Status . Canceled Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġconfirm Setup Intent Promise ?. resolve ( create Error ( Confirm Setup Intent ErrorType . Canceled . toString (), Ġsetup Intent . last Setup Error )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠStripe Intent . Status . Requires Action Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġconfirm Setup Intent Promise ?. resolve ( create Error ( Confirm Setup Intent ErrorType . Canceled . toString (), Ġsetup Intent . last Setup Error )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval ĠerrorMessage Ġ= Ġ" un handled Ġerror : Ġ${ setup Intent . status }" ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġconfirm Setup Intent Promise ?. resolve ( create Error ( Confirm Setup Intent ErrorType . Failed . toString (), ĠerrorMessage )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun ĠonError ( e : ĠException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġconfirm Setup Intent Promise ?. resolve ( create Error ( Confirm Setup Intent ErrorType . Failed . toString (), Ġe )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġpayment Sheet Fragment ?. activity ?. activity Result Registry ?. dispatch Result ( request Code , ĠresultCode , Ġdata ) ĊĠĠĠĠĠĠĠ Ġgoogle Pay Fragment ?. activity ?. activity Result Registry ?. dispatch Result ( request Code , ĠresultCode , Ġdata ) ĊĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠAdd PaymentMethod Activity Starter . Result . from Intent ( data ) ĊĠĠĠĠĠĠĠĠĠ Ġif Ġ( data ?. get Parcelable Extra < Parcelable >(" extra _ activity _ result ") Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon F px PaymentMethod Result ( result ) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : Ġjava . lang . Exception ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ ĠLog . d (" Error ", Ġe . localized Message Ġ?: Ġe . toString ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġreact Context . add Activity EventListener ( m Activity EventListener ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġconfigure 3 d Secure ( params : ĠRead able Map ) Ġ{ ĊĠĠĠ Ġval Ġstripe 3 ds Config Builder Ġ= ĠPayment Auth Config . Stripe 3 ds 2 Config . Builder () ĊĠĠĠ Ġif Ġ( params . has Key (" timeout ")) Ġstripe 3 ds Config Builder . setTimeout ( params . getInt (" timeout ")) ĊĠĠĠ Ġval Ġui Custom ization Ġ= Ġmap To UIC ustom ization ( params ) ĊĊĠĠĠ ĠPayment Auth Config . init ( ĊĠĠĠĠĠ ĠPayment Auth Config . Builder () ĊĠĠĠĠĠĠĠ Ġ. set 3 ds 2 Config ( ĊĠĠĠĠĠĠĠĠĠ Ġstripe 3 ds Config Builder ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Ui Custom ization ( ui Custom ization ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġval Ġgoogle Pay Receiver : ĠBroadcast Receiver Ġ= Ġobject Ġ: ĠBroadcast Receiver () Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġon Receive ( context : ĠContext ?, Ġintent : ĠIntent ) Ġ{ ĊĠĠĠĠĠ Ġif Ġ( intent . action Ġ== ĠON _ GOOGLE _ PAY _ FRAGMENT _ CREATED ) Ġ{ ĊĠĠĠĠĠĠĠ Ġgoogle Pay Fragment Ġ= Ġ( current Activity Ġas ĠAppCompatActivity ). support FragmentManager . find Fragment By Tag (" google _ pay _ launch _ fragment ") Ġas ĠGoogle Pay Fragment ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġif Ġ( intent . action Ġ== ĠON _ INIT _ GOOGLE _ PAY ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġis Ready Ġ= Ġintent . extras ?. getBoolean (" is Ready ") Ġ?: Ġfalse ĊĊĠĠĠĠĠĠĠ Ġif Ġ( is Ready ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġinit Google Pay Promise ?. resolve ( Writable Native Map ()) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġinit Google Pay Promise ?. resolve ( create Error ( Google Pay ErrorType . Failed . toString (), Ġ" Google ĠPay Ġis Ġnot Ġavailable Ġon Ġthis Ġdevice ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġif Ġ( intent . action Ġ== ĠON _ GOOGLE _ PAYMENT _ METHOD _ RESULT ) Ġ{ ĊĠĠĠĠĠĠĠ Ġintent . extras ?. getString (" error ") ?. let Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġpresent Google Pay Promise ?. resolve ( create Error ( Google Pay ErrorType . Failed . toString (), Ġit )) ĊĠĠĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġwhen Ġ( val Ġresult Ġ= Ġintent . extras ?. get Parcelable < Google Pay PaymentMethod Launcher . Result >(" payment Result ")) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġis ĠGoogle Pay PaymentMethod Launcher . Result . Completed Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpresent Google Pay Promise ?. resolve ( create Result (" payment Method ", Ġmap From PaymentMethod ( result . payment Method ))) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠ ĠGoogle Pay PaymentMethod Launcher . Result . Canceled Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpresent Google Pay Promise ?. resolve ( create Error ( Google Pay ErrorType . Canceled . toString (), Ġ" Google ĠPay Ġhas Ġbeen Ġcanceled ")) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġis ĠGoogle Pay PaymentMethod Launcher . Result . Failed Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpresent Google Pay Promise ?. resolve ( create Error ( Google Pay ErrorType . Failed . toString (), Ġresult . error )) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġif Ġ( intent . action Ġ== ĠON _ GOOGLE _ PAY _ RESULT ) Ġ{ ĊĠĠĠĠĠĠĠ Ġintent . extras ?. getString (" error ") ?. let Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġpresent Google Pay Promise ?. resolve ( create Error ( Google Pay ErrorType . Failed . toString (), Ġit )) ĊĠĠĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġwhen Ġ( val Ġresult Ġ= Ġintent . extras ?. get Parcelable < Google Pay Launcher . Result >(" payment Result ")) Ġ{ ĊĠĠĠĠĠĠĠĠĠ ĠGoogle Pay Launcher . Result . Completed Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpresent Google Pay Promise ?. resolve ( Writable Native Map ()) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠ ĠGoogle Pay Launcher . Result . Canceled Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpresent Google Pay Promise ?. resolve ( create Error ( Google Pay ErrorType . Canceled . toString (), Ġ" Google ĠPay Ġhas Ġbeen Ġcanceled ")) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġis ĠGoogle Pay Launcher . Result . Failed Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpresent Google Pay Promise ?. resolve ( create Error ( Google Pay ErrorType . Failed . toString (), Ġresult . error )) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġval Ġm Payment Sheet Receiver : ĠBroadcast Receiver Ġ= Ġobject Ġ: ĠBroadcast Receiver () Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġon Receive ( context : ĠContext ?, Ġintent : ĠIntent ) Ġ{ ĊĠĠĠĠĠ Ġif Ġ( intent . action Ġ== ĠON _ PAYMENT _ RESULT _ ACTION ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen Ġ( val Ġresult Ġ= Ġintent . extras ?. get Parcelable < Payment Sheet Result >(" payment Result ")) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġis ĠPayment Sheet Result . Canceled Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmessage Ġ= Ġ" The Ġpayment Ġhas Ġbeen Ġcanceled " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconfirm Payment Sheet Payment Promise ?. resolve ( create Error ( Payment Sheet ErrorType . Canceled . toString (), Ġmessage )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpresent Payment Sheet Promise ?. resolve ( create Error ( Payment Sheet ErrorType . Canceled . toString (), Ġmessage )) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġis ĠPayment Sheet Result . Failed Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconfirm Payment Sheet Payment Promise ?. resolve ( create Error ( Payment Sheet ErrorType . Failed . toString (), Ġresult . error )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpresent Payment Sheet Promise ?. resolve ( create Error ( Payment Sheet ErrorType . Failed . toString (), Ġresult . error )) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġis ĠPayment Sheet Result . Completed Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconfirm Payment Sheet Payment Promise ?. resolve ( Writable Native Map ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpresent Payment Sheet Promise ?. resolve ( Writable Native Map ()) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} Ġelse Ġif Ġ( intent . action Ġ== ĠON _ PAYMENT _ OPTION _ ACTION ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlabel Ġ= Ġintent . extras ?. getString (" label ") ĊĠĠĠĠĠĠĠ Ġval Ġimage Ġ= Ġintent . extras ?. getString (" image ") ĊĊĠĠĠĠĠĠĠ Ġif Ġ( label Ġ!= Ġnull Ġ&& Ġimage Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġval Ġoption : ĠWrit able Map Ġ= ĠWrit able Native Map () ĊĠĠĠĠĠĠĠĠĠ Ġoption . putString (" label ", Ġlabel ) ĊĠĠĠĠĠĠĠĠĠ Ġoption . putString (" image ", Ġimage ) ĊĠĠĠĠĠĠĠĠĠ Ġpresent Payment Sheet Promise ?. resolve ( create Result (" payment Option ", Ġoption )) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġpresent Payment Sheet Promise ?. resolve ( Writable Native Map ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġpresent Payment Sheet Promise Ġ= Ġnull ĊĠĠĠĠĠ Ġ} Ġelse Ġif Ġ( intent . action Ġ== ĠON _ INIT _ PAYMENT _ SHE ET ) Ġ{ ĊĠĠĠĠĠĠĠ Ġinit Payment Sheet Promise ?. resolve ( Writable Native Map ()) ĊĠĠĠĠĠ Ġ} Ġelse Ġif Ġ( intent . action Ġ== ĠON _ CONFIGURE _ FLOW _ CONTROLLER ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlabel Ġ= Ġintent . extras ?. getString (" label ") ĊĠĠĠĠĠĠĠ Ġval Ġimage Ġ= Ġintent . extras ?. getString (" image ") ĊĊĠĠĠĠĠĠĠ Ġif Ġ( label Ġ!= Ġnull Ġ&& Ġimage Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġval Ġoption : ĠWrit able Map Ġ= ĠWrit able Native Map () ĊĠĠĠĠĠĠĠĠĠ Ġoption . putString (" label ", Ġlabel ) ĊĠĠĠĠĠĠĠĠĠ Ġoption . putString (" image ", Ġimage ) ĊĠĠĠĠĠĠĠĠĠ Ġinit Payment Sheet Promise ?. resolve ( create Result (" payment Option ", Ġoption )) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġinit Payment Sheet Promise ?. resolve ( Writable Native Map ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġinitialise ( params : ĠRead able Map , Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ Ġval Ġpublish able Key Ġ= Ġget Val Or ( params , Ġ" publish able Key ", Ġnull ) Ġas ĠString ĊĠĠĠ Ġval Ġapp Info Ġ= Ġget Map OrNull ( params , Ġ" app Info ") Ġas ĠRead able Map ĊĠĠĠ Ġthis . stripe AccountId Ġ= Ġget Val Or ( params , Ġ" stripe AccountId ", Ġnull ) ĊĠĠĠ Ġval Ġurl Scheme Ġ= Ġget Val Or ( params , Ġ" url Scheme ", Ġnull ) ĊĠĠĠ Ġval Ġset Return Url Scheme On Android Ġ= Ġget Boolean Or False ( params , Ġ" set Return Url Scheme On Android ") ĊĠĠĠ Ġthis . url Scheme Ġ= Ġif Ġ( set Return Url Scheme On Android ) Ġurl Scheme Ġelse Ġnull ĊĊĠĠĠ Ġget Map OrNull ( params , Ġ" three D Secure Params ") ?. let Ġ{ ĊĠĠĠĠĠ Ġconfigure 3 d Secure ( it ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġthis . publish able Key Ġ= Ġpublish able Key ĊĊĠĠĠ Ġval Ġname Ġ= Ġget Val Or ( app Info , Ġ" name ", Ġ"") Ġas ĠString ĊĠĠĠ Ġval Ġpartner Id Ġ= Ġget Val Or ( app Info , Ġ" partner Id ", Ġ"") ĊĠĠĠ Ġval Ġversion Ġ= Ġget Val Or ( app Info , Ġ" version ", Ġ"") ĊĊĠĠĠ Ġval Ġurl Ġ= Ġget Val Or ( app Info , Ġ" url ", Ġ"") ĊĠĠĠ ĠStripe . app Info Ġ= ĠApp Info . create ( name , Ġversion , Ġurl , Ġpartner Id ) ĊĠĠĠ Ġstripe Ġ= ĠStripe ( react ApplicationContext , Ġpublish able Key , Ġstripe AccountId ) ĊĊĠĠĠ ĠPayment Configuration . init ( react ApplicationContext , Ġpublish able Key , Ġstripe AccountId ) ĊĊĠĠĠ Ġpayment Launcher Fragment Ġ= ĠPayment Launcher Fragment ( stripe , Ġpublish able Key , Ġstripe AccountId ) ĊĠĠĠ Ġ( current Activity Ġas ĠAppCompatActivity ). support FragmentManager . beginTransaction () ĊĠĠĠĠĠ Ġ. add ( payment Launcher Fragment , Ġ" payment _ launcher _ fragment ") ĊĠĠĠĠĠ Ġ. commit () ĊĊĠĠĠ Ġval Ġlocal Broadcast Manager Ġ= ĠLocal Broadcast Manager . getInstance ( react ApplicationContext ) ĊĠĠĠ Ġlocal Broadcast Manager . register Receiver ( m Payment Sheet Receiver , ĠIntent Filter ( ON _ PAYMENT _ RESULT _ ACTION )) ĊĠĠĠ Ġlocal Broadcast Manager . register Receiver ( m Payment Sheet Receiver , ĠIntent Filter ( ON _ PAYMENT _ OPTION _ ACTION )) ĊĠĠĠ Ġlocal Broadcast Manager . register Receiver ( m Payment Sheet Receiver , ĠIntent Filter ( ON _ CONFIGURE _ FLOW _ CONTROLLER )) ĊĠĠĠ Ġlocal Broadcast Manager . register Receiver ( m Payment Sheet Receiver , ĠIntent Filter ( ON _ INIT _ PAYMENT _ SHE ET )) ĊĊĠĠĠ Ġlocal Broadcast Manager . register Receiver ( google Pay Receiver , ĠIntent Filter ( ON _ GOOGLE _ PAY _ FRAGMENT _ CREATED )) ĊĠĠĠ Ġlocal Broadcast Manager . register Receiver ( google Pay Receiver , ĠIntent Filter ( ON _ INIT _ GOOGLE _ PAY )) ĊĠĠĠ Ġlocal Broadcast Manager . register Receiver ( google Pay Receiver , ĠIntent Filter ( ON _ GOOGLE _ PAY _ RESULT )) ĊĠĠĠ Ġlocal Broadcast Manager . register Receiver ( google Pay Receiver , ĠIntent Filter ( ON _ GOOGLE _ PAYMENT _ METHOD _ RESULT )) ĊĊĠĠĠ Ġpromise . resolve ( null ) ĊĠ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġinit Payment Sheet ( params : ĠRead able Map , Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ Ġval Ġactivity Ġ= Ġcurrent Activity Ġas ĠAppCompatActivity ? ĊĊĠĠĠ Ġif Ġ( activity Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġpromise . resolve ( create Error (" Failed ", Ġ" Activity Ġdoesn 't Ġexist ")) ĊĠĠĠĠĠ Ġreturn ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġthis . init Payment Sheet Promise Ġ= Ġpromise ĊĊĠĠĠ Ġpayment Sheet Fragment Ġ= ĠPayment Sheet Fragment (). also Ġ{ ĊĠĠĠĠĠ Ġval Ġbundle Ġ= Ġto Bundle Object ( params ) ĊĠĠĠĠĠ Ġit . arguments Ġ= Ġbundle ĊĠĠĠ Ġ} ĊĠĠĠ Ġactivity . support FragmentManager . beginTransaction () ĊĠĠĠĠĠ Ġ. add ( payment Sheet Fragment !! , Ġ" payment _ sheet _ launch _ fragment ") ĊĠĠĠĠĠ Ġ. commit () ĊĠ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġpresent Payment Sheet ( promise : ĠPromise ) Ġ{ ĊĠĠĠ Ġthis . present Payment Sheet Promise Ġ= Ġpromise ĊĠĠĠ Ġpayment Sheet Fragment ?. present () ĊĠ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġconfirm Payment Sheet Payment ( promise : ĠPromise ) Ġ{ ĊĠĠĠ Ġthis . confirm Payment Sheet Payment Promise Ġ= Ġpromise ĊĠĠĠ Ġpayment Sheet Fragment ?. confirm Payment () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġpay With F px () Ġ{ ĊĠĠĠ ĠAdd PaymentMethod Activity Starter ( current Activity Ġas ĠAppCompatActivity ) ĊĠĠĠĠĠ Ġ. start For Result ( ĊĠĠĠĠĠĠĠ ĠAdd PaymentMethod Activity Starter . Args . Builder () ĊĠĠĠĠĠĠĠĠĠ Ġ. set Payment MethodType ( PaymentMethod . Type . F px ) ĊĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġon F px PaymentMethod Result ( result : ĠAdd PaymentMethod Activity Starter . Result ) Ġ{ ĊĠĠĠ Ġwhen Ġ( result ) Ġ{ ĊĠĠĠĠĠ Ġis ĠAdd PaymentMethod Activity Starter . Result . Success Ġ-> Ġ{ ĊĠĠĠĠĠĠĠ Ġpayment Launcher Fragment . payment Launcher . confirm ( ĊĠĠĠĠĠĠĠĠĠ ĠConfirm Payment Intent Params . create With PaymentMethod Id ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . payment Method . id !! , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconfirm Payment Client Secret !! ĊĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġis ĠAdd PaymentMethod Activity Starter . Result . Failure Ġ-> Ġ{ ĊĠĠĠĠĠĠĠ Ġconfirm Promise ?. resolve ( create Error ( Confirm Payment ErrorType . Failed . toString (), Ġresult . exception )) ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġis ĠAdd PaymentMethod Activity Starter . Result . Canceled Ġ-> Ġ{ ĊĠĠĠĠĠĠĠ Ġconfirm Promise ?. resolve ( create Error ( Confirm Payment ErrorType . Canceled . toString (), Ġ" The Ġpayment Ġhas Ġbeen Ġcanceled ")) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġthis . confirm Payment Client Secret Ġ= Ġnull ĊĠ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġcreate PaymentMethod ( data : ĠRead able Map , Ġoptions : ĠRead able Map , Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ Ġval Ġcard Params Ġ= Ġ( card Field View ?. card Params Ġ?: Ġcard Form View ?. card Params ) Ġ?: Ġrun Ġ{ ĊĠĠĠĠĠ Ġpromise . resolve ( create Error (" Failed ", Ġ" Card Ġdetails Ġnot Ġcomplete ")) ĊĠĠĠĠĠ Ġreturn ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġcard Address Ġ= Ġcard Field View ?. card Address Ġ?: Ġcard Form View ?. card Address ĊĊĠĠĠ Ġval Ġbilling Details Params Ġ= Ġmap To Billing Details ( getMap OrNull ( data , Ġ" billing Details "), Ġcard Address ) ĊĊĠĠĠ Ġval Ġpayment Method Create Params Ġ= ĠPayment Method Create Params . create ( card Params , Ġbilling Details Params ) ĊĠĠĠ Ġstripe . create PaymentMethod ( ĊĠĠĠĠĠ Ġpayment Method Create Params , ĊĠĠĠĠĠ Ġcallback Ġ= Ġobject Ġ: ĠApi Result Callback < PaymentMethod > Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun ĠonError ( e : ĠException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġpromise . resolve ( create Error (" Failed ", Ġe )) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġoverride Ġfun ĠonSuccess ( result : ĠPayment Method ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġval Ġpayment Method Map : ĠWrit able Map Ġ= Ġmap From PaymentMethod ( result ) ĊĠĠĠĠĠĠĠĠĠ Ġpromise . resolve ( create Result (" payment Method ", Ġpayment Method Map )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġcreate Token ( params : ĠRead able Map , Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ Ġval Ġtype Ġ= Ġget Val Or ( params , Ġ" type ", Ġnull ) ĊĠĠĠ Ġif Ġ( type Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġpromise . resolve ( create Error ( Create Token ErrorType . Failed . toString (), Ġ" type Ġparameter Ġis Ġrequired ")) ĊĠĠĠĠĠ Ġreturn ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġwhen Ġ( type ) Ġ{ ĊĠĠĠĠĠ Ġ" Bank Account " Ġ-> Ġ{ ĊĠĠĠĠĠĠĠ Ġcreate Token From Bank Account ( params , Ġpromise ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ" Card " Ġ-> Ġ{ ĊĠĠĠĠĠĠĠ Ġcreate Token From Card ( params , Ġpromise ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġelse Ġ-> Ġ{ ĊĠĠĠĠĠĠĠ Ġpromise . resolve ( create Error ( Create Token ErrorType . Failed . toString (), Ġ"$ type Ġtype Ġis Ġnot Ġsupported Ġyet ")) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcreate Token From Bank Account ( params : ĠRead able Map , Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ Ġval Ġaccount Holder Name Ġ= Ġget Val Or ( params , Ġ" account Holder Name ", Ġnull ) ĊĠĠĠ Ġval Ġaccount Holder Type Ġ= Ġget Val Or ( params , Ġ" account Holder Type ", Ġnull ) ĊĠĠĠ Ġval Ġaccount Number Ġ= Ġget Val Or ( params , Ġ" account Number ", Ġnull ) ĊĠĠĠ Ġval Ġcountry Ġ= Ġget Val Or ( params , Ġ" country ", Ġnull ) ĊĠĠĠ Ġval Ġcurrency Ġ= Ġget Val Or ( params , Ġ" currency ", Ġnull ) ĊĠĠĠ Ġval Ġrouting Number Ġ= Ġget Val Or ( params , Ġ" routing Number ", Ġnull ) ĊĊĠĠĠ Ġval Ġbank Account Params Ġ= ĠBank Account Token Params ( ĊĠĠĠĠĠ Ġcountry Ġ= Ġcountry !! , ĊĠĠĠĠĠ Ġcurrency Ġ= Ġcurrency !! , ĊĠĠĠĠĠ Ġaccount Number Ġ= Ġaccount Number !! , ĊĠĠĠĠĠ Ġaccount Holder Name Ġ= Ġaccount Holder Name , ĊĠĠĠĠĠ Ġrouting Number Ġ= Ġrouting Number , ĊĠĠĠĠĠ Ġaccount Holder Type Ġ= Ġmap To Bank Account Type ( account Holder Type ) ĊĠĠĠ Ġ) ĊĠĠĠ ĠCor outine Scope ( Dispatch ers . IO ). launch Ġ{ ĊĠĠĠĠĠ Ġrun Catch ing Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtoken Ġ= Ġstripe . create Bank Account Token ( bank Account Params , Ġnull , Ġstripe AccountId ) ĊĠĠĠĠĠĠĠ Ġpromise . resolve ( create Result (" token ", Ġmap From Token ( token ))) ĊĠĠĠĠĠ Ġ}. on Failure Ġ{ ĊĠĠĠĠĠĠĠ Ġpromise . resolve ( create Error ( Create Token ErrorType . Failed . toString (), Ġit . message )) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcreate Token From Card ( params : ĠRead able Map , Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ Ġval Ġcard Params Map Ġ= Ġ( card Field View ?. card Params Ġ?: Ġcard Form View ?. card Params )?. to Param Map () ĊĠĠĠĠĠ Ġ?: Ġrun Ġ{ ĊĠĠĠĠĠĠĠ Ġpromise . resolve ( create Error ( Create Token ErrorType . Failed . toString (), Ġ" Card Ġdetails Ġnot Ġcomplete ")) ĊĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġcard Address Ġ= Ġcard Field View ?. card Address Ġ?: Ġcard Form View ?. card Address ĊĠĠĠ Ġval Ġaddress Ġ= Ġget Map OrNull ( params , Ġ" address ") ĊĠĠĠ Ġval Ġcard Params Ġ= ĠCard Params ( ĊĠĠĠĠĠ Ġnumber Ġ= Ġcard Params Map [" number "] Ġas ĠString , ĊĠĠĠĠĠ Ġexp Month Ġ= Ġcard Params Map [" exp _ month "] Ġas ĠInt , ĊĠĠĠĠĠ Ġexp Year Ġ= Ġcard Params Map [" exp _ year "] Ġas ĠInt , ĊĠĠĠĠĠ Ġc vc Ġ= Ġcard Params Map [" cv c "] Ġas ĠString , ĊĠĠĠĠĠ Ġaddress Ġ= Ġmap To Address ( address , Ġcard Address ), ĊĠĠĠĠĠ Ġname Ġ= Ġget Val Or ( params , Ġ" name ", Ġnull ), ĊĠĠĠĠĠ Ġcurrency Ġ= Ġget Val Or ( params , Ġ" currency ", Ġnull ), ĊĠĠĠ Ġ) ĊĊĠĠĠ ĠCor outine Scope ( Dispatch ers . IO ). launch Ġ{ ĊĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtoken Ġ= Ġstripe . create Card Token ( ĊĠĠĠĠĠĠĠĠĠ Ġcard Params Ġ= Ġcard Params , ĊĠĠĠĠĠĠĠĠĠ Ġstripe AccountId Ġ= Ġstripe AccountId ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġpromise . resolve ( create Result (" token ", Ġmap From Token ( token ))) ĊĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠException ) Ġ{ ĊĠĠĠĠĠĠĠ Ġpromise . resolve ( create Error ( Create Token ErrorType . Failed . toString (), Ġe . message )) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġcreate Token For CV C Update ( cv c : ĠString , Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ Ġstripe . create C vc Update Token ( ĊĠĠĠĠĠ Ġc vc , ĊĠĠĠĠĠ Ġcallback Ġ= Ġobject Ġ: ĠApi Result Callback < Token > Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun ĠonSuccess ( result : ĠToken ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġval Ġtoken Id Ġ= Ġresult . id ĊĠĠĠĠĠĠĠĠĠ Ġval Ġres Ġ= ĠWrit able Native Map () ĊĠĠĠĠĠĠĠĠĠ Ġres . putString (" tokenId ", Ġtoken Id ) ĊĠĠĠĠĠĠĠĠĠ Ġpromise . resolve ( res ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġoverride Ġfun ĠonError ( e : ĠException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġpromise . resolve ( create Error (" Failed ", Ġe )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġhandle Next Action ( payment Intent Client Secret : ĠString , Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ Ġpayment Launcher Fragment . client Secret Ġ= Ġpayment Intent Client Secret ĊĠĠĠ Ġpayment Launcher Fragment . promise Ġ= Ġpromise ĊĠĠĠ Ġpayment Launcher Fragment . payment Launcher . handle Next Action For Payment Intent ( payment Intent Client Secret ) ĊĠ Ġ} Ċ Ċ // ĠTODO : ĠUncomment Ġwhen ĠWe Chat Ġis Ġre - enabled Ġin Ġstripe - ios Ċ // Ġ Ġprivate Ġfun Ġpay With We Chat Pay ( payment Intent Client Secret : ĠString , ĠappId : ĠString ) Ġ{ Ċ // ĠĠĠ Ġval Ġactivity Ġ= Ġcurrent Activity Ġas ĠComponent Activity Ċ // Ċ // ĠĠĠ Ġactivity . lifecycle Scope . launch Ġ{ Ċ // ĠĠĠĠĠ Ġstripe . create PaymentMethod ( PaymentMethod Create Params . create We Chat Pay ()). id ?. let Ġ{ Ġpayment Method Id Ġ-> Ċ // ĠĠĠĠĠĠĠ Ġval Ġconfirm Payment Intent Params Ġ= Ċ // ĠĠĠĠĠĠĠĠĠ ĠConfirm Payment Intent Params . create With PaymentMethod Id ( Ċ // ĠĠĠĠĠĠĠĠĠĠĠ Ġpayment Method Id Ġ= Ġpayment Method Id , Ċ // ĠĠĠĠĠĠĠĠĠĠĠ Ġclient Secret Ġ= Ġpayment Intent Client Secret , Ċ // ĠĠĠĠĠĠĠĠĠĠĠ Ġpayment Method Options Ġ= ĠPayment Method Options Params . We Chat Pay ( Ċ // ĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠappId Ċ // ĠĠĠĠĠĠĠĠĠĠĠ Ġ) Ċ // ĠĠĠĠĠĠĠĠĠ Ġ) Ċ // ĠĠĠĠĠĠĠ Ġpayment Launcher Fragment . payment Launcher . confirm ( confirm Payment Intent Params ) Ċ // ĠĠĠĠĠ Ġ} Ċ // ĠĠĠ Ġ} Ċ // Ġ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġconfirm Payment ( payment Intent Client Secret : ĠString , Ġparams : ĠRead able Map , Ġoptions : ĠRead able Map , Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ Ġval Ġpayment MethodType Ġ= Ġget Val Or ( params , Ġ" type ") ?. let Ġ{ Ġmap To Payment MethodType ( it ) Ġ} Ġ?: Ġrun Ġ{ ĊĠĠĠĠĠ Ġpromise . resolve ( create Error ( Confirm Payment ErrorType . Failed . toString (), Ġ" You Ġmust Ġprovide Ġpayment MethodType ")) ĊĠĠĠĠĠ Ġreturn ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġpayment Launcher Fragment . client Secret Ġ= Ġpayment Intent Client Secret ĊĠĠĠ Ġpayment Launcher Fragment . promise Ġ= Ġpromise ĊĊĠĠĠ Ġval Ġtest Offline Bank Ġ= Ġget Boolean Or False ( params , Ġ" test Offline Bank ") ĊĊĠĠĠ Ġif Ġ( payment MethodType Ġ== ĠPayment Method . Type . F px Ġ&& Ġ! test Offline Bank ) Ġ{ ĊĠĠĠĠĠ Ġconfirm Payment Client Secret Ġ= Ġpayment Intent Client Secret ĊĠĠĠĠĠ Ġpay With F px () ĊĠĠĠĠĠ Ġreturn ĊĠĠĠ Ġ} Ċ Ċ // ĠĠĠ Ġif Ġ( payment MethodType Ġ== ĠPayment Method . Type . We Chat Pay ) Ġ{ Ċ // ĠĠĠĠĠ Ġval ĠappId Ġ= Ġget Val Or ( params , Ġ" appId ") Ġ?: Ġrun Ġ{ Ċ // ĠĠĠĠĠĠĠ Ġpromise . resolve ( create Error (" Failed ", Ġ" You Ġmust Ġprovide ĠappId ")) Ċ // ĠĠĠĠĠĠĠ Ġreturn Ċ // ĠĠĠĠĠ Ġ} Ċ // ĠĠĠĠĠ Ġpay With We Chat Pay ( payment Intent Client Secret , ĠappId ) Ċ // Ċ // ĠĠĠĠĠ Ġreturn Ċ // ĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġfactory Ġ= ĠPayment Method Create Params Factory ( payment Intent Client Secret , Ġparams , Ġcard Field View , Ġcard Form View ) ĊĊĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠ Ġval Ġconfirm Params Ġ= Ġfactory . create Confirm Params ( payment MethodType ) ĊĠĠĠĠĠ Ġurl Scheme ?. let Ġ{ ĊĠĠĠĠĠĠĠ Ġconfirm Params . return Url Ġ= Ġmap To Return URL ( url Scheme ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġconfirm Params . shipping Ġ= Ġmap To Shipping Details ( getMap OrNull ( params , Ġ" shipping Details ")) ĊĠĠĠĠĠ Ġpayment Launcher Fragment . payment Launcher . confirm ( confirm Params ) ĊĠĠĠ Ġ} Ġcatch Ġ( error : ĠPayment Method Create Params Exception ) Ġ{ ĊĠĠĠĠĠ Ġpromise . resolve ( create Error ( Confirm Payment ErrorType . Failed . toString (), Ġerror )) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġretrieve Payment Intent ( client Secret : ĠString , Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ ĠCor outine Scope ( Dispatch ers . IO ). launch Ġ{ ĊĠĠĠĠĠ Ġval Ġpayment Intent Ġ= Ġstripe . retrieve Payment Intent S ynchronous ( client Secret ) ĊĠĠĠĠĠ Ġpayment Intent ?. let Ġ{ ĊĠĠĠĠĠĠĠ Ġpromise . resolve ( create Result (" payment Intent ", Ġmap From Payment Intent Result ( it ))) ĊĠĠĠĠĠ Ġ} Ġ?: Ġrun Ġ{ ĊĠĠĠĠĠĠĠ Ġpromise . resolve ( create Error ( Retrieve Payment Intent ErrorType . Unknown . toString (), Ġ" Failed Ġto Ġretrieve Ġthe ĠPayment Intent ")) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġretrieve Setup Intent ( client Secret : ĠString , Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ ĠCor outine Scope ( Dispatch ers . IO ). launch Ġ{ ĊĠĠĠĠĠ Ġval Ġsetup Intent Ġ= Ġstripe . retrieve Setup Intent S ynchronous ( client Secret ) ĊĠĠĠĠĠ Ġsetup Intent ?. let Ġ{ ĊĠĠĠĠĠĠĠ Ġpromise . resolve ( create Result (" setup Intent ", Ġmap From Setup Intent Result ( it ))) ĊĠĠĠĠĠ Ġ} Ġ?: Ġrun Ġ{ ĊĠĠĠĠĠĠĠ Ġpromise . resolve ( create Error ( Retrieve Setup Intent ErrorType . Unknown . toString (), Ġ" Failed Ġto Ġretrieve Ġthe ĠSetup Intent ")) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġconfirm Setup Intent ( setup Intent Client Secret : ĠString , Ġparams : ĠRead able Map , Ġoptions : ĠRead able Map , Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ Ġconfirm Setup Intent Promise Ġ= Ġpromise ĊĊĠĠĠ Ġval Ġpayment MethodType Ġ= Ġget Val Or ( params , Ġ" type ") ?. let Ġ{ Ġmap To Payment MethodType ( it ) Ġ} Ġ?: Ġrun Ġ{ ĊĠĠĠĠĠ Ġpromise . resolve ( create Error ( Confirm Payment ErrorType . Failed . toString (), Ġ" You Ġmust Ġprovide Ġpayment MethodType ")) ĊĠĠĠĠĠ Ġreturn ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġfactory Ġ= ĠPayment Method Create Params Factory ( setup Intent Client Secret , Ġparams , Ġcard Field View , Ġcard Form View ) ĊĊĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠ Ġval Ġactivity Ġ= Ġcurrent Activity Ġas ĠComponent Activity ĊĠĠĠĠĠ Ġval Ġconfirm Params Ġ= Ġfactory . create Setup Params ( payment MethodType ) ĊĠĠĠĠĠ Ġurl Scheme ?. let Ġ{ ĊĠĠĠĠĠĠĠ Ġconfirm Params . return Url Ġ= Ġmap To Return URL ( url Scheme ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġstripe . confirm Setup Intent ( activity , Ġconfirm Params ) ĊĠĠĠ Ġ} Ġcatch Ġ( error : ĠPayment Method Create Params Exception ) Ġ{ ĊĠĠĠĠĠ Ġpromise . resolve ( create Error ( Confirm Payment ErrorType . Failed . toString (), Ġerror )) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġis Google Pay Supported ( params : ĠRead able Map ?, Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ Ġval Ġfragment Ġ= ĠGoogle Pay PaymentMethod Launcher Fragment ( ĊĠĠĠĠĠ Ġcurrent Activity Ġas ĠAppCompatActivity , ĊĠĠĠĠĠ Ġget Boolean Or False ( params , Ġ" test Env "), ĊĠĠĠĠĠ Ġget Boolean Or False ( params , Ġ" existing PaymentMethod Required "), ĊĠĠĠĠĠ Ġpromise ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ( current Activity Ġas ĠAppCompatActivity ). support FragmentManager . beginTransaction () ĊĠĠĠĠĠ Ġ. add ( fragment , Ġ" google _ pay _ support _ fragment ") ĊĠĠĠĠĠ Ġ. commit () ĊĠ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġinit Google Pay ( params : ĠRead able Map , Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ Ġval Ġactivity Ġ= Ġcurrent Activity Ġas ĠAppCompatActivity ĊĠĠĠ Ġval Ġfragment Ġ= ĠGoogle Pay Fragment (). also Ġ{ ĊĠĠĠĠĠ Ġval Ġbundle Ġ= Ġto Bundle Object ( params ) ĊĠĠĠĠĠ Ġit . arguments Ġ= Ġbundle ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġinit Google Pay Promise Ġ= Ġpromise ĊĊĠĠĠ Ġactivity . support FragmentManager . beginTransaction () ĊĠĠĠĠĠ Ġ. add ( fragment , Ġ" google _ pay _ launch _ fragment ") ĊĠĠĠĠĠ Ġ. commit () ĊĠ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġpresent Google Pay ( params : ĠRead able Map , Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ Ġval Ġclient Secret Ġ= Ġget Val Or ( params , Ġ" client Secret ") Ġ?: Ġrun Ġ{ ĊĠĠĠĠĠ Ġpromise . resolve ( create Error ( Google Pay ErrorType . Failed . toString (), Ġ" you Ġmust Ġprovide Ġclient Secret ")) ĊĠĠĠĠĠ Ġreturn ĊĠĠĠ Ġ} ĊĠĠĠ Ġpresent Google Pay Promise Ġ= Ġpromise ĊĠĠĠ Ġif Ġ( getBoolean Or False ( params , Ġ" for Setup Intent ")) Ġ{ ĊĠĠĠĠĠ Ġval Ġcurrency Code Ġ= Ġget Val Or ( params , Ġ" currency Code ") Ġ?: Ġrun Ġ{ ĊĠĠĠĠĠĠĠ Ġpromise . resolve ( create Error ( Google Pay ErrorType . Failed . toString (), Ġ" you Ġmust Ġprovide Ġcurrency Code ")) ĊĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġgoogle Pay Fragment ?. present For Setup Intent ( client Secret , Ġcurrency Code ) ĊĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠ Ġgoogle Pay Fragment ?. present For Payment Intent ( client Secret ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ React Method ĊĠ Ġ@ SuppressWarnings (" unused ") ĊĠ Ġfun Ġcreate Google Pay PaymentMethod ( params : ĠRead able Map , Ġpromise : ĠPromise ) Ġ{ ĊĠĠĠ Ġval Ġcurrency Code Ġ= Ġget Val Or ( params , Ġ" currency Code ", Ġnull ) Ġ?: Ġrun Ġ{ ĊĠĠĠĠĠ Ġpromise . resolve ( create Error ( Google Pay ErrorType . Failed . toString (), Ġ" you Ġmust Ġprovide Ġcurrency Code ")) ĊĠĠĠĠĠ Ġreturn ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġamount Ġ= Ġget Int OrNull ( params , Ġ" amount ") Ġ?: Ġrun Ġ{ ĊĠĠĠĠĠ Ġpromise . resolve ( create Error ( Google Pay ErrorType . Failed . toString (), Ġ" you Ġmust Ġprovide Ġamount ")) ĊĠĠĠĠĠ Ġreturn ĊĠĠĠ Ġ} ĊĠĠĠ Ġpresent Google Pay Promise Ġ= Ġpromise ĊĠĠĠ Ġgoogle Pay Fragment ?. create PaymentMethod ( currency Code , Ġamount ) ĊĠ Ġ} ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġconst Ġval ĠNAME Ġ= Ġ" Stripe Sdk " ĊĠ Ġ} Ċ } Ċ