PHP code example of mootaco / moota-php-sdk

1. Go to this page and download the library: Download mootaco/moota-php-sdk 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/ */

    

mootaco / moota-php-sdk example snippets




// my code goes here

// Set your API V2 Server Key 
\Moota\Moota\Config\Moota::$ACCESS_TOKEN = '<your server key>';


$auth = new \Moota\Moota\Domain\Auth();
try {
    $getSecretToken = $auth->login(
       new \Moota\Moota\DTO\Auth\LoginData(
                '[email protected]',
                'password_hash',
                new \Moota\Moota\DTO\Auth\ScopesData(  true )
            )
    );
    // set to \Moota\Moota\Config::$ACCESS_TOKEN = $getSecretToken['access_token'];
} catch (\Moota\Moota\Exception\MootaException $exception) {
    // handling fail authentication
}


$getSecretToken = new \Moota\Moota\Domain\Auth();
$getSecretToken->logout();

$bank_account = new \Moota\Moota\Domain\BankAccount();

// store bank account
try {
    $bank_account->storeBankAccount(
        new \Moota\Moota\DTO\BankAccount\BankAccountStoreData(
            "",
            Moota::BANK_TYPES[0], // list of bank type
            "loream",  //for gojek and ovo fill with mobile phone number
            "your password",
            "loream kasma",
            "16899030",
            true
        )
    );
 } catch (\Moota\Moota\Exception\MootaException $exception) {
    print_r($exception->getPharseErrors());
 }

// update bank account
try {
    $bank_account->updateBankAccount(
        new \Moota\Moota\DTO\BankAccount\BankAccountUpdateData(
           "hashing_qwopejs_id",
            "jhon",  //for gojek and ovo fill with mobile phone number
            "",
            "",
            "",
            "",
            ""
            )
    );
 } catch (\Moota\Moota\Exception\MootaException $exception) {
    print_r($exception->getPharseErrors());
 }

// get list bank account
try {
    $bank_account->getBankList();
 } catch (\Moota\Moota\Exception\MootaException $exception) {
    print_r($exception->getPharseErrors());
 }

// can't wait for new mutation data use method refresh mutation 
try {
    $bank_account->refreshMutation('<bank_id>');
 } catch (\Moota\Moota\Exception\MootaException $exception) {
    print_r($exception->getPharseErrors());
 }

// want to remove bank account from moota ?
try {
    $bank_account->destroyBankAccount('<bank_id>');
 } catch (\Moota\Moota\Exception\MootaException $exception) {
    print_r($exception->getPharseErrors());
 }

// want to activate my wallet account ovo or gojek please request otp code first
try {
    $otp_code = $bank_account->bankEwalletRequestOTPCode('<bank_id>');
    
    $bank_account->bankEwalletVerificationOTPCode(
        new \Moota\Moota\DTO\BankAccount\BankAccountEwalletOtpVerification('<bank_id>', '<$otp_code>')
    );
 } catch (\Moota\Moota\Exception\MootaException $exception) {
    print_r($exception->getPharseErrors());
 }

$mutation = new \Moota\Moota\Domain\Mutation();

// get my mutation
$my_mutation = $mutation->getMutations(
    new \Moota\Moota\DTO\Mutation\MutationQueryParameterData(
            'asdasd',
            '2021-09-21',
            'Testing Note Mutation',
            '2000123',
            'CR'
        )
);

// Determine dummy mutation for debugging
$my_mutation = $mutation->storeMutation(
    new \Moota\Moota\DTO\Mutation\MutationStoreData(
        // fill mutation value here
    )
);

// Add note mutation
$my_mutation = $mutation->addNoteMutation(
    new \Moota\Moota\DTO\Mutation\MutationNoteData(
            'hash_mutation_id',
            'Testing Note Mutation',
        )
);

// Debugging | try getting mutation webhook from moota
$my_mutation = $mutation->pushWebhookByMutation('<mutation_id>');

/**
* need to remove mutation data ? 
* method destroy mutation can multiple remove mutation
*/
$my_mutation = $mutation->destroyMutation(
    new \Moota\Moota\DTO\Mutation\MutationDestroyData(
           ["hash_mutation_id", "hash_mutation_id"]
        )
);

// method attach tagging to mutation 

$my_mutation = $mutation->attachTagMutation(
    new \Moota\Moota\DTO\Mutation\MutationAttachTaggingData(
            '8aolk43WJxM',
            [
                "assurance", "..."
            ]
        )
);

// method detach tagging from mutation 

$my_mutation = $mutation->detachTagMutation(
    new \Moota\Moota\DTO\Mutation\MutationDetachTaggingData([
            '8aolk43WJxM',
            [
                "assurance", "..."
            ]
        )
);

// method update tagging from mutation 

$my_mutation = $mutation->updateTagMutation(
    new \Moota\Moota\DTO\Mutation\MutationUpdateTaggingData([
            '8aolk43WJxM',
            [
                "assurance", "..."
            ]
        )
);

$tagging = new \Moota\Moota\Domain\Tagging(); 

$my_tagging = $tagging->getTaggings(
    new \Moota\Moota\DTO\Tagging\TaggingQueryParameterData(
            ['assurance', 'cash'] // or leave blank doesn`t have filter
        )
); 

// create first tagging like it
$my_tagging = $tagging->storeTagging(
    new \Moota\Moota\DTO\Tagging\TaggingStoreData(
            'assurance'
        )
); 

// update tagging like it
$my_tagging = $tagging->updateTagging(
    new \Moota\Moota\DTO\Tagging\TaggingUpdateData(
           'VLagzqBj42Ds',
            'assurance-car'
        )
); 

// update tagging like it
$my_tagging = $tagging->destroyTagging('<tag_id>'); 

$topup = new \Moota\Moota\Domain\Topup(); 

// Get list payment method | targeting bank account topup point
$payment_method = $topup->getPaymentMethod();

// Get List Amounts Point | minimum and maximum point can topup
$amounts = $topup->getListAmountPoint();

// get my topup 
$my_topup = $topup->getListTopupPoint();

// create topup point
$my_topup = $topup->createTopupPoint(
    new \Moota\Moota\DTO\Topup\CreateTopupData(
            100000,
            'bca'
        )
);

// have a voucher code ?
$my_topup = $topup->redeemVoucher(
    new \Moota\Moota\DTO\Topup\VoucherRedeemData(
          'abcd'
        )
);

$transaction = new \Moota\Moota\Domain\Transaction();  

$history = $transaction->getHistoryTransactionPoint(
    new \Moota\Moota\DTO\Transaction\TransactionHistoryData(
             1,
             '',
            ''
        )
);

$user = new \Moota\Moota\Domain\User();  

$my_profile = $transaction->getProfile();

$my_profile = $transaction->updateProfile(
    new \Moota\Moota\DTO\User\UserUpdateData(
            'moota',
            '[email protected]',
            '12312312123123',
            'Jl. street no 1'
        )
);

$webhook = new \Moota\Moota\Domain\Webhook();  


$response = $webhook->getListWebhooks(
    new \Moota\Moota\DTO\Webhook\WebhookQueryParameterData(
        '',
        '',
         1,
        20
    )
);

try {
    $response = $webhook->storeWebhook(
        new \Moota\Moota\DTO\Webhook\WebhookStoreData(
                'https://app.moota.co/endpoint/webhook',
               'akjsdkj3',
                1,
               999,
                'credit',
                '', // leave blank webhook can set for all banks account
            )
    );
 } catch (\Moota\Moota\Exception\MootaException $exception) {
    print_r($exception->getPharseErrors());
 }

$response = $webhook->removeWebhook('<webhook_id>');

$response = $webhook->getWebhookHistory('<webhook_id>');

$webhook = new \Moota\Moota\Domain\Webhook('<secret_token>');  

try {
    $response_payload_json = file_get_contents("php://input");
    $get_signature_from_header = getallheaders()['Signature'];
    
    $webhooks = $webhook->getResponse($get_signature_from_header, $response_payload_json);
    
    foreach ($webhooks as $webhook) {
        // code store to database 
    }
} catch (\Moota\Moota\Exception\Webhook\WebhookValidateException $exception) {
    // code handling when incoming webhook fail validation signature 
    print_r($exception->getMessage()) 
}


composer 
json
{
  "ta-co/moota-php-sdk": "1.*"
  }
}