GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Stripe   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 8
dl 0
loc 66
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A run() 0 34 2
A getRedirectParams() 0 9 1
1
<?php
2
namespace Goodoneuz\PayUz\Http\Classes\Stripe;
3
4
use Session;
5
use Stripe as StripeGateway;
6
use Illuminate\Http\Request;
7
use Goodoneuz\PayUz\Models\Transaction;
8
use Goodoneuz\PayUz\Models\PaymentSystem;
9
use Goodoneuz\PayUz\Http\Classes\DataFormat;
10
use Goodoneuz\PayUz\Services\PaymentService;
11
use Goodoneuz\PayUz\Http\Classes\BaseGateway;
12
use Goodoneuz\PayUz\Models\PaymentSystemParam;
13
use Goodoneuz\PayUz\Services\PaymentSystemService;
14
use Goodoneuz\PayUz\Http\Classes\PaymentException;
15
16
class Stripe extends BaseGateway
17
{
18
	public $config;
19
    public $request;
20
    public $response;
21
    public $merchant;
22
    public $payment_system;
23
	const CUSTOM_FORM = 'pay-uz::merchant.stripe';
24
    
25
    /**
26
     * Payme constructor.
27
     */
28
    public function __construct()
29
    {
30
        $this->config   = PaymentSystemService::getPaymentSystemParamsCollect(PaymentSystem::STRIPE);
31
        $this->request  = request();
32
    }
33
    /**
34
     * success response method.
35
     *
36
     * @return \Illuminate\Http\Response
37
     */
38
    public function run(){
39
        StripeGateway\Stripe::setApiKey($this->config['secret_key']);
40
        if (!empty($this->config['proxy'])){
41
            $curl = new StripeGateway\HttpClient\CurlClient([CURLOPT_PROXY => $this->config['proxy']]);
42
            // tell Stripe to use the tweaked client
43
            StripeGateway\ApiRequestor::setHttpClient($curl); 
44
        }
45
46
        $charge = StripeGateway\Charge::create ([
0 ignored issues
show
Unused Code introduced by
$charge is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
47
                "amount" => (int)$this->request->amount,
48
                "currency" => "USD",
49
                "source" => $this->request->stripeToken,
50
                "description" => "Pay for service" 
51
        ]);
52
        $model = PaymentService::convertKeyToModel($this->request->key);
53
		$create_time = DataFormat::timestamp(true);	
54
        $transaction = Transaction::create([
55
            'payment_system'        => PaymentSystem::STRIPE,
56
            'system_transaction_id' => (int)rand()*1000,
57
            'amount'                =>(int)$model->total,
58
            'currency_code'         => Transaction::CURRENCY_CODE_UZS,
59
            'state'                 => Transaction::STATE_COMPLETED,
60
            'updated_time'          => 1*$create_time,
61
            'comment'               => '',
62
            'detail'                => '',
63
            'transactionable_type'  => get_class($model),
64
            'transactionable_id'    => $model->id
65
        ]);
66
        Session::flash('success', 'Payment successful!');
67
        //todo: create transaction for stripe
68
		PaymentService::payListener(null,$transaction,'after-pay');
69
        header("Location: ". $this->request->url);
70
        echo "<script>window.location.href='".$this->request->url."';</script>";
71
    }
72
    public function getRedirectParams($model, $amount, $currency, $url){
73
    	return [
74
    		'config' => $this->config,
75
    		'url' => $url,
76
    		'amount' => $amount,
77
    		'currency' => $currency,
78
    		'key' => PaymentService::convertModelToKey($model),
79
    	];
80
    }
81
}