suseche/walletstripe

php component to connect applications with stripe

dev-master 2018-10-10 13:41 UTC

This package is auto-updated.

Last update: 2024-04-11 02:29:36 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

https://stripe.com//

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);
  1. params

    account_id: Account's local identifier which you want to link the customer stripe to.

  2. return

    All customer data stored in Stripe

  • getCostumerId
$wallet = new WalletStripe;
$customer = $wallet->getCostumerId($user->id);
  1. params

    • account_id: Local identifier of the account.
  2. return

    • The customer identifier in stripe
  • getDataCustomer
$wallet = new WalletStripe;
$customer = $wallet->getDataCustomer($user->id);
  1. params

    • account_id: Local identifier of the account.
  2. return

    • All customer data stored in stripe
  • createCreditCard
$wallet = new WalletStripe;
$customer = $wallet->createCreditCard($user->id,$token_card);
  1. params

    • account_id: Local identifier of the account.
    • $token: Token generated by the front end of stripe using the public key.
  2. return

    • All credit card data stored in stripe
  • getCreditCards
$wallet = new WalletStripe;
$customer = $wallet->getCreditCards($user->id,$card_id);
  1. 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
  2. return

    • all credit card data stored in stripe / list credit cards
  • deleteCreditCard
$wallet = new WalletStripe;
$customer = $wallet->deleteCreditCard($user->id,$card_id);
  1. params

    • account_id: Local identifier of the account.
    • $card_id: identifier of the credit card in stripe
  2. 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',
    ]);
  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',
    ]
  1. 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,
    ]);
  1. 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,
    ]
  1. return

    • token credit card
  • loadCharge
$wallet = new WalletStripe;
$customer = $wallet->loadCharge($account_id,$amount,$description,$metadata,$currency)
  1. 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)
  2. return

    • all charge data stored in stripe