suseche / walletstripe
php component to connect applications with stripe
Installs: 27
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 1
Open Issues: 0
Type:package
Requires
- php: ^7.1.3
- cartalyst/stripe-laravel: 8.0.*
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2025-03-11 04:30:16 UTC
README
Description
php component to connect applications with stripe
Installation / Usage
1. Use Composer
$ composer require suseche/walletstripe
2. Run the migration command
$ php artisan migrate
3. Create Account in Stripe
In the dashboard options go to:
- Developers
- API Keys
Copy the Secret key provided by stripe and in the laravel environment file add the following:
-STRIPE_KEY (Secret key from stripe)
-APP_ENV
-APP_NAME
Requirements
- PHP 7.1.3
- Laravel 5.6
Usage
namespace App\Http\Controllers; use suseche\walletstripe\WalletStripe; class UserController extends Controller { public function createCustomer(Request $request) { $wallet = new WalletStripe; $customer = $wallet->createConstumer($user->id); } }
Methods
- createConstumer
$wallet = new WalletStripe; $customer = $wallet->createConstumer($user->id);
-
params
account_id: Account's local identifier which you want to link the customer stripe to.
-
return
All customer data stored in Stripe
- getCostumerId
$wallet = new WalletStripe; $customer = $wallet->getCostumerId($user->id);
-
params
- account_id: Local identifier of the account.
-
return
- The customer identifier in stripe
- getDataCustomer
$wallet = new WalletStripe; $customer = $wallet->getDataCustomer($user->id);
-
params
- account_id: Local identifier of the account.
-
return
- All customer data stored in stripe
- createCreditCard
$wallet = new WalletStripe; $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
$wallet = new WalletStripe; $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
$wallet = new WalletStripe; $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
$wallet = new WalletStripe; $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
$wallet = new WalletStripe; $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 array 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
$wallet = new WalletStripe; $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: A string representing the currency in ISO format (Default value if not sent is USD)
-
return
- all charge data stored in stripe