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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
<?php //paypal reference link https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/
$order_id = 1; $shipping_price = 0; $amount = 100; $invoiceNo = "ORDER_0001"; //$paypal_url = "https://www.paypal.com/row/cgi-bin/webscr"; //production //$paypal_business = ""; //production $paypal_url = "https://www.sandbox.paypal.com/row/cgi-bin/webscr"; //uat $paypal_business = "gsell_1323239795_biz@onesolution.com.hk"; //uat $paypal_array = array('cmd' => '_xclick', 'upload' => '1', 'custom' => "{order_id:1}", //can pass a json string 'invoice' => $invoiceNo, 'business' => $paypal_business, 'item_name' => 123, 'item_number' => 1001, 'amount' => $amount, 'currency_code' => 'HKD', 'shipping' => $shipping_price, 'no_shipping' => 1, 'return' => 'http://' . $_SERVER['HTTP_HOST'] . '/webadmin/order_form.php?id=' . $order_id, 'notify_url' => 'http://' . $_SERVER['HTTP_HOST'] . '/paypal_notify.php', 'cancel_return' => 'http://' . $_SERVER['HTTP_HOST'] . '/webadmin/order_form.php?id=' . $order_id ); $array = array(); foreach ($paypal_array as $name => $data) { $array[] = $name . '=' . urlencode($data); } $path = $paypal_url . '?' . implode('&', $array); ?>
<html> <body> <a href="<?= $path ?>" target="_blank"> <img src="https://www.paypalobjects.com/webstatic/en_US/i/btn/png/btn_buynow_107x26.png" alt="Buy Now"/> </a> </body> </html>
|