Beberapa langkah untuk memulai:
- Mula-mula, pastinya kita harus bikin account paypal dulu yang akan dijadikan sebagai merchant (penerima duit). Untuk sandbox, bikinnya di http://developer.paypal.com (daftar beneran dulu untuk bisa bikin account bo’ongan/ tester account setelah login. daftarnya gratis kok).
- login pakai account tersebut (kalau pakai sandbox, login sandbox dulu baru login account tester)
- My Account � Profile �Get API Credentials . Ikuti petunjuknya untuk mendapatkan PayPal API Signature untuk Website Payment Pro (bukan Payflow Pro) dengan integrasi sendiri (bukan pakai third-party shopping cart)
- Anda akan mendapatkan:
-
- API Username
- API Password
- API Signature
Implementasi:
Tiga data diatas dimasukkan kedalam $ppConfig.
03 |
require_once('../PayPalApps/paypal.nvp.class.php'); |
05 |
# Setup the PayPal object |
06 |
$ppConfig = array('Sandbox' => true, //set false untuk non-sandbox |
07 |
'APIUsername' => 'jbuzz547_api1.ymail.com', |
08 |
'APIPassword' => 'AW9KUMJRLYG5XSX3', |
09 |
'APISignature' => 'Au4SU-K4fYYF.P79qKJxkZVnRl99Aajgl6JLQDOqRPpDrqFGThC-rB4H', |
11 |
$pp = new PayPal($ppConfig); |
13 |
# Populate data arrays for API call. |
15 |
'paymentaction' => 'Sale', |
16 |
'ipaddress' => '192.168.1.34', |
17 |
'returnfmfdetails' => '1' |
21 |
'creditcardtype' => 'Visa', |
22 |
'acct' => '4635800000835916', |
23 |
'expdate' => '052012', |
29 |
'email' => 'tester@testerson.com', |
30 |
'business' => 'Testers, LLC' |
34 |
'salutation' => 'Mr.', |
35 |
'firstname' => 'Tester', |
37 |
'lastname' => 'Testerson', |
41 |
$BillingAddress = array( |
42 |
'street' => '123 Test Ave.', |
43 |
'street2' => 'Apt. 3', |
44 |
'city' => 'Testersville', |
46 |
'countrycode' => 'US', |
48 |
'phonenum' => '555-555-5555' |
51 |
$ShippingAddress = array( |
52 |
'shiptoname' => 'Mr. Tester Testerson Jr.', |
53 |
'shiptostreet' => '123 Test Ave', |
54 |
'shiptostreet2' => 'Apt. 3', |
55 |
'shiptocity' => 'Testersville', |
56 |
'shiptostate' => 'MO', |
57 |
'shiptozip' => '64030', |
58 |
'shiptocountrycode' => 'US', |
59 |
'shiptophonenum' => '555-555-5555' |
62 |
$PaymentDetails = array( |
64 |
'currencycode' => 'USD', |
66 |
'shippingamt' => '10.00', |
69 |
'desc' => 'This is a test order.', |
71 |
'invnum' => '1234-ABC', |
76 |
# Now combine your data arrays into a single nested array to pass into the class. |
78 |
'DPFields' => $DPFields, |
79 |
'CCDetails' => $CCDetails, |
80 |
'PayerInfo' => $PayerInfo, |
81 |
'PayerName' => $PayerName, |
82 |
'BillingAddress' => $BillingAddress, |
83 |
'ShippingAddress' => $ShippingAddress, |
84 |
'PaymentDetails' => $PaymentDetails); |
86 |
# Now we pass the nested array of all our data into the class. |
87 |
$DPResult = $pp -> DoDirectPayment($DPData); |
89 |
# Now lets study the result array |
Kalau yang ini untuk pembayaran dengan account PayPal
03 |
require_once('../PayPalApps/paypal.nvp.class.php'); |
05 |
# Setup the PayPal object |
06 |
$ppConfig = array('Sandbox' => true, // set false untuk non-sandbox |
07 |
'APIUsername' => 'jbuzz547_api1.ymail.com', |
08 |
'APIPassword' => 'AW9KUMJRLYG5XSX3', |
09 |
'APISignature' => 'Au4SU-K4fYYF.P79qKJxkZVnRl99Aajgl6JLQDOqRPpDrqFGThC-rB4H', |
12 |
$pp = new PayPal($ppConfig); |
14 |
# Populate data arrays for API call. |
18 |
'paymentaction' => 'Sale' |
20 |
$PaymentDetails = array( |
22 |
'currencycode' => 'USD', |
24 |
'shippingamt' => '5.00', |
25 |
'handlingamt' => '2.00', |
27 |
'desc' => 'This is a test order.', |
29 |
'invnum' => '1234-ABC' |
32 |
# Now combine your data arrays into a single nested array to pass into the class. |
34 |
'SECFields' => $SECFields, |
35 |
'PaymentDetails' => $PaymentDetails |
38 |
# Now we pass the nested array of all our data into the class. |
39 |
$SECResult = $pp -> SetExpressCheckout($SECData); |
41 |
# Now lets study the result array |
46 |
# Now we can just use the returned REDIRECTURL field to redirect the user to PayPal based on our input. |
47 |
header('Location: ' . $SECResult['REDIRECTURL']); |
paypal.nvp.clssass download here
Butuh coba-coba sendiri sambil lirik classnya kalau mau buat bayar multiple items. 
Sekedar pengingat. Jangan lupa beli hosting dengan dedicated IP dan install SSL.
Terlihat mudah bukan?
source: rumahdot