# 20220818 串接Paypal金流 ###### tags: `Ruby` `Rails` 路徑,action,view ```ruby= # /orders/訂單編號/pay resources :orders, except: [:edit, :update, :destroy] do member do get :pay delete :cancel end end ``` ### braintree(paypal子公司) sandbox https://www.braintreepayments.com/sandbox 註冊好去收信 ![](https://i.imgur.com/ANKhZHw.png) sandbox home `https://sandbox.braintreegateway.com/merchants/<yourhashcode>/home` VARCHAR的長度是不固定的 EX:密碼,CHAR的長度是固定的EX:電話。 #### Nonce ### ```shell= $ yarn add braintree-web-drop-in ``` https://www.npmjs.com/package/braintree-web-drop-in 跨境電商請注意幣別,如果只是區域的話就沒差? ### 環境變數 :::danger # **不要把金鑰放在程式碼裡面。** ::: ## 套件 dotenv https://github.com/bkeepers/dotenv 部署平台會有環境變數的設定 所以這邊的套件才會在dev和test --- https://github.com/carrierwaveuploader/carrierwave 上傳照片套件 carrierwave https://ithelp.ithome.com.tw/articles/10199035 avatar:string 只是放圖片的路徑 不要把照片傳入資料庫喔~ 這是不好的做法 可以找替代 下關鍵字 XXXXXXXXX alternative gem~~~ 官方有提供檔案上傳的工具 ### Active Storage https://guides.rubyonrails.org/v6.1/active_storage_overview.html `AWS S3` 可以當作全世界最大的硬碟 ### 8 Transforming Images https://guides.rubyonrails.org/v6.1/active_storage_overview.html#transforming-images > To enable variants, add the image_processing gem to your Gemfile: ```ruby! gem 'image_processing' ``` SQL injection https://ithelp.ithome.com.tw/articles/10189201 Ruby教學影片: railscasts (Ruby3以前的影片) gorails (小胖) driftingruby 套件 權限管理: cancan -> cancancan / [Pundit](https://github.com/varvet/pundit) ## [Alfred](https://www.alfredapp.com/) ![](https://i.imgur.com/COFgYRP.png) ## debugger