Plugin Directory

Changeset 3161482


Ignore:
Timestamp:
10/02/2024 11:45:50 AM (18 months ago)
Author:
payping
Message:

add payping v3

Location:
payping-gravityforms/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • payping-gravityforms/trunk/README.txt

    r3122735 r3161482  
    66Tested up to: 6.6
    77Requires PHP: 7.2
    8 Stable tag: 2.3.1
     8Stable tag: 2.4.1
    99License: GPLv3 or later
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    2626== Privacy Policy ==
    2727This plugin follows strict privacy guidelines. When using the api.payping.ir service, user data is securely transmitted and stored following industry best practices.
     28
     29
     30== Changelog ==
     31
     32== 2.4.1 ==
     33افزودن برخی از ویژگی ها.
  • payping-gravityforms/trunk/payping-gravityforms.php

    r3099658 r3161482  
    22/*
    33Plugin Name: PayPing GravityForms
    4 Version: 2.3.1
     4Version: 2.4.1
    55Description:  افزونه درگاه پرداخت پی‌پینگ برای Gravity forms
    66Plugin URI: https://www.payping.ir/
  • payping-gravityforms/trunk/payping.php

    r3103209 r3161482  
    20462046
    20472047        $data = array(
    2048             'payerName' => $user_name,
     2048            'PayerName' => $user_name,
    20492049            'Amount' => $Amount,
    2050             'payerIdentity' => $Mobile,
    2051             'returnUrl' => $ReturnPath,
     2050            'PayerIdentity' => $Mobile,
     2051            'ReturnUrl' => $ReturnPath,
    20522052            'Description' => $Description,
    2053             'clientRefId' => $entry_id
     2053            'ClientRefId' => $entry_id,
     2054            'NationalCode'  => ''
    20542055        );
    20552056       
    20562057        try {
    2057             $url = "https://api.payping.ir/v1/pay";
     2058            $url = "https://api.payping.ir/v3/pay";
    20582059            $headers = array(
     2060                'X-Platform'         => 'GravityForms',
     2061                'X-Platform-Version' => '2.3.1',
    20592062                "Accept" => "application/json",
    20602063                "Authorization" => "Bearer " . self::get_merchent(),
     
    20812084                    $response = json_decode($body, true);
    20822085       
    2083                     if (isset($response["code"]) && $response["code"] != '') {
    2084                         $Payment_URL = sprintf('https://api.payping.ir/v1/pay/gotoipg/%s', $response["code"]);
     2086                    if (isset($response["paymentCode"]) && $response["paymentCode"] != '') {
     2087                        $Payment_URL = sprintf('https://api.payping.ir/v3/pay/start/%s', $response["paymentCode"]);
    20852088                       
    20862089                        if ($valid_checker) {
     
    21352138    // #5
    21362139    public static function Verify() {
    2137 
     2140       
    21382141        if ( apply_filters( 'gf_gateway_payping_return', apply_filters( 'ppgf_gateway_verify_return', false ) ) ) {
    21392142            return;
     
    21602163
    21612164            $form = RGFormsModel::get_form_meta( $form_id );
    2162 
     2165           
    21632166            $payment_type = gform_get_meta( $entry["id"], 'payment_type' );
    21642167            gform_delete_meta( $entry['id'], 'payment_type' );
     
    22092212            }
    22102213            $Total_Money = GFCommon::to_money( $Total, $entry["currency"] );
    2211 
     2214           
    22122215            $free = false;
    2213             if ( empty( $_GET['no'] ) || $_GET['no'] != 'true' ) {
     2216           
     2217            $paypingResponse = stripslashes($_REQUEST['data']);
     2218            $responseData = json_decode($paypingResponse, true);
     2219            // Get refid
     2220            if (isset($responseData['paymentRefId'])) {
     2221                $refid = sanitize_text_field($responseData['paymentRefId']);
     2222            }else{
     2223                $refid = null;
     2224            }
     2225            if ($_REQUEST['status'] == 0) {
     2226                $Status = 'cancelled';
     2227                $Message = "کاربر در صفحه بانک از پرداخت انصراف داده است.";
     2228                $Fault = 'تراكنش توسط شما لغو شد.';
     2229               
     2230               
     2231            } else{
     2232                if ( empty( $_GET['no'] ) || $_GET['no'] != 'true' ) {
    22142233
    22152234                //Start of payping
     
    22172236                    $Amount = GFPersian_Payments::amount( $Amount, 'IRT', $form, $entry );
    22182237                }
    2219 
    2220                     $Authority = isset($_GET['refid']) ? sanitize_text_field($_GET['refid']) : '';
    2221                     $MerchantID = self::get_merchent();
     2238                $Authority = isset($responseData['paymentRefId']) ? sanitize_text_field($responseData['paymentRefId']) : '';
     2239                $MerchantID = self::get_merchent();
    22222240
    22232241                    try {
    2224                         $data = array('refId' => sanitize_text_field($_GET['refid']), 'amount' => $Amount);
     2242                        $data = array('PaymentRefId' => sanitize_text_field($responseData['paymentRefId']), 'Amount' => $Amount);
    22252243                   
    2226                         $url = "https://api.payping.ir/v1/pay/verify";
     2244                        $url = "https://api.payping.ir/v3/pay/verify";
    22272245                        $headers = array(
    22282246                            "Accept" => "application/json",
     
    22402258                            )
    22412259                        );
    2242                    
     2260                       
    22432261                        if (is_wp_error($response)) {
    22442262                            $Status = 'failed';
     
    22512269                                $body = wp_remote_retrieve_body($response);
    22522270                                $response = json_decode($body, true);
    2253                    
    2254                                 if (isset($_GET["refid"]) && $_GET["refid"] != '') {
     2271                                if (isset($response["paymentRefId"]) && $response["paymentRefId"] != '') {
    22552272                                    $Status = 'completed';
     2273                                    $Message = 'پرداخت با موفقیت انجام شد.';
    22562274                                } else {
    2257                                     $Message = 'متافسانه سامانه قادر به دریافت کد پیگیری نمی باشد! ';
     2275                                    $Message = 'متاسفانه سامانه قادر به دریافت کد پیگیری نمی باشد! ';
    22582276                                    $Status = 'failed';
    22592277                                }
     
    22622280                                $Message = implode('. ', array_values(json_decode($body, true)));
    22632281                                $Status = 'failed';
     2282                            }elseif ($header == 409){
     2283                                $Status = 'completed';
     2284                                $Message = 'این پرداخت قبلا تایید شده است.';
    22642285                            } else {
    22652286                                $Message = self::Fault($header) . '(' . $header . ')';
     
    22732294                   
    22742295               
    2275                 $Transaction_ID = isset($_GET['refid']) ? absint($_GET['refid']) : '-';
     2296                $Transaction_ID = isset($refid) ? absint($refid) : '-';
     2297                $CardNumber = isset($responseData['cardNumber']) ? $responseData['cardNumber'] : '-';
    22762298                //End of payping
    22772299            } else {
     
    22812303                $free           = true;
    22822304            }
    2283 
     2305            }
     2306           
     2307           
     2308           
    22842309            $Status         = ! empty( $Status ) ? $Status : 'failed';
    22852310            $transaction_id = ! empty( $Transaction_ID ) ? $Transaction_ID : '';
     
    22902315            $entry["transaction_id"]   = $transaction_id;
    22912316            $entry["transaction_type"] = $transaction_type;
    2292 
    22932317            if ( $Status == 'completed' ) {
    22942318
     
    23112335                    $Note = sprintf( esc_html__( 'وضعیت پرداخت : رایگان - بدون نیاز به درگاه پرداخت', "payping-gravityforms" ) );
    23122336                } else {
    2313                     $Note = sprintf( esc_html__( 'وضعیت پرداخت : موفق - مبلغ پرداختی : %s - کد تراکنش : %s', "payping-gravityforms" ), $Total_Money, $transaction_id );
     2337                    $Note = sprintf( esc_html__( 'وضعیت پرداخت : موفق - مبلغ پرداختی : %s - کد تراکنش : %s | شماره کارت: %s', "payping-gravityforms" ), $Total_Money, $transaction_id , $CardNumber);
    23142338                }
    23152339
     
    23742398                do_action( "gform_paypal_fulfillment", $entry, $paypal_config, $transaction_id, $Total );
    23752399            } else if ( $Status == 'cancelled' ) {
     2400               
    23762401                $entry["payment_status"] = "Cancelled";
    23772402                $entry["payment_amount"] = 0;
Note: See TracChangeset for help on using the changeset viewer.