App\Ninja\PaymentDrivers\StripePaymentDriver::createToken PHP Method

createToken() public method

public createToken ( )
    public function createToken()
    {
        $invoice = $this->invitation->invoice;
        $client = $invoice->client;
        $data = $this->paymentDetails();
        $data['description'] = $client->getDisplayName();
        if (!empty($data['plaidPublicToken'])) {
            $plaidResult = $this->getPlaidToken($data['plaidPublicToken'], $data['plaidAccountId']);
            unset($data['plaidPublicToken']);
            unset($data['plaidAccountId']);
            $data['token'] = $plaidResult['stripe_bank_account_token'];
        }
        // if a customer already exists link the token to it
        if ($customer = $this->customer()) {
            $data['customerReference'] = $customer->token;
        }
        $tokenResponse = $this->gateway()->createCard($data)->send();
        if ($tokenResponse->isSuccessful()) {
            $this->tokenResponse = $tokenResponse->getData();
            return parent::createToken();
        } else {
            throw new Exception($tokenResponse->getMessage());
        }
    }