From 8fe1f267a6b2fe310d7af0088909f48d68ceee8f Mon Sep 17 00:00:00 2001 From: Hadi Hosseini <111495011+HadiWP@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:21:20 +0330 Subject: [PATCH] add v3 --- Contact-Form-7-PayPing.php | 4 +- inc/CreatePay.php | 24 ++++--- inc/gateway.php | 143 +++++++++++++++++++++++-------------- readme.txt | 27 +++++++ 4 files changed, 132 insertions(+), 66 deletions(-) create mode 100644 readme.txt diff --git a/Contact-Form-7-PayPing.php b/Contact-Form-7-PayPing.php index 84fbab5..0b79603 100644 --- a/Contact-Form-7-PayPing.php +++ b/Contact-Form-7-PayPing.php @@ -1,9 +1,9 @@ Masoud Amini. -Version: 1.0.0 +Version: 1.1.0 Author: Mahdi Sarani Author URI: https://mahdisarani.ir Text Domain: CF7PayPing diff --git a/inc/CreatePay.php b/inc/CreatePay.php index 5627d34..083988b 100644 --- a/inc/CreatePay.php +++ b/inc/CreatePay.php @@ -64,12 +64,13 @@ $clientrefid = $wpdb->insert_id; /* Create Pay */ $pay_data = array( - 'payerName' => $Paymenter, - 'Amount' => $Amount, - 'payerIdentity'=> $payerIdentity , - 'returnUrl' => $CallbackURL, - 'Description' => $Description , - 'clientRefId' => $clientrefid + 'PayerName' => $Paymenter, + 'Amount' => $Amount, + 'PayerIdentity' => $payerIdentity , + 'ReturnUrl' => $CallbackURL, + 'Description' => $Description , + 'clientRefId' => (string) $clientrefid, + 'NationalCode' => '' ); $pay_args = array( 'body' => json_encode( $pay_data ), @@ -78,12 +79,16 @@ 'httpsversion' => '1.0', 'blocking' => true, 'headers' => array( + 'X-Platform' => 'ContactForm7', + 'X-Platform-Version' => '1.1.1', 'Authorization' => 'Bearer ' . $TokenCode, 'Content-Type' => 'application/json', - 'Accept' => 'application/json' ), + 'Accept' => 'application/json' + ), 'cookies' => array() ); - $pay_url = 'https://api.payping.ir/v2/pay'; + //var_dump($pay_data); die(); + $pay_url = 'https://api.payping.ir/v3/pay'; $pay_response = wp_remote_post( $pay_url, $pay_args ); $PAY_XPP_ID = $pay_response["headers"]["x-paypingrequest-id"]; if( is_wp_error( $pay_response ) ){ @@ -96,9 +101,10 @@ if( isset( $pay_response["body"] ) and $pay_response["body"] != '' ){ $code_pay = wp_remote_retrieve_body( $pay_response ); $code_pay = json_decode( $code_pay, true ); + $_x['transid'] = $code_pay["code"]; $wpdb->update( $table_name, $_x, array( 'id' => $clientrefid ), $_y, array( '%d' ) ); - wp_redirect( sprintf( 'https://api.payping.ir/v2/pay/gotoipg/%s', $code_pay["code"] ) ); + wp_redirect($code_pay["url"]); exit; }else{ $Message = ' تراکنش ناموفق بود- کد خطا : '.$PAY_XPP_ID; diff --git a/inc/gateway.php b/inc/gateway.php index 75f0291..5658b00 100644 --- a/inc/gateway.php +++ b/inc/gateway.php @@ -159,7 +159,7 @@ function CF7_PayPing_CreatePage( $title, $body ){ function CF7_PayPing_plugin_admin_notices() { if (!get_option('CF7_PayPing_plugin_notice_shown')) { - echo "
"; + echo esc_html_e(""); update_option("CF7_PayPing_plugin_notice_shown", "true"); } } @@ -313,7 +313,7 @@ function CF7_PayPing_save_contact_form( $cf7 ){ function CF7_PayPing_list_trans(){ if( !current_user_can("manage_options" ) ){ - wp_die( __( "You do not have sufficient permissions to access this page." ) ); + wp_die( esc_html( "You do not have sufficient permissions to access this page." ) ); } global $wpdb; @@ -327,7 +327,7 @@ function CF7_PayPing_list_trans(){ $num_of_pages = ceil($total / $limit); $cntx = 0; - echo 'وضعیت | - '; + '); if( count( $transactions ) == 0 ){ - echo '|||||
---|---|---|---|---|---|
هيج تراکنش وجود ندارد. | -