Sklep SMS - Forum
 
InfoKup LicencjęDownloadKonfiguracjaPoradnikiForumKontakt

Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
PROBLEM Z API HOSTPLAY
#11
Proszę nowe api :Smile

Kod:
<?php



$heart->register_payment_module("hostplay", "PaymentModuleHostplay");



class PaymentModuleHostplay2 extends PaymentModule implements IPayment_Sms

{



    const SERVICE_ID = "hostplay";



    /** @var  string */

    protected $userId;



    /** @var  string */

    protected $sms_code;



    function __construct()

    {

        parent::__construct();



        $this->sms_code = $this->data['sms_text'];

        $this->userId = $this->data['user_id'];

        

        $this->rates_number = array(

            '0.34'  => '7055',

            '0.67'  => '7155',

            '1.35'  => '7255',

            '2.02'  => '7355',

            '2.7'  => '7455',

            '3.38'  => '7555',

            '4.05'  => '76660',

            '6.08'  => '7955',

            '6.76'  => '91055',

            '7.43'  => '91155',

            '9.47'  => '91455',

            '12.85' => '91955',

            '13.53' => '92055',

            '16.91' => '92555'

        );        

    }



    public function verify_sms($return_code, $number)

    {

        $response = curl_get_contents(

            'http://hostplay.pl/api/payment/api_code_verify.php' .

            '?payment=homepay_sms' .

            '&userid=' . urlencode($this->userId) .

            '&comment=SklepSMS' .

            '&code=' . urlencode($return_code)

        );



        file_put_contents('test.log', $response);



        $response = json_decode($response, true);

        $response_number = $this->rates_number[number_format(floatval($response['kwota']), 2)];

        

        if (strtoupper($response['status']) == 'OK') {

            if ($response_number == $number) {

                return IPayment_Sms::OK;

            }



            return array(

                'status' => IPayment_Sms::BAD_NUMBER,

                'tariff' => $this->getTariffByNumber($response_number)->getId()

            );

        }



        if (strtoupper($response['status']) == 'FAIL') {

            if(strtoupper($response['error']) == "BAD_CODE") {

                return IPayment_Sms::BAD_CODE;

            }

            

            if(strtoupper($response['error']) == "BAD_CODE[1]") {

                return IPayment_Sms::BAD_CODE;

            }        

            

            if(strtoupper($response['error']) == "BAD_AMOUNT") {

                return IPayment_Sms::BAD_NUMBER;

            }

            

            if(strtoupper($response['error']) == "BAD_AMOUNT2") {

                return IPayment_Sms::BAD_NUMBER;

            }

        }

        

        return IPayment_Sms::SERVER_ERROR;

    }



    public function getSmsCode()

    {

        return $this->sms_code;

    }



}
Odpowiedz
#12
(09-05-2017, 18:45 PM)Mesharsky napisał(a): Proszę nowe api :Smile

Kod:
<?php



$heart->register_payment_module("hostplay", "PaymentModuleHostplay");



class PaymentModuleHostplay2 extends PaymentModule implements IPayment_Sms

{



    const SERVICE_ID = "hostplay";



    /** @var  string */

    protected $userId;



    /** @var  string */

    protected $sms_code;



    function __construct()

    {

        parent::__construct();



        $this->sms_code = $this->data['sms_text'];

        $this->userId = $this->data['user_id'];

        

        $this->rates_number = array(

            '0.34'  => '7055',

            '0.67'  => '7155',

            '1.35'  => '7255',

            '2.02'  => '7355',

            '2.7'  => '7455',

            '3.38'  => '7555',

            '4.05'  => '76660',

            '6.08'  => '7955',

            '6.76'  => '91055',

            '7.43'  => '91155',

            '9.47'  => '91455',

            '12.85' => '91955',

            '13.53' => '92055',

            '16.91' => '92555'

        );        

    }



    public function verify_sms($return_code, $number)

    {

        $response = curl_get_contents(

            'http://hostplay.pl/api/payment/api_code_verify.php' .

            '?payment=homepay_sms' .

            '&userid=' . urlencode($this->userId) .

            '&comment=SklepSMS' .

            '&code=' . urlencode($return_code)

        );



        file_put_contents('test.log', $response);



        $response = json_decode($response, true);

        $response_number = $this->rates_number[number_format(floatval($response['kwota']), 2)];

        

        if (strtoupper($response['status']) == 'OK') {

            if ($response_number == $number) {

                return IPayment_Sms::OK;

            }



            return array(

                'status' => IPayment_Sms::BAD_NUMBER,

                'tariff' => $this->getTariffByNumber($response_number)->getId()

            );

        }



        if (strtoupper($response['status']) == 'FAIL') {

            if(strtoupper($response['error']) == "BAD_CODE") {

                return IPayment_Sms::BAD_CODE;

            }

            

            if(strtoupper($response['error']) == "BAD_CODE[1]") {

                return IPayment_Sms::BAD_CODE;

            }        

            

            if(strtoupper($response['error']) == "BAD_AMOUNT") {

                return IPayment_Sms::BAD_NUMBER;

            }

            

            if(strtoupper($response['error']) == "BAD_AMOUNT2") {

                return IPayment_Sms::BAD_NUMBER;

            }

        }

        

        return IPayment_Sms::SERVER_ERROR;

    }



    public function getSmsCode()

    {

        return $this->sms_code;

    }



}

Jak sobie z tym poradziłeś, jestem pewien że poświęciłeś na to sporo czasu...
Odpowiedz
#13
"Jak sobie z tym poradziłeś, jestem pewien że poświęciłeś na to sporo czasu..."

Wiem że to ty zrobiłeś nikt tego nie ukrywa Smile
Po prostu udostępniam by inni tez mogli z tego korzystać
Odpowiedz


Podobne wątki
Wątek: Autor Odpowiedzi: Wyświetleń: Ostatni post
  Problem Avabuy 4 1,295 16-07-2017, 21:45 PM
Ostatni post: katarzyn90
  Problem SKLEPSMS. Tysiek 10 1,536 03-04-2017, 13:02 PM
Ostatni post: Didi77
  Problem z dodaniem klucza API do wszystkich płatności. efka 3 693 06-03-2017, 11:57 AM
Ostatni post: eztruk



Użytkownicy przeglądający ten wątek: 1 gości