datalive / stripe
php component to connect applications with stripe
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
Requires
- php: ^7.1.3
- cartalyst/stripe-laravel: 8.0.*
- datalive/serviceinfrastructure: *
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2025-03-05 06:00:39 UTC
README
Description
php component to connect applications with stripe
Installation / Usage
Via Composer
$ composer require datalive/stripe
After installing via composer, run the migration command
$ php artisan migrate
Create Account in Stripe
In the dashboard options
-Developers -API Keys
copy the Secret key
In the laravel environment file should go the following data -STRIPE_KEY (Secret key from stripe) -APP_ENV -APP_NAME
Requirements
- PHP 7.1.3
- Laravel 5.6 or higher
Usage
namespace App\Http\Controllers; use datalive\stripe\Stripe; class UserController extends Controller { public function createCustomer(Request $request) { $wallet = new Stripe; $customer = $wallet->createConstumer($user->id); } }
Methods
##createConstumer
-code
$wallet = new Stripe; $customer = $wallet->createConstumer($user->id);
-
params
- account_id: Local identifier of the account to which you want to link the customer stripe
-
return
- all customer data stored in stripe
##getCostumerId
-code
$wallet = new Stripe; $customer = $wallet->getCostumerId($user->id);
-
params
- account_id: Local identifier of the account.
-
return
- the customer identifier in stripe
##getDataCustomer -code
$wallet = new Stripe; $customer = $wallet->getDataCustomer($user->id);
-
params
- account_id: Local identifier of the account.
-
return
- all customer data stored in stripe
##createCreditCard -code
$wallet = new Stripe; $customer = $wallet->createCreditCard($user->id,$token_card);
-
params
- account_id: Local identifier of the account.
- $token: Token generated by the front end of stripe using the public key.
-
return
- all credit card data stored in stripe
##getCreditCards
-code
$wallet = new Stripe; $customer = $wallet->getCreditCards($user->id,$card_id);
-
params
- account_id: Local identifier of the account.
- $card_id: (optional) identifier of the credit card in stripe, if the value is not sent the function returns a list of the credit cards
-
return
- all credit card data stored in stripe / list credit cards
##deleteCreditCard -code
$wallet = new Stripe; $customer = $wallet->deleteCreditCard($user->id,$card_id);
-
params
- account_id: Local identifier of the account.
- $card_id: identifier of the credit card in stripe
-
return
- Boolean response of the operation
##updateCreditCard
-code
$wallet = new Stripe; $customer = $wallet->updateCreditCard($user->id,$card_id,[ 'name' => 'John Doe', 'address_line1' => 'Example Street 1', ]);
-
params
- account_id: Local identifier of the account.
- $card_id: identifier of the credit card in stripe
- $data: Array with a single data that can be modified from a credit card
$data = [ 'name' => 'John Doe', 'address_line1' => 'Example Street 1', 'address_line2' => 'Example Street 2', 'address_state' => 'Texas', 'address_zip' => '55555', 'exp_month' => '03', 'exp_year' => '2025', ]
-
return
- all credit card data stored in stripe
##generateTokenCreditCard
Note: this method should only be used for testing purposes since its use in production may result in misuse of data that is sensitive and vulnerable to scams or fraud
-code
$wallet = new Stripe; $customer = $wallet->generateTokenCreditCard($user->id,[ 'number' => '4242424242424242', 'exp_month' => 10, 'cvc' => 314, 'exp_year' => 2020, ]);
-
params
- account_id: Local identifier of the account.
- $data: array with credit card data
Note: if the fix is not sent within the function a test token with test data is created
$data =[ 'number' => '4242424242424242', 'exp_month' => 10, 'cvc' => 314, 'exp_year' => 2020, ]
-
return
- token credit card
##loadCharge
-code
$wallet = new Stripe; $customer = $wallet->loadCharge($account_id,$amount,$description,$metadata,$currency)
-
params
- account_id: Local identifier of the account.
- $amount: amount of the charge
- $description: description of the charge
- $metadata: array with additional caharge data
- $currency: (Default value if not sent is USD)
-
return
- all charge data stored in stripe