PHP code example of nikapps / saman-ussd

1. Go to this page and download the library: Download nikapps/saman-ussd library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nikapps / saman-ussd example snippets



use Nikapps\SamanUssd\SamanUssd;

$samanUssd = new SamanUssd();

// Set api endpoint
$samanUssd->endpoint('http://example.com/webservice.php');

// TODO: Set listener or callbacks

$samanUssd->handle();
~~~

## Listener
You need a listener for incoming soap calls. You have two options:

#### 1. Listener Class:
You can setup your listener by implementing interface `Nikapps\SamanUssd\Contracts\SamanUssdListener`:

~~~php


use Nikapps\SamanUssd\Contracts\SamanUssdListener;

class Listener implements SamanUssdListener{

    /**
     * When `GetProductInfo` is called
     *
     * @param string[] $codes
     * @param string $language
     * 
     * @return \Nikapps\SamanUssd\Responses\ProductInfoResponse;
     */
    public function onProductInfo(array $codes, $language)
    {
        // TODO: response
    }

    /**
     * When `CallSaleProvider` is called
     *
     * @param string[] $codes
     * @param integer $amount
     * @param string $phone Mobile/Call number
     * @param long $sepId Unique number provided by saman724
     * @param string $language
     * 
     * @return \Nikapps\SamanUssd\Responses\CallSaleResponse
     */
    public function onCallSale(array $codes, $amount, $phone, $sepId, $language)
    {
        // TODO: return response
    }

    /**
     * When `ExecSaleProvider` is called
     *
     * @param string $providerId
     * 
     * @return \Nikapps\SamanUssd\Responses\ExecuteSaleResponse
     */
    public function onExecuteSale($providerId)
    {
        // TODO: return response
    }

    /**
     * When `CheckStatus` is called
     *
     * @param string $providerId
     * 
     * @return \Nikapps\SamanUssd\Responses\CheckStatusResponse
     */
    public function onCheckStatus($providerId)
    {
        // TODO: return response
    }