package Ġcom . react native cloud payments Ċ Ċ import Ġandroid . app . Activity Ċ import Ġcom . facebook . react . bridge . Readable Map Ċ import Ġcom . google . android . gms . wallet . Payments Client Ċ import Ġcom . google . android . gms . wallet . Wallet Ċ import Ġorg . json . JSONArray Ċ import Ġorg . json . JSONException Ċ import Ġorg . json . JSONObject Ċ Ċ class ĠGoogle Pay Request Ġ( ĊĠ Ġmerchant Name : ĠString , ĊĠ Ġgoogle Pay Merchant Id : ĠString , ĊĠ Ġgateway : ĠRead able Map , ĊĠ Ġpayment Networks : ĠArrayList < String >, Ċ ) Ġ{ ĊĠ Ġprivate Ġvar Ġbase Card PaymentMethod : ĠJSONObject Ġ= ĠJSONObject (); ĊĠ Ġprivate Ġvar Ġbase Request : ĠJSONObject Ġ= ĠJSONObject (); ĊĠ Ġprivate Ġvar Ġgateway Token ization Specification : ĠJSONObject Ġ= ĠJSONObject (); ĊĠ Ġprivate Ġvar Ġmerchant Info : ĠJSONObject Ġ= ĠJSONObject (); ĊĠ Ġprivate Ġlateinit Ġvar Ġpayment Data Request : ĠJSONObject ; ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġval Ġgateway Name Ġ= Ġgateway . getString (" service ") Ġas ĠString ; ĊĠĠĠ Ġval Ġgateway Merchant Id Ġ= Ġgateway . getString (" merchant Id ") Ġas ĠString ; ĊĊĠĠĠ Ġbase Request . apply Ġ{ ĊĠĠĠĠĠ Ġput (" apiVersion ", Ġ 2 ) ĊĠĠĠĠĠ Ġput (" apiVersion Minor ", Ġ 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġgateway Token ization Specification . apply Ġ{ ĊĠĠĠĠĠ Ġput (" type ", Ġ" PAYMENT _ GATE WAY ") ĊĠĠĠĠĠ Ġput (" parameters ", ĠJSONObject ( map Of ( ĊĠĠĠĠĠĠĠ Ġ" gateway " Ġto Ġgateway Name , ĊĠĠĠĠĠĠĠ Ġ" gateway Merchant Id " Ġto Ġgateway Merchant Id ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġallowed Card Networks Ġ= ĠJSONArray ( payment Networks ); ĊĊĠĠĠ Ġval Ġallowed Card Auth Methods Ġ= ĠJSONArray ( listOf ( ĊĠĠĠĠĠ Ġ" PAN _ ONLY ", Ġ Ġ// ĠÐº Ð°ÑĢ ÑĤ Ñĭ , ĠÑħ ÑĢÐ°Ð½ Ñı ÑīÐ¸Ðµ ÑģÑı ĠÐ² ĠÑĥ ÑĩÐµÑĤ Ð½Ð¾Ð¹ ĠÐ·Ð°Ð¿Ð¸Ñģ Ð¸ ĠGoogle ĊĠĠĠĠĠ Ġ" CRYPTO GRAM _ 3 DS ")) Ġ// ĠÐº Ð°ÑĢ ÑĤ Ñĭ , ĠÑħ ÑĢÐ°Ð½ Ñı ÑīÐ¸Ðµ ÑģÑı ĠÐ² ĠÐ²Ð¸Ð´ Ðµ ĠÑĤ Ð¾Ðº ÐµÐ½ Ð¾Ð² ĠÐ½Ð° ĠÑĥ ÑģÑĤÑĢ Ð¾Ð¹ ÑģÑĤÐ² Ðµ ĊĊĠĠĠ Ġbase Card PaymentMethod . apply Ġ{ ĊĠĠĠĠĠ Ġval Ġparameters Ġ= ĠJSONObject (). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġput (" allowed Auth Methods ", Ġallowed Card Auth Methods ) ĊĠĠĠĠĠĠĠ Ġput (" allowed Card Networks ", Ġallowed Card Networks ) ĊĠĠĠĠĠĠĠ Ġput (" billing Address Required ", Ġtrue ) ĊĠĠĠĠĠĠĠ Ġput (" billing Address Parameters ", ĠJSONObject (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġput (" format ", Ġ" FULL ") ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġput (" type ", Ġ" CARD ") ĊĠĠĠĠĠ Ġput (" parameters ", Ġparameters ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġmerchant Info . put (" merchant Name ", Ġmerchant Name ) ĊĠĠĠ Ġmerchant Info . put (" merchant Id ", Ġgoogle Pay Merchant Id ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcard PaymentMethod (): ĠJSONObject Ġ{ ĊĠĠĠ Ġval Ġcard PaymentMethod Ġ= Ġbase Card PaymentMethod ; ĊĠĠĠ Ġcard PaymentMethod . put (" token ization Specification ", Ġgateway Token ization Specification ) ĊĊĠĠĠ Ġreturn Ġcard PaymentMethod ĊĠ Ġ} ĊĊĠ Ġfun Ġcreate Payments Client ( activity : ĠActivity , Ġenvironment Running : ĠInt ): ĠPay ments Client Ġ{ ĊĠĠĠ Ġval Ġwallet Options Ġ= ĠWallet . Wallet Options . Builder () ĊĠĠĠĠĠ Ġ. set Environment ( environment Running ) ĊĠĠĠĠĠ Ġ. build () ĊĊĠĠĠ Ġreturn ĠWallet . get Payments Client ( activity , Ġwallet Options ) ĊĠ Ġ} ĊĊĠ Ġfun Ġis Ready To Pay Request (): ĠJSONObject ? Ġ{ ĊĠĠĠ Ġreturn Ġtry Ġ{ ĊĠĠĠĠĠ Ġbase Request . apply Ġ{ ĊĠĠĠĠĠĠĠ Ġput (" allowed Payment Methods ", ĠJSONArray (). put ( base Card PaymentMethod )) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ġcatch Ġ( e : ĠJSON Exception ) Ġ{ ĊĠĠĠĠĠ Ġnull ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġfun Ġset Transaction Info ( country Code : ĠString , Ġcurrency Code : ĠString , Ġtotal Price : ĠString ) Ġ{ ĊĠĠĠ Ġpayment Data Request Ġ= ĠJSONObject (). apply Ġ{ ĊĠĠĠĠĠ Ġput (" total Price ", Ġtotal Price ) ĊĠĠĠĠĠ Ġput (" total Price Status ", Ġ" FINAL ") Ġ// ĠÑģ ÑĤÐ¾ Ð¸Ð¼Ð¾ÑģÑĤ ÑĮ ĠÐ¿Ð¾Ðº ÑĥÐ¿ ÐºÐ¸ ĠÐ¾ Ðº Ð¾Ð½ Ñĩ Ð°ÑĤÐµÐ»ÑĮ Ð½Ð°Ñı ĠÐ¸ ĠÐ± Ð¾Ð»ÑĮ ÑĪÐµ ĠÐ¸Ð· Ð¼ÐµÐ½ Ñı ÑĤÑĮ ÑģÑı ĠÐ½Ðµ ĠÐ±ÑĥÐ´ÐµÑĤ ĊĠĠĠĠĠ Ġput (" country Code ", Ġcountry Code ) ĊĠĠĠĠĠ Ġput (" currency Code ", Ġcurrency Code ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġfun Ġget Payment Data Request (): ĠJSONObject ? Ġ{ ĊĠĠĠ Ġreturn Ġtry Ġ{ ĊĠĠĠĠĠ Ġbase Request . apply Ġ{ ĊĠĠĠĠĠĠĠ Ġput (" allowed Payment Methods ", ĠJSONArray (). put ( card PaymentMethod ())) ĊĠĠĠĠĠĠĠ Ġput (" transaction Info ", Ġpayment Data Request ) ĊĠĠĠĠĠĠĠ Ġput (" merchant Info ", Ġmerchant Info ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ġcatch Ġ( e : ĠJSON Exception ) Ġ{ ĊĠĠĠĠĠ Ġnull ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ