Friday, October 21, 2022

終於弄到實機

 但跑出來的結果跟模擬器一樣...

API exception 10















還有實機多了模擬器一顆按鈕













回去乖乖翻資料,發現之前的筆記上提到 github project 要仔細看 Constants.java and PaymentsUtil.java,發現 CURRENCY_CODE 我從 USD 改成 TW,應該是 TWD 才對,也把 exampleGatewayMerchantId 改成 YOUR_GATEWAY_MERCHANT_ID (因為我挑 ctbcbank 所以要帶這個,在之前的 payment provider 有提到)

改好後終於擺脫 error 10 !! (是說這 error 也太.... 幾乎找不到參考資料,大部分都說是 sign in 的資訊)












上次卡關的時候有用本帳號加入群組,今天突破後改用免洗帳號,結果就出現需要新增信用卡的情況,記得原本在 Test card suite 裡面是說:

These sample credit cards are intended for use with our integration checklist. To use them in our TEST environment, join our user group. While logged into an account that has joined the above group and viewing the payment sheet in the test environment, the Google Pay payment sheet will display a set of test cards. 

以為 group 裡面會有個 sheet contains sample credit card, 但群組裡面空空如也,仔細看上面寫著:

Congratulations! You now have access to our test suite! No further action is required.

To test this feature, navigate to the demo page in our dev docs. Once you click on the Google Pay payment button, you should see our test cards instead of your own production cards.

猜想可能沒加過信用卡不行,或者時間差的關係,就換上本帳號,果真看到測試卡片了(上方右側)

按下 Continue 被要求加個螢幕鎖,展開發現蠻多卡片可以挑的 XD

然後就順利完成購物啦 Yeah~


PS 後來大概過半個小時,免洗帳號也出現測試信用卡了~

PS 有一度 factory reset 實機,多的那顆按鈕就不見了...







Monday, October 10, 2022

直接開新局!

 文件看起來可以直上測試,那就開一套玩玩看囉~











先把 libs 加進來

  • implementation 'com.google.android.gms:play-services-wallet:19.1.0'


Put it all together

把直接寫好的程式碼放到專案裡面看看吧

恩,噴了一些錯,看來程式碼有點歷史...

那來找歷史看看 XD


https://github.com/google-pay/android-quickstart/


Instructions

Make sure you read the comments in Constants.java and PaymentsUtil.java before you continue. These files must be modified prior to running the app, as per the instructions provided in the comments.




 





從 sample code 做的三個變更,跑起來開服飾店啦






















哎呀,要設定帳號才行~


這邊 Before you begin 有提到:

Set up your app in your Google Pay account

Install the Google Play services version 19.1.0 or greater.

Install the Google Pay app and add a payment method.

Add a payment method to Google.

Adhere to our Google Pay API Acceptable Use Policy and the Google Play developer policy.


剛好在 Integration checklist 裡面有看到 Test card suite

剛按下申請加入,期待審核後參考裡面的測試卡片資料囉~

咦,重整網頁居然秒加入群組了

貌似只要用加入群組的帳號登入裝置就能直接使用測試卡片

但登入後顯示 Toast ...












Sunday, October 9, 2022

好,我要用功了!again!

 這次要紀錄怎麼以開發者的角度使用 Google Pay 來幫店家販售商品~


為什麼我會想研究怎麼串接 Google Pay 呢?

主要是... 

  1. 無腦選擇相信它
  2. 常被問到能否幫忙做他們家的 app 販售商品


先來翻說明書吧~

https://developers.google.com/pay/

首先,恩... 語系只有這些











恩,有三個分類,我會先看熟悉的 Android, 再看 Transaction Events,最後看 Web






  1. The user taps the Google Pay payment button and sees a payment sheet with a list of supported payment methods.
  2. The user selects a payment method and Google Pay securely returns a payment token for that method to your app.
  3. Your app submits the payment token, along with details about the purchase, to its backend.
  4. To execute the payment, the backend processes the purchase and sends the payment token to the payment service provider





ㄜ,馬上卡關==b


  1. Review and adhere to our Google Pay API Terms of Service and Acceptable Use Policy.
  2. Look through the supported processors and gateways list to find the reference documentation for your payment processor or gateway.

看起來一定要透過很厲害的 PSP, 自己想弄是狠難的XD

好,到這邊我覺得我只能接接 API, 想成為 Google Pay GDE 應該是無理 XD



喔喔!!居然在一堆陌生的名字裡面看到眼熟的,但是網址點開就只是首頁而已!?

試試看線上客服,記得好像只到幾點就沒了,沒想到國慶連假深夜居然還有,只是要等五個人XD(事實證明... 好像系統壞了,一下說維護,然後斷線,再上去改口說要等十人,接著 loop ... 等白天再試試看好了)


等的時候喵了一下 Tutorial 裡面還是有列出中國信託的資訊,但 Developer docs 還是直連到首頁,但 Tip 的說法貌似還是可以進行測試啦~


但目前有點累了,明天繼續吧~