Benny b9 Benny b9

how to make transaksi online pembayaran paypal scripts fsockopen

paypal is rekening elektronik that can difungsikan as media penyimpanan saldo keuangan sekaligus as transaksi online.
dalam hal keamanan, sistem web paypal diyakini 100% aman about berbagai method peretasan.

 

how to register paypal.

as register/ registrasi other, sangat mudah.
registrasi paypal. choise rekening pribadi or business type account paypal you. fitur lebih untuk can bertransaksi online menerima pembayaran berdasarkan name perusahaan choise type business.
account you akan berstatus inactive or ditangguhkan if belum dihubungkan with rekening bank you. how to menghubungkannya menggunakan kartu kredit or credit card that still berlaku. behow bank indonesia ada that disetujui aktifasi paypal, but statusnya still meragukan, akan lebih baik aktifasinya mengunakan kartu kredit, payoner or vcc (virtual credit card) that can you beli (google.com/search?q=jual+vcc).

paypal sangat membantu para online business dalam menghasilkan keuangan. in spite of status paypalnya belum aktif, can use bertransaksi online, mengirim or menerima keuangan.

fitur paypal.me/ or other memberikan kemudahan menerima keuangan dalam bertransaksi, selain that bagi para webmaster (web) pemilik online business that menginginkan transaksi lebih terpercaya can menambahkan scripts php see hasil log riwayat hasil transaksi, can use curl or fsockopen, kita ambil sample fsockopen. hal its is legal, disediakan oleh pihak paypal.

1. buat form pembayaran paypal payment terminal

scriptnya :

===========================================================

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="paypalpemilikproduk@yahoo.com"><!--your mail paypal-->
<input type="hidden" name="item_name" value="name produk">
<input type="hidden" name="item_number" value="id produk">
<input type="hidden" name="amount" value="10.00"> <!--- total uang dibayarkan or harga produk-->
<input type="hidden" name="currency_code" value="usd">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="rm" value="1">
<input type="hidden" name="custom" value="11.1111.1111.111"> <!-- ip or iduser pembeli--->
<input type="hidden" name="return" value="https://webmu.com/pay.php">
<input type="hidden" name="cancel_return" value="https://webmu.com/batal-pembelian.php">
<input type="hidden" name="bn" value="pp-buynowbf:btn_buynowcc_lg.gif:nonhosted">
<input class="ignore" type="image" src="https://w3.Benny9.be/btn_paynowcc_lg.png" border="0" style="margin: 5px 0 0 3px;" name="submit" alt="pay with paypal">
<img alt="" border="0" src="https://www.paypal.com/en_us/i/scr/pixel.gif" width="1" height="1">
</form>


===========================================================

pelu diperhatikan is menuju paypal.com/cgi-bin/webscr cmd=_xclick

to input name amount isikan nominal that dibayarkan, misal 10.00 untuk 10 usd, mata uang to currency_code misalnya usd (dolar amerika)

custom = isikan informasi pembeli, can berisikan id user or alamat ip if not registrasi or bukan method member web.

to input name=submit src can use with gambar kreasi sendiri.

 

2. to web you sediakan page that berisi scripts dimana pembeli sealready melakukan transaksi menuju halaman about, dalam hal its kita beriname pay.php and disertakan to root (http://webmu.com/pay.php).

scripts to pay.php

===========================================================

<?php

$ip = $_server["remote_addr"]?:($_server["http_x_forwarded_for"]?:$_server["http_client_ip"]);
$usragn = strtolower(@$_server["http_user_agent"]);
$date = time();


$req = "cmd=_notify-synch";

$tx_token = $_get["tx"];

$auth_token = "xxxxisikan-auth_tokenmu-in hereiiixxxx";//aut token from paypal web here

$req .= "&tx=$tx_token&at=$auth_token";


//validasi, header and connection
$header .= "post /cgi-bin/webscr http/1.0\r\n";
$header .= "content-type: application/x-www-form-urlencoded\r\n";
$header .= "content-length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);

if (!$fp) {
// errorfp
} else {

fputs($fp, $header . $req);
// read body
$res = "";
$headerdone = false;
while (!feof($fp)) {
$line = fgets ($fp, 1024);
if (strcmp($line, "\r\n") == 0) {

$headerdone = true;// read header

}
else if ($headerdone){

$res .= $line;// read contents

}
}


$lines = explode("\n", $res);
$data = array();

if (strcmp ($lines[0], "success") == 0) {

echo "please wait, process payments,..";

for ($i=1; $i<count($lines);$i++){

list($key,$val) = explode("=", $lines[$i]);
$data[urldecode($key)] = urldecode($val);

}

$oke = true;


//read data informasi
$firstname    = $data['first_name'];
$lastname    = $data['last_name'];
$itemname    = $data['item_name'];
$amount        = $data['mc_gross'];
$currency    = $data['mc_currency'];
$payment_status    = $data['payment_status'];
$payment_reason    = $data['pending_reason'];
$txn        = $data['txn_id'];
$reciever_e    = $data['receiver_email'];
$item_num    = $data['item_number'];
$custom        = $data['custom'];
$fee        = $data['mc_fee'];
$true_amount    = $amount - $fee;


////coneksi sql db
$con = mysql_connect("localhost", "dbuser", "db_pwd");//edit
$con_db = mysql_select_db("db_name");//edit


$msg = 1;

$id_your_product = "16";//edit
$price_your_product = "10";//edit

//check if error id and amount
if(($item_num==id_your_product)&&($amount>=$price_your_product)) {//oke
} else {
$oke = false;

$sql_log = "insert into `log_pp`(`status`, `id_produk`, `usr_ip`, `usr_agent`, `dater`) values ('error -price missmatch','".$id_your_product."','".$ip."','".$usragn."','".$date."')";
$q_log = mysql_query($sql_log);

$msg = 2;
}


//check if error currency
if ($currency=="usd") {//oke
} else {
$oke = false;

$sql_log = "insert into `log_pp`(`status`, `id_produk`, `usr_ip`, `usr_agent`, `dater`) values ('error -price currency','".$id_your_product."','".$ip."','".$usragn."','".$date."')";
$q_log = mysql_query($sql_log);

$msg = 2;
}



if ($payment_status=="completed") {

if($oke == false){
$sql_log = "insert into `log_pp`(`status`, `id_produk`, `usr_ip`, `usr_agent`, `dater`) values ('error -somthing error','".$id_your_product."','".$ip."','".$usragn."','".$date."')";
$q_log = mysql_query($sql_log);

$msg = 2;
}else{//

// process payment
$sql_log = "insert into `log_pp`(`status`, `id_produk`, `usr_ip`, `usr_agent`, `dater`) values ('success payment','".$id_your_product."','".$ip."','".$usragn."','".$date."')";
$q_log = mysql_query($sql_log);

$msg = 3;
}

}



}else if (strcmp ($lines[0], "fail") == 0) {
// log manual investigation

$sql_log = "insert into `log_pp`(`status`, `id_produk`, `usr_ip`, `usr_agent`, `dater`) values ('failed payment-failed strcmp','x','".$ip."','".$usragn."','".$date."')";
$q_log = mysql_query($sql_log);

echo "payment failed";
}

}
fclose ($fp);
?>

<meta http-equiv="refresh" content="0;url=thankyou.php?status=<?php echo $msg; ?>">



===========================================================


3. thankyou.php
to page thankyou.php isikan pesan status pembayaran. misalnya:

<?php
if(isset($_get['status'])){

if($_get['status']==1){echo 'error';}
if($_get['status']==2){echo 'error';}
if($_get['status']==3){echo 'success payment,..';}


}
?>



pasang auth token from paypal to page pay.php
login paypal, click to gambar gear that tercan to kanan atas, --> account settings
paypay account settings

 

to products & services click --> website payments . pada website payments click --> website preferences

website prefernces paypal

 

checklist to auto return for website payments and isikan website link to auto return click save. checklist payment data transfer copy identity token pastekan to page pay.php auth token.

paypal3

 

 

to paylal type personal = login paypal --> click gear (top right) --> website payments or alat pembayaran dalam bahasa indonesia --> website preferences or website preferensi dalam bahasa indonesia .


By Benny b9 at Apr 25 2020 Link :b9 follow us on :facebook twitter youtube || share to Facebook Tweitter WhatsApp
.
Most loggedin to submit comment.