PHP code example of shahzadthathal / skipcash

1. Go to this page and download the library: Download shahzadthathal/skipcash 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/ */

    

shahzadthathal / skipcash example snippets


use Shahzadthathal\Skipcash\Traits\SkipCashPaymentGatewayTrait;
use Shahzadthathal\Skipcash\Models\SkipcashLogs;

class YourPaymentController extends Controller{

    use SkipCashPaymentGatewayTrait;

    //Generate payment link
    //http://127.0.0.1:8000/payment/generate-payment-link
    $this->generatePaymentLinkSkipcash(Request $request){
            //Your custom transaciton id or order id
            $transactionId = 'xyz12345';
            //Sequance of the fields is important, don't move keys
            $requestData = [
                "Uid" =>\Str::uuid()->toString(),
                "KeyId"=>   env('SKIPCASH_KEY_ID'),
                "Amount" => "40.00",
                'FirstName' => 'Muhammad',
                'LastName' => 'Shahzad',
                'Phone' => '+971507520175',
                'Email' => '[email protected]',
                "TransactionId" => $transactionId,
                "Custom1" => 'Custom1 anything',
                // Add other .$currentUrlWithParams;
            $skipcashLogs->save();

            //Verify payment
            $responseSkipcash = $this->validatePaymentSkipcash($payment_id);
            $responseSkipcashArr = json_decode($responseSkipcash, true);
            $resultObj = $responseSkipcashArr['resultObj'];
            //Payment success
            if(isset($resultObj['statusId']) && $resultObj['statusId']===2){
                //Your custom transaciton id or order id from the payment gateway
                $transactionId = $resultObj['transactionId'];
                dd('transactionId '.$transactionId.' is verifid payment please update your order.');
            }
    }

    //Webhook
   //http://127.0.0.1:8000/payment/gateway/response/skipcash/webhook
   //Please update above url in SkipCash payment portal in Webhook URL input box.
    public function paymentGatewayResponseSkipcashWebhook(Request $request){
        try{
            $data = $request->all();
            $skipcashLogs = new SkipcashLogs();
            $skipcashLogs->user_id = 0;
            $skipcashLogs->logs = 'webhook '.$data;
            $skipcashLogs->save();
            return response()->json(['message' => 'Success'], 200);
        }catch(\Exception $e){
            throw $e;
        }   

    }

}