Issues (258)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

Containers/Stripe/Tasks/ChargeWithStripeTask.php (1 issue)

Check for loose comparison of boolean to boolean

Best Practice Coding Style Informational

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace App\Containers\Stripe\Tasks;
4
5
use App\Containers\Payment\Contracts\ChargeableInterface;
6
use App\Containers\Payment\Contracts\PaymentChargerInterface;
7
use App\Containers\Payment\Models\AbstractPaymentAccount;
8
use App\Containers\Payment\Models\PaymentTransaction;
9
use App\Containers\Stripe\Exceptions\StripeAccountNotFoundException;
10
use App\Containers\Stripe\Exceptions\StripeApiErrorException;
11
use App\Ship\Parents\Tasks\Task;
12
use Cartalyst\Stripe\Stripe;
13
use Exception;
14
use Illuminate\Support\Facades\Config;
15
16
/**
17
 * Class ChargeWithStripeTask.
18
 *
19
 * @author Mahmoud Zalt <[email protected]>
20
 */
21
class ChargeWithStripeTask extends Task implements PaymentChargerInterface
22
{
23
24
    private $stripe;
25
26
    /**
27
     * ChargeWithStripeTask constructor.
28
     *
29
     * @param \Cartalyst\Stripe\Stripe $stripe
30
     */
31
    public function __construct(Stripe $stripe)
32
    {
33
        $this->stripe = $stripe->make(Config::get('settings.stripe.secret'), Config::get('settings.stripe.version'));
34
    }
35
36
    /**
37
     * @param \App\Containers\Payment\Contracts\ChargeableInterface $user
38
     * @param \App\Containers\Payment\Models\AbstractPaymentAccount $account
39
     * @param float                                                 $amount
40
     * @param string                                                $currency
41
     *
42
     * @return PaymentTransaction
43
     * @throws StripeAccountNotFoundException
44
     * @throws StripeApiErrorException
45
     */
46
    public function charge(ChargeableInterface $user, AbstractPaymentAccount $account, $amount, $currency = 'USD') : PaymentTransaction
47
    {
48
        // NOTE: you should not call this function directly. Instead use the Payment Gateway in the Payment container.
49
        // Or even better to use the charge function in the ChargeableTrait.
50
51
        $valid = $account->checkIfPaymentDataIsSet(['customer_id', 'card_id', 'card_funding', 'card_last_digits', 'card_fingerprint']);
52
53
        if ($valid == false) {
0 ignored issues
show
Coding Style Best Practice introduced by Johannes Schobel
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
54
            throw new StripeAccountNotFoundException('We could not find your credit card information. 
55
            For security reasons, we do not store your credit card information on our server. 
56
            So please login to our Web App and enter your credit card information directly into Stripe, 
57
            then try to purchase the credits again. 
58
            Thanks.');
59
        }
60
61
        try {
62
            $response = $this->stripe->charges()->create([
63
                'customer' => $account->customer_id,
64
                'currency' => $currency,
65
                'amount'   => $amount,
66
            ]);
67
68
        } catch (Exception $e) {
69
            throw (new StripeApiErrorException('Stripe API error (chargeCustomer)'))->debug($e->getMessage(), true);
70
        }
71
72
        if ($response['status'] != 'succeeded') {
73
            throw new StripeApiErrorException('Stripe response status not succeeded (chargeCustomer)');
74
        }
75
76
        if ($response['paid'] !== true) {
77
            throw new StripeApiErrorException('Payment was not set to PAID.');
78
        }
79
80
        // this data will be stored on the pivot table (user credits)
81
        $transaction = new PaymentTransaction([
82
            'transaction_id' => $response['id'],
83
            'status' => $response['status'],
84
            'is_successful' => true,
85
            'data' => $response,
86
        ]);
87
88
        return $transaction;
89
    }
90
91
}
92