• 08-12-2024, 14:29:24
    #1
    Merhaba değerleri forum sakinleri tüm işlemleri doğru yapmama rağmen ödeme sırasında bana "API Anahtarı hatalı. Eğer bu internet sitesinin sahibi sizseniz, lütfen Shopier hesabınızda API Erişimi bölümünde bulunan API Key ve API Secret alanlarının, internet sitenizin e-ticaret panelinde Shopier modül ayarları alanında doğru girilmiş olduğunu kontrol ediniz." hatası veriyor ama modül yönetiminde gösterilen API Key ve API Secret bilgileri ile işlem yapmaktayım aşağıya kodlarımıda bırakıyorum ve çıktı kodumda şöyle

    https://www.shopier.com/ShowProduct/...9734e114a1f4b0

    herhangi bir eksik işlem mi yapıyorum yoksa API bilgilerini kullanabilmek için ne yapmam lazım yardımcı olursanız çok sevinirim





  • 08-12-2024, 14:32:43
    #2
    Wordpress & PHP Uzmanı
    Selamlar php uzmanıyım ücretli yardım almak isterseniz wp: +90 542 572 26 46
  • 08-12-2024, 14:38:07
    #3
    imzadan ulaşabilrisiniz.
  • 10-12-2024, 08:04:28
    #4
    <?php
    class Shopier
        {
            private $payment_url = 'https://www.shopier.com/ShowProduct/api_pay4.php';
            private
                $api_key,
                $api_secret,
                $module_version,
                $buyer = [],
                $currency = 'TRY';
    
            public function __construct($api_key='', $api_secret='', $module_version = ('1.0.4'))
            {
                $this->api_key = $api_key;
                $this->api_secret = $api_secret;
                $this->module_version = $module_version;
            }
    
            public function setBuyer(array $fields = [])
            {
                $this->buyerValidateAndLoad($this->buyerFields(), $fields);
            }
    
            public function setOrderBilling(array $fields = [])
            {
                $this->buyerValidateAndLoad($this->orderBillingFields(), $fields);
            }
    
            public function setOrderShipping(array $fields = [])
            {
                $this->buyerValidateAndLoad($this->orderShippingFields(), $fields);
            }
    
            private function buyerValidateAndLoad($validationFields='', $fields='')
            {
                $diff = array_diff_key($validationFields, $fields);
    
                if (count($diff) > 0)
                    throw new Exception(implode(',', array_keys($diff)) . ' fields are required');
    
                foreach ($validationFields as $key => $buyerField) {
                    $this->buyer[$key] = $fields[$key];
                }
            }
    
            public function generateFormObject($order_id='', $order_total='', $callback_url='')
            {
    
                $diff = array_diff_key($this->buyerFields(), $this->buyer);
    
                if (count($diff) > 0)
                    throw new Exception(implode(',', array_keys($diff)) . ' fields are required use "setBuyer()" method ');
    
                $diff = array_diff_key($this->orderBillingFields(), $this->buyer);
    
                if (count($diff) > 0)
                    throw new Exception(implode(',', array_keys($diff)) . ' fields are required use "setOrderBilling()" method ');
    
                $diff = array_diff_key($this->orderShippingFields(), $this->buyer);
    
                if (count($diff) > 0)
                    throw new Exception(implode(',', array_keys($diff)) . ' fields are required use "setOrderShipping()" method ');
    
    
                $args = array(
                    'API_key' => $this->api_key,
                    'website_index' => 1,
                    'platform_order_id' => $order_id,
                    'product_name' => '',
                    'product_type' => 0, //1 : downloadable-virtual 0:real object,2:default
                    'buyer_name' => $this->buyer['first_name'],
                    'buyer_surname' => $this->buyer['last_name'],
                    'buyer_email' => $this->buyer['email'],
                    'buyer_account_age' => 0,
                    'buyer_id_nr' => $this->buyer['id'],
                    'buyer_phone' => $this->buyer['phone'],
                    'billing_address' => $this->buyer['billing_address'],
                    'billing_city' => $this->buyer['billing_city'],
                    'billing_country' => $this->buyer['billing_country'],
                    'billing_postcode' => $this->buyer['billing_postcode'],
                    'shipping_address' => $this->buyer['shipping_address'],
                    'shipping_city' => $this->buyer['shipping_city'],
                    'shipping_country' => $this->buyer['shipping_country'],
                    'shipping_postcode' => $this->buyer['shipping_postcode'],
                    'total_order_value' => $order_total,
                    'currency' => $this->getCurrency(),
                    'platform' => 0,
                    'is_in_frame' => 0,
                    'current_language' => $this->lang(),
                    'modul_version' => $this->module_version,
                    'random_nr' => rand(100000, 999999)
                );
    
    
                $data = $args["random_nr"] . $args["platform_order_id"] . $args["total_order_value"] . $args["currency"];
                $signature = hash_hmac('sha256', $data, $this->api_secret, true);
                $signature = base64_encode($signature);
                $args['signature'] = $signature;
                $args['callback'] = $callback_url;
    
                return [
                    'elements' => [
                        [
                            'tag' => 'form',
                            'attributes' => [
                                'id' => 'shopier_form_special',
                                'method' => 'post',
                                'action' => $this->payment_url
                            ],
                            'children' => array_map(function ($key, $value) {
                                return [
                                    'tag' => 'input',
                                    'attributes' => [
                                        'name' => $key,
                                        'value' => $value,
                                        'type' => 'hidden',
                                    ]
                                ];
    
                            }, array_keys($args), array_values($args))
                        ]
                    ]
                ];
    
            }
    
    
            public function generateForm($order_id='', $order_total='', $callback_url='')
            {
                $obj = $this->generateFormObject($order_id, $order_total, $callback_url);
    
                return $this->recursiveHtmlStringGenerator($obj['elements']);
            }
    
            public function run($order_id='', $order_total='', $callback_url='')
            {
    
                $form = $this->generateForm($order_id, $order_total, $callback_url);
    
                return '<!doctype html>
                 <html lang="en">
                <head>
        <meta charset="UTF-8">
        <meta name="viewport"
              content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title></title>
         </head>
    ' . $form . '
        <body>
            <script type="text/javascript">
                        document.getElementById("shopier_form_special").submit();
            </script>
         </body>
        </html>
         ';
            }
    
            // generateFormObject() sınıfının verdiği formattaki arrayden structure çıkartan yapıdırı.
            private function recursiveHtmlStringGenerator(array $elements = [], $string = null)
            {
                foreach ($elements as $element) {
                    $attributes = (empty($element['attributes'])) ? [] : $element['attributes'];
                    $attributes = array_map(function ($key, $value) {
                        return $key . '="' . $value . '"';
                    }, array_keys($attributes), array_values($attributes));
                    $attribute_string = implode(' ', $attributes);
                    $html_in = (empty($element['source'])) ? NULL : $element['source'];
                    $string .= "<{$element['tag']} {$attribute_string} > " . $html_in;
    
                    if (isset($element['children']) && is_array($element['children']))
                        $string = $this->recursiveHtmlStringGenerator($element['children'], $string);
    
                    $string .= "</{$element['tag']}>";
    
                }
                return $string;
            }
    
    
            //shopierden gelen dataları kontrol eder.
            public function verifyShopierSignature($post_data='')
            {
    
                if (isset($post_data['platform_order_id'])) {
                    $order_id = $post_data['platform_order_id'];
                    $random_nr = $post_data['random_nr'];
                    if ($order_id != '') {
                        $signature = base64_decode($_POST["signature"]);
                        $expected = hash_hmac('sha256', $random_nr . $order_id, $this->api_secret, true);
    
                        if ($signature == $expected)
                            return true;
    
                    }
    
    
                }
                return false;
            }
    
            private function buyerFields()
            {
                return [
                    'id' => true,
                    'first_name' => true,
                    'last_name' => true,
                    'email' => true,
                    'phone' => true,
                ];
            }
    
            private function orderBillingFields()
            {
                return [
                    'billing_address' => true,
                    'billing_city' => true,
                    'billing_country' => true,
                    'billing_postcode' => true,
                ];
            }
    
            private function orderShippingFields()
            {
                return [
                    'shipping_address' => true,
                    'shipping_city' => true,
                    'shipping_country' => true,
                    'shipping_postcode' => true,
                ];
            }
    
            private function getCurrency()
            {
                $currencyList = [
                    'TRY' => 0,
                    'USD' => 1,
                    'EUR' => 2,
                ];
                return 0;
            }
    
            private function lang()
            {
                $current_language = "tr-TR";
                $current_lan = 1;
                if ($current_language == "tr-TR") {
                    $current_lan = 0;
                }
    
                return $current_lan;
            }
    
        }
    Aşağıdaki kod ile Shopier tarafına istek atabilirsiniz. Lakin bu kod öncesi lütfen yukarıdaki Shopier sınıfını ayrı bir dosya içerisine ekleyip bu kodların en üstüne include etmeyi unutmayınız.
    <?php
    $shopier = new Shopier($key, $secret);
                            $shopier->setBuyer([
                                'id' => $orderid,
                                'first_name' => $firstName,
                                'last_name' => $lastName,
                                'email' => $email,
                                'phone' => $phone
                            ]);
                            $shopier->setOrderBilling([
                                'billing_address' => '',
                                'billing_city' => '',
                                'billing_country' => '',
                                'billing_postcode' => '',
                            ]);
                            $shopier->setOrderShipping([
                                'shipping_address' => '',
                                'shipping_city' => '',
                                'shipping_country' => '',
                                'shipping_postcode' => '',
                            ]);
                            die($shopier->run($orderid, $tutar, $redirect_link));
    Aşağıdaki kod ise yukarıda Redirect aşamasında belirtmiş olduğunuz $redirect_link içerisinde çalıştıracağınız kodlardır. Burada ilgili ödemenin son kontrollerini yapıp veritabanınızda işlemlerinizi gerçekleştirebilirsiniz.
    if (isset($_POST['platform_order_id'])) {
                $order_id = $_POST['platform_order_id'];
                $status = $_POST['status'];
                $payment_id = $_POST['payment_id'];
                $installment = $_POST['installment'];
                $random_nr = $_POST['random_nr'];
                if ($order_id != '') {
                    $signature = $_POST["signature"];
                    $expected = base64_encode(hash_hmac(SHA256,$random_nr.$order_id,$secret, true));
                    if ($signature == $expected) {
                        // tüm kontrollerin yapılacağı alan
                    }
                }else {
                    Header("Location:".base_url('basarisiz'));
                }
            }else {
                Header("Location:".base_url('/'));
                exit;
            }
    @emrebt5; Umarım siz dahil olmak üzere bu konuda problem yaşayan diğer arkadaşlara da faydalı olacaktır. Söylediğim şekilde ilerleme kaydeder ve kodlardaki gerekli alanları doğru şekilde ekleyip çalıştırırsanız hiç bir sorun yaşamadan Shopier Entegrasyonunu yapmış olacaksınız. Hayırlı günler bol kazançlar dilerim.
  • 17-06-2025, 00:03:59
    #5
    iyovi adlı üyeden alıntı: mesajı görüntüle
    <?php
    class Shopier
        {
            private $payment_url = 'https://www.shopier.com/ShowProduct/api_pay4.php';
            private
                $api_key,
                $api_secret,
                $module_version,
                $buyer = [],
                $currency = 'TRY';
    
            public function __construct($api_key='', $api_secret='', $module_version = ('1.0.4'))
            {
                $this->api_key = $api_key;
                $this->api_secret = $api_secret;
                $this->module_version = $module_version;
            }
    
            public function setBuyer(array $fields = [])
            {
                $this->buyerValidateAndLoad($this->buyerFields(), $fields);
            }
    
            public function setOrderBilling(array $fields = [])
            {
                $this->buyerValidateAndLoad($this->orderBillingFields(), $fields);
            }
    
            public function setOrderShipping(array $fields = [])
            {
                $this->buyerValidateAndLoad($this->orderShippingFields(), $fields);
            }
    
            private function buyerValidateAndLoad($validationFields='', $fields='')
            {
                $diff = array_diff_key($validationFields, $fields);
    
                if (count($diff) > 0)
                    throw new Exception(implode(',', array_keys($diff)) . ' fields are required');
    
                foreach ($validationFields as $key => $buyerField) {
                    $this->buyer[$key] = $fields[$key];
                }
            }
    
            public function generateFormObject($order_id='', $order_total='', $callback_url='')
            {
    
                $diff = array_diff_key($this->buyerFields(), $this->buyer);
    
                if (count($diff) > 0)
                    throw new Exception(implode(',', array_keys($diff)) . ' fields are required use "setBuyer()" method ');
    
                $diff = array_diff_key($this->orderBillingFields(), $this->buyer);
    
                if (count($diff) > 0)
                    throw new Exception(implode(',', array_keys($diff)) . ' fields are required use "setOrderBilling()" method ');
    
                $diff = array_diff_key($this->orderShippingFields(), $this->buyer);
    
                if (count($diff) > 0)
                    throw new Exception(implode(',', array_keys($diff)) . ' fields are required use "setOrderShipping()" method ');
    
    
                $args = array(
                    'API_key' => $this->api_key,
                    'website_index' => 1,
                    'platform_order_id' => $order_id,
                    'product_name' => '',
                    'product_type' => 0, //1 : downloadable-virtual 0:real object,2:default
                    'buyer_name' => $this->buyer['first_name'],
                    'buyer_surname' => $this->buyer['last_name'],
                    'buyer_email' => $this->buyer['email'],
                    'buyer_account_age' => 0,
                    'buyer_id_nr' => $this->buyer['id'],
                    'buyer_phone' => $this->buyer['phone'],
                    'billing_address' => $this->buyer['billing_address'],
                    'billing_city' => $this->buyer['billing_city'],
                    'billing_country' => $this->buyer['billing_country'],
                    'billing_postcode' => $this->buyer['billing_postcode'],
                    'shipping_address' => $this->buyer['shipping_address'],
                    'shipping_city' => $this->buyer['shipping_city'],
                    'shipping_country' => $this->buyer['shipping_country'],
                    'shipping_postcode' => $this->buyer['shipping_postcode'],
                    'total_order_value' => $order_total,
                    'currency' => $this->getCurrency(),
                    'platform' => 0,
                    'is_in_frame' => 0,
                    'current_language' => $this->lang(),
                    'modul_version' => $this->module_version,
                    'random_nr' => rand(100000, 999999)
                );
    
    
                $data = $args["random_nr"] . $args["platform_order_id"] . $args["total_order_value"] . $args["currency"];
                $signature = hash_hmac('sha256', $data, $this->api_secret, true);
                $signature = base64_encode($signature);
                $args['signature'] = $signature;
                $args['callback'] = $callback_url;
    
                return [
                    'elements' => [
                        [
                            'tag' => 'form',
                            'attributes' => [
                                'id' => 'shopier_form_special',
                                'method' => 'post',
                                'action' => $this->payment_url
                            ],
                            'children' => array_map(function ($key, $value) {
                                return [
                                    'tag' => 'input',
                                    'attributes' => [
                                        'name' => $key,
                                        'value' => $value,
                                        'type' => 'hidden',
                                    ]
                                ];
    
                            }, array_keys($args), array_values($args))
                        ]
                    ]
                ];
    
            }
    
    
            public function generateForm($order_id='', $order_total='', $callback_url='')
            {
                $obj = $this->generateFormObject($order_id, $order_total, $callback_url);
    
                return $this->recursiveHtmlStringGenerator($obj['elements']);
            }
    
            public function run($order_id='', $order_total='', $callback_url='')
            {
    
                $form = $this->generateForm($order_id, $order_total, $callback_url);
    
                return '<!doctype html>
                 <html lang="en">
                <head>
        <meta charset="UTF-8">
        <meta name="viewport"
              content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title></title>
         </head>
    ' . $form . '
        <body>
            <script type="text/javascript">
                        document.getElementById("shopier_form_special").submit();
            </script>
         </body>
        </html>
         ';
            }
    
            // generateFormObject() sınıfının verdiği formattaki arrayden structure çıkartan yapıdırı.
            private function recursiveHtmlStringGenerator(array $elements = [], $string = null)
            {
                foreach ($elements as $element) {
                    $attributes = (empty($element['attributes'])) ? [] : $element['attributes'];
                    $attributes = array_map(function ($key, $value) {
                        return $key . '="' . $value . '"';
                    }, array_keys($attributes), array_values($attributes));
                    $attribute_string = implode(' ', $attributes);
                    $html_in = (empty($element['source'])) ? NULL : $element['source'];
                    $string .= "<{$element['tag']} {$attribute_string} > " . $html_in;
    
                    if (isset($element['children']) && is_array($element['children']))
                        $string = $this->recursiveHtmlStringGenerator($element['children'], $string);
    
                    $string .= "</{$element['tag']}>";
    
                }
                return $string;
            }
    
    
            //shopierden gelen dataları kontrol eder.
            public function verifyShopierSignature($post_data='')
            {
    
                if (isset($post_data['platform_order_id'])) {
                    $order_id = $post_data['platform_order_id'];
                    $random_nr = $post_data['random_nr'];
                    if ($order_id != '') {
                        $signature = base64_decode($_POST["signature"]);
                        $expected = hash_hmac('sha256', $random_nr . $order_id, $this->api_secret, true);
    
                        if ($signature == $expected)
                            return true;
    
                    }
    
    
                }
                return false;
            }
    
            private function buyerFields()
            {
                return [
                    'id' => true,
                    'first_name' => true,
                    'last_name' => true,
                    'email' => true,
                    'phone' => true,
                ];
            }
    
            private function orderBillingFields()
            {
                return [
                    'billing_address' => true,
                    'billing_city' => true,
                    'billing_country' => true,
                    'billing_postcode' => true,
                ];
            }
    
            private function orderShippingFields()
            {
                return [
                    'shipping_address' => true,
                    'shipping_city' => true,
                    'shipping_country' => true,
                    'shipping_postcode' => true,
                ];
            }
    
            private function getCurrency()
            {
                $currencyList = [
                    'TRY' => 0,
                    'USD' => 1,
                    'EUR' => 2,
                ];
                return 0;
            }
    
            private function lang()
            {
                $current_language = "tr-TR";
                $current_lan = 1;
                if ($current_language == "tr-TR") {
                    $current_lan = 0;
                }
    
                return $current_lan;
            }
    
        }
    Aşağıdaki kod ile Shopier tarafına istek atabilirsiniz. Lakin bu kod öncesi lütfen yukarıdaki Shopier sınıfını ayrı bir dosya içerisine ekleyip bu kodların en üstüne include etmeyi unutmayınız.
    <?php
    $shopier = new Shopier($key, $secret);
                            $shopier->setBuyer([
                                'id' => $orderid,
                                'first_name' => $firstName,
                                'last_name' => $lastName,
                                'email' => $email,
                                'phone' => $phone
                            ]);
                            $shopier->setOrderBilling([
                                'billing_address' => '',
                                'billing_city' => '',
                                'billing_country' => '',
                                'billing_postcode' => '',
                            ]);
                            $shopier->setOrderShipping([
                                'shipping_address' => '',
                                'shipping_city' => '',
                                'shipping_country' => '',
                                'shipping_postcode' => '',
                            ]);
                            die($shopier->run($orderid, $tutar, $redirect_link));
    Aşağıdaki kod ise yukarıda Redirect aşamasında belirtmiş olduğunuz $redirect_link içerisinde çalıştıracağınız kodlardır. Burada ilgili ödemenin son kontrollerini yapıp veritabanınızda işlemlerinizi gerçekleştirebilirsiniz.
    if (isset($_POST['platform_order_id'])) {
                $order_id = $_POST['platform_order_id'];
                $status = $_POST['status'];
                $payment_id = $_POST['payment_id'];
                $installment = $_POST['installment'];
                $random_nr = $_POST['random_nr'];
                if ($order_id != '') {
                    $signature = $_POST["signature"];
                    $expected = base64_encode(hash_hmac(SHA256,$random_nr.$order_id,$secret, true));
                    if ($signature == $expected) {
                        // tüm kontrollerin yapılacağı alan
                    }
                }else {
                    Header("Location:".base_url('basarisiz'));
                }
            }else {
                Header("Location:".base_url('/'));
                exit;
            }
    @emrebt5; Umarım siz dahil olmak üzere bu konuda problem yaşayan diğer arkadaşlara da faydalı olacaktır. Söylediğim şekilde ilerleme kaydeder ve kodlardaki gerekli alanları doğru şekilde ekleyip çalıştırırsanız hiç bir sorun yaşamadan Shopier Entegrasyonunu yapmış olacaksınız. Hayırlı günler bol kazançlar dilerim.
    Hocam bu en alttaki kodunuzda ödeme alındı ise çalışacak kodu nereye yazıcaz

    // tüm kontrollerin yapılacağı alan <--- bu kısma mı?
  • 17-06-2025, 06:44:48
    #6
    emretanerc adlı üyeden alıntı: mesajı görüntüle
    Hocam bu en alttaki kodunuzda ödeme alındı ise çalışacak kodu nereye yazıcaz

    // tüm kontrollerin yapılacağı alan <--- bu kısma mı?
    Evet hocam o yorum satırının hemen altından veritabanı güncellemelerini gerçekleştirebilirsin. Sonrasında da success sayfan varsa en son oraya yönlendirmen yeterlidir. Kolay gelsin.
  • 17-06-2025, 09:25:41
    #7
    iyovi adlı üyeden alıntı: mesajı görüntüle
    Evet hocam o yorum satırının hemen altından veritabanı güncellemelerini gerçekleştirebilirsin. Sonrasında da success sayfan varsa en son oraya yönlendirmen yeterlidir. Kolay gelsin.
    Teşekkürler şuan shopier sayfası açılıyor kartı giriyorum ödemeyi yapıyorum bankaya onay düşüyor onaylıyorum ama nedense
    2 banka da bu şekilde kaldı.

    "3d.payten.com.tr ana makinesinin yanıt vermesi çok uzun sürdü"


    telefona gelen onaydan sonra sürekli bu şekilde sayfalarda kalıyor 2-3 kart denedim mail attım cevap bekliyorum
  • 17-06-2025, 09:46:48
    #8
    emretanerc adlı üyeden alıntı: mesajı görüntüle
    Teşekkürler şuan shopier sayfası açılıyor kartı giriyorum ödemeyi yapıyorum bankaya onay düşüyor onaylıyorum ama nedense
    2 banka da bu şekilde kaldı.

    "3d.payten.com.tr ana makinesinin yanıt vermesi çok uzun sürdü"


    telefona gelen onaydan sonra sürekli bu şekilde sayfalarda kalıyor 2-3 kart denedim mail attım cevap bekliyorum
    Bu konu hakkında bilgim yok malesef sanırım API servislerinin kendi aralarında ki yanıtlaşma süreçleri doğru çalışmıyor olabilir. Lakin Shopier Ödeme Entegrasyonu kullandığım tüm projeler burada paylaştığım kaynak kod üzerinden ilerliyor herhangi bir sorun problem yaşamıyorum şuan tüm servislerim aktif şekilde çalışıyor.
  • 17-06-2025, 23:53:21
    #9
    Domaininiz cf de mi ?