因為經常會用到 PayPal 的連接.而之前工作中也因為遇上了某些奇怪的需求.
所以在空閒時作點小記錄.其實最主要的是.
- 當用戶付款時.該筆款項並不是真正交付公司帳戶.而是暫存於 30 天
- 當整個過程順利後,公司才真正的作出收取動作 (Capture)
- 否則.如果過程不順利.那交付的款項將退回給用戶 (公司可通過 Batch 功能一次退給多個用戶)
記錄一下提交的表格
- https://www.paypal.com/cgi-bin/webscr (真正網站的應用連結)
- https://www.sandbox.paypal.com/cgi-bin/webscr (Developer 測試用連結)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25<form method="post" action="[連結的網址,即上面兩個中並中一個]?locale.x=zh_HK" target="_blank">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="公司的 PayPal 帳號" />
<input type="hidden" name="currency_code" value="HKD" />
<input type="hidden" name="amount" value="應該收取的總金額" />
<!-- 使用 Capture 方式收款-->
<input type="hidden" name="paymentaction" value="authorization" />
<!-- 付款後返回的 URL -->
<input type="hidden" name="return" value="http://localhost/path/to/file" />
<!-- 給予我方檢查付款的連結,資料由PayPal發送,用戶不會感覺到這個畫面(可實現支持一個帳戶中多個 IPN ?) -->
<input type="hidden" name="notify_url" value="http://localhost/path/to/file" />
<!-- 如在 PayPal 過程中按下 Cancel 後則跳轉到此頁面 -->
<input type="hidden" name="cancel_url" value="http://localhost/path/to/file" />
<input type="hidden" name="invoice" value="自定義的訂單識別號碼" />
<input type="hidden" name="item_name" value="物品的名稱,配上 invoice 則可有效識別交易" />
<input type="hidden" name="charset" value="utf-8" />
<!-- 經 POST 方法取得所有值 -->
<input type="hidden" name="rm" value="2" />
<input type="submit" value="前往 PayPal 在線支付" />
</form>
注.如果 IPN 和帳號中沒設定轉址連結.則用戶付款後需要按動連結才會返回.