Plugin Directory

Changeset 841274


Ignore:
Timestamp:
01/19/2014 01:12:29 PM (12 years ago)
Author:
picor.ir
Message:

update to 2.0 version

Location:
bank-mellat-edd-gateway
Files:
19 added
5 edited

Legend:

Unmodified
Added
Removed
  • bank-mellat-edd-gateway/trunk/Mellat_for_EDD.php

    r767396 r841274  
    22/**
    33    Plugin Name: Bank mellat EDD gateway
    4     Version: 1.1
    5     Description:  این افزونه درگاه بانک ملت را به افزونه EDD اضافه می کند.
     4    Version: 2.0
     5    Description:  این افزونه درگاه بانک ملت و شبکه پرداخت الکترونیک شاپرک را به افزونه فروش فایل EDD اضافه می کند.
    66    Plugin URI: http://picor.ir/Bank-mellat-EDD-gateway
    77    Author: Arash Heidari
    88    Author URI: http://www.picor.ir/
    99    License: GPL2
     10    Tested up to: 3.8
    1011**/
    1112if ( !defined( 'ABSPATH' ) ) {
     
    1516require_once('lib/nusoap.php');
    1617@session_start();
    17 /////---------------------------------------------------------
     18/////---------------------------------------------------
    1819function edd_bpm_rial ($formatted, $currency, $price) {
    1920
     
    2122}
    2223add_filter( 'edd_rial_currency_filter_after', 'edd_bpm_rial', 10, 3 );
    23 /////---------------------------------------------------------
     24/////------------------------------------------------
    2425function bpm_add_gateway ($gateways) {
    2526    $gateways['Mellat'] = array('admin_label' => 'درگاه بانک ملت', 'checkout_label' => 'بانک ملت');
     
    3334add_filter( 'edd_Mellat_cc_form', 'bpm_cc_form' );
    3435
    35 /////---------------------------------------------------------
     36/////--------------------------------------------------
    3637function bpmRequest(&$BpmWs, $Req, $params) {
    3738    $namespace='http://interfaces.core.sw.bps.com/';
     
    5253    return $res;
    5354}
    54 /////---------------------------------------------------------
     55/////-------------------------------------------------
    5556function bpm_process_payment ($purchase_data) {
    5657    error_reporting(0);
    5758    global $edd_options;
    58 
    59     if ($edd_options['Is_foreign']){
    60         $bpm_ws = 'https://pgwsf.bpm.bankmellat.ir:1443/pgwchannel/services/pgw?wsdl';
    61     }else{
    62         $bpm_ws = 'https://pgws.bpm.bankmellat.ir:443/pgwchannel/services/pgw?wsdl';
    63     }
    64    
     59    $bpm_ws = 'https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl';
    6560    $i=0;
    6661    do {
     
    7065    // Check for Connection error
    7166    if ($BpmWs->getError()){
    72         edd_set_error( 'pay_00', 'P00:خطا در اتصال به بانک، لطفاً مجدداً تلاش کنید...' );
     67        edd_set_error( 'pay_00', 'P00:خطایی در اتصال پیش آمد،مجدد تلاش کنید...' );
    7368        edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
    7469    }
     
    8479        'status' => 'pending',
    8580    );
    86    
    8781    $payment = edd_insert_payment($payment_data);
    88    
    89     $PayAddr = 'https://pgw.bpm.bankmellat.ir/pgwchannel/startpay.mellat';
     82    $PayAddr = 'https://bpm.shaparak.ir/pgwchannel/startpay.mellat';
    9083    $terminalId = $edd_options['Mellat_TermID'];
    9184    $userName = $edd_options['Mellat_UserName'];
    9285    $userPassword = $edd_options['Mellat_PassWord'];
    93    
    9486    if ($payment) {
    95        
    9687        $_SESSION['Mellat_payment'] = $payment;
    9788        $return = add_query_arg('order', 'Mellat', get_permalink($edd_options['success_page']));
    98        
    9989        $orderId = date('ym').date('His').$payment;
    10090        $amount = $purchase_data['price'];
     
    10494        $payerId = 0;
    10595
    106 /////////////////////PAY REQUEST////////////////////////////
     96/////////////////PAY REQUEST PART/////////////////////////
    10797        $parameters = array(
    10898            'terminalId' => $terminalId,
     
    117107            'payerId' => $payerId
    118108        );
    119        
    120109        // Call the SOAP method
    121110        $i=0;
     
    124113            $i++;
    125114        } while($PayResult[0] != "0" and $i<3);
    126 ///***************END of PAY REQUEST*******************///
     115///************END of PAY REQUEST***************///
    127116        if ($PayResult[0] == "0") {
    128             // Successfull Pay Request - Send user to pay url
     117            // Successfull Pay Request
    129118            echo '
    130119                <form name="MellatPay" method="post" action="'. $PayAddr .'">
     
    135124        }else {
    136125            edd_update_payment_status($payment, 'failed');
     126            edd_insert_payment_note( $payment, 'P02:'.CheckStatus((int)$PayResult[0]) );
    137127            edd_set_error( 'pay_02', ':P02'.CheckStatus((int)$PayResult[0]) );
    138128            edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
    139129        }
    140    
    141130    }else {
    142131        edd_set_error( 'pay_01', 'P01:خطا در ایجاد پرداخت، لطفاً مجدداً تلاش کنید...' );
     
    145134}
    146135add_action('edd_gateway_Mellat', 'bpm_process_payment');
    147 
    148 /////---------------------------------------------------------
     136/////----------------------------------------------------
    149137function bpm_verify() {
    150138    error_reporting(0);
     
    153141    $userName = $edd_options['Mellat_UserName'];
    154142    $userPassword = $edd_options['Mellat_PassWord'];
    155    
    156     if ($edd_options['Is_foreign']){
    157         $bpm_ws = 'https://pgwsf.bpm.bankmellat.ir:1443/pgwchannel/services/pgw?wsdl';
    158     }else{
    159         $bpm_ws = 'https://pgws.bpm.bankmellat.ir:443/pgwchannel/services/pgw?wsdl';
    160     }
    161 
     143    $bpm_ws = 'https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl';
    162144    if (isset($_GET['order']) and $_GET['order'] == 'Mellat' and isset($_POST['SaleOrderId']) and $_SESSION['Mellat_payment'] == substr($_POST['SaleOrderId'],10) and $_POST['ResCode'] == '0') {
    163        
    164145        $payment = $_SESSION['Mellat_payment'];
    165146        $RefId = $_POST['RefId'];
     
    168149        $SaleOrderId = $_POST['SaleOrderId'];
    169150        $SaleReferenceId = $_POST['SaleReferenceId'];
    170        
    171151        $do_inquiry = false;
    172152        $do_settle = false;
    173153        $do_reversal = false;
    174154        $do_publish = false;
    175        
    176155        //Connect to WebService
    177156        $i=0;
     
    179158            $BpmWs = new nusoap_client($bpm_ws);
    180159            $i++;
    181         }while ( $BpmWs->getError() and $i<5 );//Check for connection error
     160        }while ( $BpmWs->getError() and $i<5 );//Check for connection errors
    182161        if ($BpmWs->getError()){
    183162            edd_set_error( 'ver_00', 'V00:تراکنش ناموفق بود.<br>اگر وجهی از حساب شما کسر شده باشد، تا پایان روز جاری به حساب شما باز خواهد گشت.' );
    184163            edd_update_payment_status($_SESSION['Mellat_payment'], 'failed');
     164            edd_insert_payment_note( $_SESSION['Mellat_payment'], 'V00:'.'<pre>'.$BpmWs->getError().'</pre>' );
    185165            edd_send_back_to_checkout('?payment-mode=Mellat');
    186166        }
     
    194174            'saleReferenceId' => $SaleReferenceId
    195175        );
    196 /////////////////////VERIFY REQUEST///////////////////////////
     176//////////////////VERIFY REQUEST///////////////////////
    197177        if (!edd_is_test_mode()) {
    198178            // Call the SOAP method
    199179            $VerResult = bpmRequest($BpmWs, 'bpVerifyRequest', $parameters);
    200        
    201180            if ($VerResult[0] == "0") {
    202181                // Note: Successful Verify means complete successful sale was done.
     
    215194            $do_inquiry = false;
    216195        }
    217 ///********************************END of VERIFY REQUEST**///
     196///*************************END of VERIFY REQUEST**///
    218197
    219198///INQUIRY REQUEST//////////////////////////////////////////
     
    239218            }
    240219        }
    241 ///***************END of INQUIRY REQUEST*******************///
    242 
    243 //////////------------SETTLE REQUEST-------------/////////////
     220///***********END of INQUIRY REQUEST**************///
     221///////------------SETTLE REQUEST-------------//////////
    244222        if ($do_settle) {
    245223            // Call the SOAP method
     
    249227                $i++;
    250228            }while ( $SettResult[0] != "0" and $i<5 );
    251            
    252229            if ($SettResult[0] == "0") {
    253230                // Note: Successful Settle means that sale is settled.
     
    262239            }
    263240        }
    264 ///***************END of SETTLE REQUEST*******************///
    265 
    266 /////////////////////REVERSAL REQUEST///////////////////////
     241///*************END of SETTLE REQUEST****************///
     242
     243//////////////////REVERSAL REQUEST////////////////////
    267244        if ($do_reversal) {
    268245            $i=0;
     
    271248                $i++;
    272249            }while ($RevResult[0] != "0" and $i<5);
    273            
    274250            // Note: Successful Reversal means that sale is reversed.
    275251            edd_update_payment_status($payment, 'failed');
     252            edd_insert_payment_note( $payment, 'REV:'.CheckStatus((int)$RevResult[0]) );
    276253            edd_set_error( 'rev_'.$RevResult[0], 'R00:تراکنش ناموفق بود.<br>اگر وجهی از حساب شما کسر شده باشد، تا پایان روز جاری به حساب شما باز خواهد گشت.' );
    277254            edd_send_back_to_checkout('?payment-mode=Mellat');
     
    284261            $do_publish = false;
    285262            edd_update_payment_status($payment, 'publish');
     263            edd_insert_payment_note( $payment, 'شماره تراکنش:'.$SaleReferenceId );
    286264            echo "<script type='text/javascript'>alert('کد تراکنش خرید بانک : ".$SaleReferenceId."');</script>";
    287265        }
    288        
    289266    }else if (isset($_GET['order']) and $_GET['order'] == 'Mellat' and isset($_POST['SaleOrderId']) and $_SESSION['Mellat_payment'] == substr($_POST['SaleOrderId'],10) and $_POST['ResCode'] != '0'){
    290267        edd_update_payment_status($_SESSION['Mellat_payment'], 'failed');
     268        edd_insert_payment_note($_SESSION['Mellat_payment'], 'V02:'.CheckStatus((int)$_POST['ResCode']) );
    291269        edd_set_error( $_POST['ResCode'], CheckStatus((int)$_POST['ResCode']) );
    292270        edd_send_back_to_checkout('?payment-mode=Mellat');
    293        
    294     }
    295        
     271    }   
    296272}
    297273add_action('init', 'bpm_verify');
    298 /////---------------------------------------------------------
     274/////-----------------------------------------------
    299275function bpm_add_settings ($settings) {
    300276    $Mellat_settings = array (
    301277        array (
    302278            'id'        =>  'Mellat_settings',
    303             'name'      =>  '<strong>پيکربندي درگاه بانک ملت</strong><br>(در حالت آزمااشی این قسمت رو تکمیل نکنید)',
     279            'name'      =>  '<strong>پيکربندي درگاه بانک ملت</strong><br>(در حالت آزمایشی این قسمت را تکمیل نکنید)',
    304280            'desc'      =>  'پيکربندي درگاه بانک ملت با تنظيمات فروشگاه',
    305281            'type'      =>  'header'
    306282        ),
    307283        array (
    308             'id'        =>  'Is_foreign',
    309             'name'      =>  'موقعیت هاست',
    310             'desc'      =>  '<strong>در صورت قرار گرفتن سایت شما روی هاست خارجی این گزینه را تیک بزنید</strong>',
    311             'type'      =>  'checkbox'
    312         ),
    313         array (
    314284            'id'        =>  'Mellat_TermID',
    315             'name'      =>  'ترمینال عملیاتی',
     285            'name'      =>  'شماره ترمينال',
    316286            'desc'      =>  '',
    317287            'type'      =>  'text',
     
    327297        array (
    328298            'id'        =>  'Mellat_PassWord',
    329             'name'      =>  'گذرواژه',
     299            'name'      =>  'رمز',
    330300            'desc'      =>  '',
    331301            'type'      =>  'text',
    332302            'size'      =>  'medium'
    333303        )
    334        
    335304    );
    336305    return array_merge( $settings, $Mellat_settings );
    337306}
    338307add_filter('edd_settings_gateways', 'bpm_add_settings');
    339 /////---------------------------------------------------------
     308/////-------------------------------------------------
    340309function CheckStatus($ecode) {
    341310    $tmess="شرح خطا: ";
  • bank-mellat-edd-gateway/trunk/readme.txt

    r767396 r841274  
    44Author URI: http://picor.ir
    55Donate link: http://picor.ir
    6 Tags: bank mellat, easy digital downloads, EDD gateways
     6Tags: bank mellat, easy digital downloads, EDD gateways,
    77Requires at least: 3.0
    8 Tested up to: 3.6
    9 Stable tag: 1.1
     8Tested up to: 3.8
     9Stable tag: 2.0
    1010
    11 Thia plugin will add bank mellat gateway to EDD plugin
     11Thia plugin will add Bank Mellat and Shaparak Electronic Network gateway to EDD plugin
    1212
    1313== Description ==
     
    1616Features:
    1717
    18 * Add Bank mellat gateway to easy digital downloads plugin.
     18*
     19* Add Bank mellat and Shaparak Electronic Network gateway to easy digital downloads plugin.
    1920* Sell digital downloads through Persian WordPress in iran.
    2021
     
    3637
    3738== Upgrade Notice ==
     39= 2.0 =
     40* Added shaparak electronic network gateway
     41
    3842= 1.1 =
    3943* Fix a problem.
     
    4347
    4448== Changelog ==
     49= 2.0 =
     50* Added shaparak electronic network gateway
     51
    4552= 1.1=
    4653* Fix a problem.
     
    5057
    5158== Donations ==
    52 You can Donate plugin author here http://pay.picor.ir
     59You can Donate plugin author here http://picor.ir
    5360
    5461== Frequently Asked Questions ==
Note: See TracChangeset for help on using the changeset viewer.