Automatic Silk

Results 1 to 5 of 5
  1. #1
    Apprentice sonytal is offline
    MemberRank
    Sep 2012 Join Date
    6Posts

    Automatic Silk

    Hello RZ ;)
    i test my donation methond (paypal) in my own p-server site and after donation is completed Silks dont arrive at the char item mall inventory, does anybody know how to make it automatically?
    thanks...


  2. #2
    Account Upgraded | Title Enabled! serend is offline
    MemberRank
    Mar 2012 Join Date
    eurosro.coLocation
    338Posts

    Re: Automatic Silk

    post your script source then we might beable to see whats wrong without it good luck in getting your help

  3. #3
    Apprentice sonytal is offline
    MemberRank
    Sep 2012 Join Date
    6Posts

    Re: Automatic Silk

    Quote Originally Posted by serend View Post
    post your script source then we might beable to see whats wrong without it good luck in getting your help
    here it is:
    ini_set('error_log', dirname(__FILE__).'/ipn_errors.log');
    // intantiate the IPN listener
    include('ipnlistener.php');
    $listener = new IpnListener();
    // tell the IPN listener to use the PayPal test sandbox
    $listener->use_sandbox = false;
    // try to process the IPN POST
    try {
    $listener->requirePostMethod();
    $verified = $listener->processIpn();
    } catch (Exception $e) {
    error_log($e->getMessage());
    exit(0);
    }
    if ($verified) {
    $errmsg = ''; // stores errors from fraud checks
    // Make sure the payment status is "Completed"
    if ($_POST['payment_status'] != 'Completed') {
    // simply ignore any IPN that is not completed
    exit(0);
    }
    // Make sure seller email matches your primary account email.
    if ($_POST['receiver_email'] != $ppEmail) {
    $errmsg .= "'receiver_email' does not match: ";
    $errmsg .= $_POST['receiver_email']."\n";
    }
    //checks currency
    if ($_POST['mc_currency'] != 'EUR') {
    $errmsg .= "'mc_currency' does not match: ";
    $errmsg .= $_POST['mc_currency']."\n";
    }
    // Make sure the amount(s) paid match
    if ($_POST['mc_currency'] = 'EUR') {
    if (!in_array($_POST['mc_gross'],$amountUsd)) {
    $errmsg .= "'mc_gross' does not match: ";
    $errmsg .= $_POST['mc_gross']."\n";
    }
    }
    /* if ($_POST['mc_currency'] = 'EUR') {
    if (!in_array(number_format($_POST['mc_gross'],2),number_format($amountEur, 2))) {
    $errmsg .= "'mc_gross' does not match: ";
    $errmsg .= $_POST['mc_gross']."\n";
    }
    }
    */
    // Ensure the transaction is not a duplicate.
    $txn_id = ms_escape_string($_POST['txn_id']);
    // Execute the query.
    $stmt = $mssql->dbQuery("SELECT * FROM orders WHERE txn_id = '$txn_id'");
    //Is query not succesfull
    if (!$stmt) {
    error_log(print_r("Not sucessful", true));
    exit(0);
    }
    else {
    //Count rows
    $row_count = mssql_num_rows($stmt);

    if ($row_count>0) {
    $errmsg .= "'txn_id' has already been processed: ".$_POST['txn_id']."\n";
    }
    }
    if (!empty($errmsg)) {
    // manually investigate errors from the fraud checking
    $body = "IPN failed fraud checks: \n$errmsg\n\n";
    $body .= $listener->getTextReport();
    error_log($body); exit(0);
    } else {
    $payer_email = $sec->secure($_POST['payer_email']);
    $mc_gross = $sec->secure($_POST['mc_gross']);
    $username = $sec->secure($_POST['custom']);
    $timenow = time();
    //Prepare params
    // Execute the query.
    $stmt = $mssql->dbQuery("INSERT INTO orders (txn_id,payer_email,mc_gross,username) VALUES ('$txn_id','$payer_email','$mc_gross','$username')");
    //Is query succesful
    if (!$stmt) {
    error_log(print_r("U MAD ", true));
    exit(0);
    }
    //silk update
    $silkAmount = $usdToSilks[(int)$mc_gross];
    $query = ("SELECT * FROM TB_User WHERE StrUserId='$username'");
    $row = sqlsrv_fetch_array($query);
    $JID=$row['JID'];
    if(!$mssql->numRows("SELECT * FROM SK_Silk WHERE JID='$JID'")) {
    $insert = $mssql->dbQuery("INSERT INTO SK_Silk(JID,silk_own,silk_gift,silk_point) VALUES('$JID','$silkAmount','0','0')");
    } else {
    $query5 = $mssql->dbQuery("SELECT * FROM SK_Silk WHERE JID='$JID'");
    $fetch = sqlsrv_fetch_array($query5);
    $all = $fetch['silk_own'] + $silkAmount;
    $final = $mssql->dbQuery("UPDATE SK_Silk SET silk_own='$all' WHERE JID='$JID'");
    }
    }
    } else {
    // manually investigate the invalid IPN
    mail($personalEmail, 'Invalid IPN', $listener->getTextReport());
    }
    $mssql->dbClose();
    ?>



    another one:


    <?php
    //reading raw POST data from input stream. reading pot data from $_POST may cause serialization issues since POST data may contain arrays
    $raw_post_data = file_get_contents('php://input');
    $raw_post_array = explode('&', $raw_post_data);
    $myPost = array();
    foreach ($raw_post_array as $keyval)
    {
    $keyval = explode ('=', $keyval);
    if (count($keyval) == 2)
    $myPost[$keyval[0]] = urldecode($keyval[1]);
    }
    // read the post from PayPal system and add 'cmd'
    $req = 'cmd=_notify-validate';
    if(function_exists('get_magic_quotes_gpc'))
    {
    $get_magic_quotes_exits = true;
    }
    foreach ($myPost as $key => $value)
    {
    if($get_magic_quotes_exits == true && get_magic_quotes_gpc() == 1)
    {
    $value = urlencode(stripslashes($value));
    }
    else
    {
    $value = urlencode($value);
    }
    $req .= "&$key=$value";
    }

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://www.paypal.com/cgi-bin/webscr');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: www.paypal.com'));
    // In wamp like environment where the root authority certificate doesn't comes in the bundle, you need
    // to download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set the directory path
    // of the certificate as shown below.
    // curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
    $res = curl_exec($ch);
    curl_close($ch);

    // assign posted variables to local variables
    $item_name = $_POST['item_name'];
    $item_number = $_POST['item_number'];
    $payment_status = $_POST['payment_status'];
    $payment_amount = $_POST['mc_gross'];
    $payment_currency = $_POST['mc_currency'];
    $txn_id = $_POST['txn_id'];
    $receiver_email = $_POST['receiver_email'];
    $payer_email = $_POST['payer_email'];


    if (strcmp ($res, "VERIFIED") == 0) {
    // check the payment_status is Completed
    // check that txn_id has not been previously processed
    // check that receiver_email is your Primary PayPal email
    // check that payment_amount/payment_currency are correct
    // process payment
    }
    else if (strcmp ($res, "INVALID") == 0) {
    // log for manual investigation
    }
    ?>

  4. #4
    Apprentice sonytal is offline
    MemberRank
    Sep 2012 Join Date
    6Posts

    Re: Automatic Silk

    bump .

  5. #5
    Valued Member Nexus2oo7 is offline
    MemberRank
    Mar 2008 Join Date
    102Posts

    Re: Automatic Silk

    bump2



Advertisement