線上付款模組 - Paypal
A2B 版本: 1.9.4
修改 System Settings
A2B Admin UI > System Settings > Select Group: epayment_method >
Customer UI:
- enable = Yes (如果不想啟用線上付款模組,可已改成 No)
- http_server = http://<A2B FQDN or IP>
- https_server = https://<A2B FQDN or IP>
- http_cookie_domain = <A2B FQDN or IP>
- https_cookie_domain = <A2B FQDN or IP>
- http_cookie_path = /A2BCustomer_UI/ ;網址路徑
- https_cookie_path = /A2BCustomer_UI/ ;網址路徑
- dir_ws_http_catalog = /A2BCustomer_UI/ ;網址路徑
- dir_ws_https_catalog = /A2BCustomer_UI/ ;網址路徑
- enable_ssl = No (除非已經在 Apache 設定了 SSL,否則請設為 No )
- http_domain = <A2B FQDN or IP>
- dir_ws_http = /var/www/A2BCustomer_UI/ ;絕對路徑
- transaction_key = <自定一組60位數以下的英文數字亂數組合>
Agent UI:
- http_server_agent = http://<A2B FQDN or IP>
- https_server_agent = https://<A2B FQDN or IP>
- https_cookie_domain_agent = <A2B FQDN or IP>
- http_cookie_path_agent = /agent/Public/
- https_cookie_path_agent = /agent/Public/
- dir_ws_http_catalog_agent = /agent/Public/
- dir_ws_https_catalog_agent = /agent/Public/
啟用/關閉 Payment Gateway
A2B Admin UI > Billing > Payment Methods >
內建有四種付款方法,可進入 Details 將該項啟用或關閉。
設定 Paypal 模組
- 設定 System Settings 參數,先參閱上述的相關說明。
A2B Admin UI > System Settings > Select Group: epayment_method >
- paypal_payment_url = https://secure.paypal.com/cgi-bin/webscr
程式開發用:https://www.sandbox.paypal.com/cgi-bin/webscr - paypal_verify_url = ssl://www.paypal.com
程式開發用:ssl://www.sandbox.paypal.com - store_name =My Calls Shop ;自訂義 Paypal 商店名稱
- charge_paypal_fee = No ; No: 手續費由賣家支付, Yes: 由買家支付
- 開啟 Paypal 付款模組
A2B Admin UI > Billing > Payment Methods > Paypal, Select Details - Enable Paypal Module: True
- E-Mail Address: <輸入賣家要收款的 Paypal ID,且必須是 business type>
- 設定 Paylpal 網站帳戶
登入 Paypal 網站 > My Account > Profile > More options > Website Payment Preferences > Auto Return for Website Payments
- Auto return: On
- Return URL: htttp://<A2B FQDN or IP>/A2BCustomer_UI/checkout_process.php
- 注意:Paypal 帳戶必須是 Business type 才會顯示 Website Payment Preference 功能項,參閱附檔。
- 如果發生可完成 Paypal 付款,但餘額及付款記錄沒有更新,請參閱 Q&A
在 Customer UI 操作線上付款
操作流程:
- 登入 A2B Customer UI
- 首頁 > BUY NOW
- 選擇 Paypal > 選擇購買金額 > 完成按 continue
- 顯示訂單內容 > 確認按 confirm order (註: 此時在 Admin UI > Billing > E-Payment Log 會有該筆訂單記錄且狀態為 New)
- 自動前往 Paypal 登入網頁 > 輸入要付款的 paypal 帳號/密碼 (註: 左側會顯示付款的物品內容及金額)
- Paypal 政策同意頁面 > 勾選 Yes > 完成按 Agree and Continue
- 再次確認付款內容 > 完成後按 Pay Now
- Paypal 網站在訂單處裡完後,會自動將頁面導回 A2B Customer UI,在這個頁面的餘額以及 Payment 應該都已完成更新 (註: 此時在 Admin UI > Billing > E-Payment Log 會有該筆訂單記錄且狀態為 Proceed)
一旦付款程序有正確的完成,有以下狀況可驗證:
A2B Admin UI)
- Billing > Customer Balance > E-Payment Log,該筆訂單狀態呈現 Proceed
- Billing > Customer Balance > Payments,會自動產生付款記錄
- Billing > Customer Balance > Refills,會自動儲值
- Customer,帳戶餘額會自動更新
A2B Customer UI)
- 首頁上的餘額會自動更新
- Payment History 會有付款記錄
E-Payment Log 狀態說明
注意:這裡的付款記錄是由付款模組自動更新,不可由人工編輯。
- New:新訂單,用戶有購買但尚未進行paypal付款及付款確認等程序
- In Process:訂單處理中,用戶已購買且完成 paypal 付款但未通過 paypal 交易確認
- Proceed:訂單完成,用戶已購買且付款及交易確認均已完成
TIPs:
假使購買記錄沒有呈現 Proceed,在 Customer 的餘額及 Payment 歷史紀錄都不會有更新。
Q&A
Q: a2billing_epayment.log 沒有資料
- 檢查 A2B Admin UI > System Settings > Select Group: log-files > epayment 路徑是否正確
- 檢查 /var/log/a2billing/a2billing_epayment.log 權限是否可允許 Apache 寫入
- 分析 Apache Log
Q: 如何開發及測試 paypal API
Ans:先前往 paypal 開發網站註冊開發用的 paypal 帳號
- Paypal 開發網站:https://developer.paypal.com/
- 註冊時需要一個有效的 email 做認證
- 完成註冊後,登入並前往 Test Accounts,可選擇 Preconfigured 方式新增開發用的 paypal 帳號
- 開發用的 paypal 帳號
- Buyer type 就是 Personal
- Seller type 就是 Business
- 在 Browser 要測試你的付款程式時,需要先登入開發網站,否則看不到 paypal 帳號登入網頁
Q: 使用 Paypal Sandbox 平台測試,Paypal 可以在 Customer UI 完成付款,但 Payment 以及 Customer Balance 都不會更新?
Ans:除錯的重點要項
- 確定 System Settings > epayment_method 參數是正確的
- 分析 /var/log/a2billing/a2billing_epayment.log
- PHP module - OpenSSL 是否安裝
- 修正 check_process.php
Q: [fixed] checkout_process.php
Ans:檢視 a2billing_epayment.log,總是出現錯誤:
[29/08/2012 03:29:10]:[checkout_process.php line:150-PAYPAL Transaction Verification Status: Failed req=cmd=_notify-validate&mc_gross=2.00&protection_eligibility=Ineligible&payer_id=LETTM8WG64ENJ&tax=0.00&payment_date=20%3A29%3A01+Aug+28%2C+2012+PDT&payment_status=Completed&....
HTTP/1.0 400 Bad Request
Server: BigIP
Connection: close
Content-Length: 19
Invalid Host header]
請按照下述步驟做修正:
編輯 checkout_process.php,搜尋 payal
reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)Callstack:
at User:alang/Private_Zone/A2Billing_專區/修正~Payment-Paypal
MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException: reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown.
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptVar expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptVar.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Evaluate (MindTouch.Deki.Script.Expr.DekiScriptAccess expr, DekiScriptExpressionEvaluationState state, Boolean evaluateProperties) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptAccess expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptAccess.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptCall expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptCall.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptSequence expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptSequence.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptReturnScope expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0