Cartalyst LLC.
Stripe by Cartalyst
0
140
58
48
207

Preface

Introduction

A comprehensive API package for Stripe.

The package requires PHP 5.5.9+ and follows the FIG standard PSR-1, PSR-2 and PSR-4 to ensure a high level of interoperability between shared PHP code and is fully unit-tested.

Have a read through the Installation Guide.

Features

  • Charges
    • Can create a charge.
    • Can retrieve a charge.
    • Can update a charge.
    • Can capture a charge.
    • Can retrieve all charges.
  • Refunds
    • Can create a refund.
    • Can retrieve a refund.
    • Can update a refund.
    • Can retrieve all refunds.
  • Customers
    • Can create a customer.
    • Can retrieve a customer.
    • Can update a customer.
    • Can delete a customer.
    • Can apply a discount to a customer.
    • Can retrieve all customers.
  • Cards
    • Can create a card.
    • Can retrieve a card.
    • Can update a card.
    • Can delete a card.
    • Can retrieve all cards.
  • Subscriptions
    • Can create a subscription.
    • Can retrieve a subscription.
    • Can update a subscription.
    • Can cancel a subscription.
    • Can reactivate a canceled subscription.
    • Can apply a discount to a subscription.
    • Can retrieve all active subscriptions.
  • Plans
    • Can create a plan.
    • Can retrieve a plan.
    • Can update a plan.
    • Can delete a plan.
    • Can retrieve all plans.
  • Coupons
    • Can create a coupon.
    • Can retrieve a coupon.
    • Can update a coupon.
    • Can delete a coupon.
    • Can retrieve all coupons.
  • Invoices
    • Can create an invoice.
    • Can retrieve an invoice.
    • Can retrieve an invoice line items.
    • Can retireve the upcoming invoice.
    • Can update an invoice.
    • Can pay an invoice.
    • Can retrieve all invoices.
  • Invoice Items
    • Can create an invoice item.
    • Can retrieve an invoice item.
    • Can update an invoice item.
    • Can delete an invoice item.
    • Can retrieve all invoice items.
  • Disputes
    • Can update a dispute.
    • Can close a dispute.
  • Transfers
    • Can create a transfer.
    • Can retrieve a transfer.
    • Can update a transfer.
    • Can cancel a transfer.
    • Can retrieve all transfers.
  • Recipients
    • Can create a recipient.
    • Can retrieve a recipient.
    • Can update a recipient.
    • Can delete a recipient.
    • Can retrieve all recipients.
  • Application Fees
    • Can retrieve an application fee.
    • Can retrieve all application fees
  • Application Fee Refunds
    • Can create an application fee refund.
    • Can retrieve an application fee refund.
    • Can update an application fee refund.
    • Can retrieve all application fee refunds.
  • Account
    • Can retrieve account details.
  • Balance
    • Can retrieve balance.
    • Can retrieve the a balance transaction.
    • Can retrieve all balance history.
  • Events
    • Can retrieve an event.
    • Can retrieve all events.
  • Tokens
    • Can create a card token.
    • Can create a bank account token.
    • Can retrieve a token.
  • File Uploads
    • Can create a file upload.
    • Can retrieve a file upload.
    • Can retrieve all file uploads.

Examples

Retrieve all customers
$stripe = Stripe::make('your-stripe-api-key');

$customers = $stripe->customers()->all();

foreach ($customers['data'] as $customer) {
    var_dump($customer['email']);
}
Retrieve a customer
$stripe = Stripe::make('your-stripe-api-key');

$customer = $stripe->customers()->find('cus_4EBumIjyaKooft');

echo $customer['email'];

Setup

Installation

Cartalyst packages utilize Composer, for more information on how to install Composer please read the Composer Documentation.

Preparation

Open your composer.json file and add the following to the require array:

"cartalyst/stripe": "~2.0"

Note: Make sure that after the required changes your composer.json file is valid by running composer validate.

Install the dependencies

Run Composer to install or update the new requirement.

php composer install

or

php composer update

Now you are able to require the vendor/autoload.php file to autoload the package.

Instantiation

Creating a new Stripe instance is very easy and straightforward. Please check the examples below for further explanation.

use Cartalyst\Stripe\Stripe;

$stripe = new Stripe('your-stripe-api-key', 'your-stripe-api-version');
use Cartalyst\Stripe\Stripe;

$stripe = Stripe::make('your-stripe-api-key', 'your-stripe-api-version');

You can use environment variables instead of passing them as arguments, like so:

putenv('STRIPE_API_KEY=your-stripe-api-key');

putenv('STRIPE_API_VERSION=your-stripe-api-version');

Then upon instantiation, Stripe will auto detect these and use accordingly.

use Cartalyst\Stripe\Stripe;

$stripe = new Stripe();
$stripe = Stripe::make();

Note: Please do note that the Stripe API KEY is always required to be defined, either through an environment variable or by passing it as the first argument.

Integrations

Cartalyst packages are framework agnostic and as such can be integrated easily natively or with your favorite framework.

Laravel

Please refer to the links below for instructions on how to integrate the package in your Laravel application

Usage

Charges

To charge a credit or a debit card, you create a new charge object. You can retrieve and refund individual charges as well as list all charges. Charges are identified by a unique ID.

Create a charge

To charge a credit card, you need to create a new charge object. If your API key is in test mode, the supplied card won't actually be charged, though everything else will occur as if in live mode. (Stripe will assume that the charge would have completed successfully).

Arguments
Key Required Type Default Description
$parameters true array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
amount true number null A positive amount representing how much to charge the card. Note that this should be a dollar amount, and will automatically be converted in to cents for you before being transmitted to Stripe.
currency true string null Three-letter ISO currency code, in lowercase.
application_fee_amount false integer null A fee in cents that will be applied to the charge and transferred to the application owner’s Stripe account.
capture false bool null Whether to immediately capture the charge.
customer false string null The customer unique identifier.
description false string null An arbitrary string which you can attach to a Charge object.
metadata false array [] A set of key/value pairs that you can attach to a charge object.
on_behalf_of false string null The Stripe account ID for which these funds are intended.
receipt_email false string null The email address to which this charge’s receipt will be sent.
shipping false array [] Shipping information for the charge. Helps prevent fraud on charges for physical goods.
source false string | array null The source can either be a token or a dictionary containing the source details.
statement_descriptor false string null An arbitrary string to be displayed alongside your company name on your customer's credit card statement.
statement_descriptor_suffix false string null Provides information about the charge that customers see on their statements.
transfer_data false array [] An arbitrary string to be used as the dynamic portion of the full descriptor displayed on your customer’s credit card statement.
transfer_group false string null A string that identifies this transaction as part of a group.
Usage
$charge = $stripe->charges()->create([
    'customer' => 'cus_4EBumIjyaKooft',
    'currency' => 'USD',
    'amount'   => 50.49,
]);

echo $charge['id'];

Retrieve a charge

Retrieves the details of a charge that has been previously created. Supply the unique charge ID that was returned from a previous request, and Stripe will return the corresponding charge information. The same information is returned when creating or refunding the charge.

Arguments
Key Required Type Default Description
$chargeId true string null The charge unique identifier.
Usage
$charge = $stripe->charges()->find('ch_4ECWMVQp5SJKEx');

Update a charge

Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

Arguments
Key Required Type Default Description
$chargeId true string null The charge unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
customer false string null The ID of an existing customer that will be associated with this request.
description false string null An arbitrary string which you can attach to a charge object.
fraud_details false array [] A set of key/value pairs that you can attach to a charge object giving information about its riskiness.
metadata false array [] A set of key/value pairs that you can attach to a charge object.
receipt_email false string null This is the email address that the receipt for this charge will be sent to.
shipping false array [] Shipping information for the charge. Helps prevent fraud on charges for physical goods.
transfer_group false string null A string that identifies this transaction as part of a group.
Usage
$charge = $stripe->charges()->update('ch_4ECWMVQp5SJKEx', [
    'description' => 'Payment to foo bar',
]);

Capture a charge

Capture the payment of an existing, uncaptured, charge. This is the second half of the two-step payment flow, where first you created a charge with the capture option set to false.

Uncaptured payments expire exactly seven days after they are created. If they are not captured by that point in time, they will be marked as refunded and will no longer be capturable.

Arguments
Key Required Type Default Description
$chargeId true string null The charge unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
amount false number null A positive amount for the transaction.
application_fee_amount false string null An application fee amount to add on to this charge, which must be less than or equal to the original amount. Can only be used with Stripe Connect.
receipt_email false string null The email address to send this charge’s receipt to.
statement_descriptor false string null An arbitrary string to be displayed alongside your company name on your customer's credit card statement.
statement_descriptor_suffix false string null Provides information about the charge that customers see on their statements.
transfer_data false array [] An optional dictionary including the account to automatically transfer to as part of a destination charge
transfer_group false string null A string that identifies this transaction as part of a group.
Usage
$charge = $stripe->charges()->capture('ch_4ECWMVQp5SJKEx');

Retrieve all charges

Returns a list of charges you've previously created. The charges are returned in sorted order, with the most recent charges appearing first.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
created false string null A filter on the list based on the object created field.
customer false string null The customer unique identifier.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
payment_intent false string null Only return charges that were created by the PaymentIntent specified by this PaymentIntent ID.
starting_after false string null A cursor to be used in pagination.
transfer_group false string null Only return charges for this transfer group.
Usage
$charges = $stripe->charges()->all();

foreach ($charges['data'] as $charge) {
    var_dump($charge['id']);
}

Refunds

Refund objects allow you to refund a charge that has previously been created but not yet refunded. Funds will be refunded to the credit or debit card that was originally charged. The fees you were originally charged are also refunded.

Create a refund

Creating a new refund will refund a charge that has previously been created but not yet refunded. Funds will be refunded to the credit or debit card that was originally charged. The fees you were originally charged are also refunded.

Arguments
Key Required Type Default Description
$chargeId true string null The charge unique identifier.
$amount true number null A positive amount representing how much of this charge to refund.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
amount false number null A positive integer in cents representing how much of this charge to refund.
metadata false array [] A set of key/value pairs that you can attach to a refund object.
reason false string null String indicating the reason for the refund. If set, possible values are `duplicate`, `fraudulent`, and `requested_by_customer`. Connect only.
refund_application_fee false boolean false Boolean indicating whether the application fee should be refunded when refunding this refund.
reverse_transfer false boolean false Boolean indicating whether the transfer should be reversed when refunding this charge.
Usage
$refund = $stripe->refunds()->create('ch_4ECWMVQp5SJKEx');

Retrieve a refund

By default, you can see the 10 most recent refunds stored on a charge directly on the charge object, but you can also retrieve details about a specific refund stored on the charge.

Arguments
Key Required Type Default Description
$chargeId true string null The charge unique identifier.
$refundId true string null The refund unique identifier.
Usage
$refund = $stripe->refunds()->find('ch_4ECWMVQp5SJKEx', 'txn_4IgdBGArAOeiQw');

Update a refund

Updates the specified refund by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

Arguments
Key Required Type Default Description
$chargeId true string null The charge unique identifier.
$refundId true string null The refund unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
metadata false array [] A set of key/value pairs that you can attach to a refund object.
Usage
$refund = $stripe->refunds()->update('ch_4ECWMVQp5SJKEx', 'txn_4IgdBGArAOeiQw', [
    'metadata' => [
        'reason'      => 'Customer requested for the refund.',
        'refunded_by' => 'John Doe',
    ],
]);

Retrieve all refunds

You can see a list of the refunds belonging to a specific charge.

Arguments
Key Required Type Default Description
$chargeId true string null The charge unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
charge false string null Only return refunds for the charge specified by this charge ID.
created false string null A filter on the list based on the object created field.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
Usage
$refunds = $stripe->refunds()->all('ch_4ECWMVQp5SJKEx');

foreach ($refunds['data'] as $refund) {
    var_dump($refund['id']);
}

Customers

Customer objects allow you to perform recurring charges and track multiple charges that are associated with the same customer. The API allows you to create, delete, and update your customers. You can retrieve individual customers as well as a list of all your customers.

Create a customer

Creates a new customer object.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
address false array [] The customer’s address.
balance false number null Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice.
coupon false string null Coupon identifier that applies a discount on all recurring charges.
description false string null An arbitrary string that you can attach to a customer object.
email false string null Customer’s email address.
invoice_prefix false string null The prefix for the customer used to generate unique invoice numbers.
invoice_settings false array [] Default invoice settings for this customer.
metadata false array [] A set of key/value pairs that you can attach to a customer object.
name false string null The customer’s full name or business name.
payment_method false string null ID of the PaymentMethod to attach to the customer.
phone false string null The customer’s phone number.
preferred_locales false array [] Customer’s preferred languages, ordered by preference.
shipping false array [] Mailing and shipping address for the customer. Appears on invoices emailed to this customer.
source false string | array null The source can either be a token or a dictionary containing the source details.
tax_exempt false string null Describes the customer’s tax exemption status
tax_id_data false string null The customer’s tax IDs.
Usage
$customer = $stripe->customers()->create([
    'email' => 'john@doe.com',
]);

echo $customer['id'];

Retrieve a customer

Retrieves the details of an existing customer.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
Usage
$customer = $stripe->customers()->find('cus_4EBumIjyaKooft');

echo $customer['email'];

Update a customer

Updates the specified customer by setting the values of the parameters passed.

This request accepts mostly the same arguments as the customer creation call.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
address false array [] The customer’s address.
balance false number null Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice.
coupon false string null Coupon identifier that applies a discount on all recurring charges.
default_source false string null Provide the ID of a payment source already attached to this customer to make it this customer’s default payment source
description false string null An arbitrary string that you can attach to a customer object.
email false string null Customer’s email address.
invoice_prefix false string null The prefix for the customer used to generate unique invoice numbers.
invoice_settings false array [] Default invoice settings for this customer.
metadata false array [] A set of key/value pairs that you can attach to a customer object.
name false string null The customer’s full name or business name.
phone false string null The customer’s phone number.
preferred_locales false array [] Customer’s preferred languages, ordered by preference.
shipping false array [] Mailing and shipping address for the customer. Appears on invoices emailed to this customer.
source false string | array null The source can either be a token or a dictionary containing the source details.
tax_exempt false string null The customer’s tax exemption. One of `none`, `exempt`, or `reverse`.
Usage
$customer = $stripe->customers()->update('cus_4EBumIjyaKooft', [
    'email' => 'jonathan@doe.com',
]);

echo $customer['email'];

Delete a customer

Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
Usage
$customer = $stripe->customers()->delete('cus_4EBumIjyaKooft');

Delete a customer discount

Removes the currently applied discount on a customer.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
Usage
$customer = $stripe->customers()->deleteDiscount('cus_4EBumIjyaKooft');

Retrieve all customers

Returns a list of your customers. The customers are returned sorted by creation date, with the most recently created customers appearing first.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
created false string null A filter on the list based on the object created field.
email false string null A filter on the list based on the customer’s email field.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
Usage
$customers = $stripe->customers()->all();

foreach ($customers['data'] as $customer) {
    var_dump($customer['id']);
}

Payment Methods

PaymentMethod objects represent your customer's payment instruments. They can be used with PaymentIntents to collect payments or saved to Customer objects to store instrument details for future payments.

Create a payment method

Creates a Payment Method object. Read the Stripe.js reference to learn how to create PaymentMethods via Stripe.js.

Arguments
Key Required Type Default Description
$parameters true array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
type true string null The type of the PaymentMethod, one of: `card`.
billing_details true array null Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods.
card false integer null If this is a card PaymentMethod, this array should contains the user’s card details.
metadata false array [] A set of key/value pairs that you can attach to a payment method object.
Usage
$paymentMethod = $stripe->paymentMethods()->create([
    'type' => 'card',
    'card' => [
        'number' => '4242424242424242',
        'exp_month' => 9,
        'exp_year' => 2020,
        'cvc' => '314'
    ],
]);

echo $paymentMethod['id'];

Retrieve a payment method

Retrieves a Payment Method object.

Arguments
Key Required Type Default Description
$paymentMethodId true string null The payment method unique identifier.
Usage
$paymentMethod = $stripe->paymentMethods()->find('pm_1FNPdU2eZvKYlo2C09r77g4w');

Update a payment method

Updates a Payment Method object. A PaymentMethod must be attached a customer to be updated.

Arguments
Key Required Type Default Description
$paymentMethodId true string null The payment method unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
billing_details true array null Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods.
card false integer null If this is a card PaymentMethod, this array should contains the user’s card details.
metadata false array [] A set of key/value pairs that you can attach to a payment method object.
Usage
$paymentMethod = $stripe->paymentMethods()->update('pm_1FNPtF2eZvKYlo2Cc72xxtPl', [
    'metadata' => [
        'order_id' => '123456',
    ],
]);

Retrieve all payment methods

Returns a list of Payment Methods for a given Customer.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
customer required string null The ID of the customer whose PaymentMethods will be retrieved.
type required string null A required filter on the list, based on the object type field.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
Usage
$paymentMethods = $stripe->paymentMethods()->all([
    'type' => 'card',
    'customer' => 'cus_FtAnrEozrF5NDy',
]);

foreach ($paymentMethods['data'] as $paymentMethod) {
    var_dump($paymentMethod['id']);
}

Attach a payment method

Attaches the Payment Method to a Customer.

Arguments
Key Required Type Default Description
$paymentMethodId true string null The payment method unique identifier.
$customerId true string null The customer unique identifier.
Usage
$paymentMethod = $stripe->paymentMethods()->attach('pm_1FNPdU2eZvKYlo2C09r77g4w', 'cus_FtAnrEozrF5NDy);

Detach a payment method

Detaches the Payment Method from a Customer.

Arguments
Key Required Type Default Description
$paymentMethodId true string null The payment method unique identifier.
Usage
$paymentMethod = $stripe->paymentMethods()->detach('pm_1FNPdU2eZvKYlo2C09r77g4w');

Cards

You can store multiple cards on a customer in order to charge the customer later. You can also store multiple debit cards on a recipient in order to transfer to those cards later.

Create a card

When you create a new credit card, you must specify a customer to create it on.

Creating a new credit card will not change the card owner's existing default credit card. If the card's owner has no default credit card, the added credit card will become the default.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$parameters true string | array null The card can either be a token or a dictionary containing the card details.
Usage

You have 3 different but very similar ways to create cards on Stripe.

Through a Stripe.js Token (recommended)
$card = $stripe->cards()->create('cus_4EBumIjyaKooft', $_POST['stripe_token']);

Note: The name of the stripe_token field might be different on your application!

Through a Stripe API Token
$token = $stripe->tokens()->create([
    'card' => [
        'number'    => '4242424242424242',
        'exp_month' => 10,
        'cvc'       => 314,
        'exp_year'  => 2020,
    ],
]);

$card = $stripe->cards()->create('cus_4EBumIjyaKooft', $token['id']);

Note: Please refer to the Token documentation for more information.

Through an array
$card = $stripe->cards()->create('cus_4EBumIjyaKooft', [
    'number'    => '4242424242424242',
    'exp_month' => 10,
    'cvc'       => 314,
    'exp_year'  => 2020,
]);

Retrieve a Card

Retrieves the details of an existing credit card.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$cardId true string null The card unique identifier.
Usage
$card = $stripe->cards()->find('cus_4EBumIjyaKooft', 'card_4DmaB3muM8SNdZ');

echo $card['last4'];

Update a card

If you need to update only some card details, like the billing address or expiration date, you can do so without having to re-enter the full card details.

When you update a card, Stripe will automatically validate the card.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$cardId true string null The card unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
address_city false string null City/District/Suburb/Town/Village.
address_country false string null Billing address country, if provided when creating card.
address_line1 false string null Address line 1 (Street address/PO Box/Company name).
address_line2 false string null Address line 2 (Apartment/Suite/Unit/Building).
address_state false string null State/County/Province/Region.
address_zip false string null ZIP or postal code.
exp_month false string null Two digit number representing the card’s expiration month.
exp_year false string null Four digit number representing the card’s expiration year.
metadata false array [] A set of key/value pairs that you can attach to a card object.
name false string null Cardholder name.
Usage
$card = $stripe->cards()->update('cus_4EBumIjyaKooft', 'card_4DmaB3muM8SNdZ', [
    'name'          => 'John Doe',
    'address_line1' => 'Example Street 1',
]);

Delete a card

You can delete cards from a customer.

If you delete a card that is currently the default card on a customer, the most recently added card will be used as the new default.

If you delete the last remaining card on a customer, the default_card attribute on the card's owner will become null.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$cardId true string null The card unique identifier.
Usage
$card = $stripe->cards()->delete('cus_4EBumIjyaKooft', 'card_4DmaB3muM8SNdZ');

Retrieve all cards

You can see a list of the cards belonging to a customer.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
Usage
$cards = $stripe->cards()->all('cus_4EBumIjyaKooft');

foreach ($cards['data'] as $card) {
    var_dump($card['id']);
}

Sources

Source objects allow you to accept a variety of payment methods. They represent a customer's payment instrument, and can be used with the Stripe API just like a Card object: once chargeable, they can be charged, or can be attached to customers.

Create a source

Creates a Source object.

Arguments
Key Required Type Default Description
$parameters true array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
type true string null The type of the Source.
amount false numeric null Amount associated with the source.
currency false string null Three-letter ISO code for the currency associated with the source.
flow false string null The authentication `flow` of the source to create. The `flow` is one of `redirect`, `receiver`, `code_verification`, `none`. It is generally inferred unless a type supports multiple flows.
mandate false array [] Information about a mandate possibility attached to a source object (generally for bank debits) as well as its acceptance status.
metadata false array [] A set of key/value pairs that you can attach to a source object.
owner false array [] Information about the owner of the payment instrument that may be used or required by particular source types.
receiver false array [] Optional parameters for the receiver flow. Can be set only if the source is a receiver (`flow` is `receiver)`.
redirect false array [] Parameters required for the redirect flow. Required if the source is authenticated by a redirect (`flow` is `redirect`).
source_order false array [] Parameters required for the redirect flow. Required if the source is authenticated by a redirect (`flow` is `redirect`).
statement_descriptor false string An arbitrary string to be displayed on your customer’s statement.
token false string An optional token used to create the source.
usage false string Either `reusable` or `single_use`.
Usage
$source = $stripe->sources()->create([
    'type' => 'ach_credit_transfer',
    'currency' => 'usd',
    'owner' => [
        'email' => 'jenny.rosen@example.com'
    ],
]);

echo $source['id'];

Retrieve a source

Retrieves a Source object.

Arguments
Key Required Type Default Description
$sourceId true string null The source unique identifier.
Usage
$source = $stripe->sources()->find('src_1FR3sfEind3TueVhD5ZyAvz8');

Update a source

Updates a Source object.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier. (This is for backwards compatibility.)
$sourceId true string null The source unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
amount false numeric null Amount associated with the source.
mandate false array [] Information about a mandate possibility attached to a source object (generally for bank debits) as well as its acceptance status.
metadata false array [] A set of key/value pairs that you can attach to a payment method object.
owner false array [] Information about the owner of the payment instrument that may be used or required by particular source types.
source_order false array [] Parameters required for the redirect flow. Required if the source is authenticated by a redirect (`flow` is `redirect`).
Usage
$source = $stripe->sources()->update('cus_4EBumIjyaKooft', 'src_1FR439Eind3TueVhKWibD8fH', [
    'metadata' => [
        'order_id' => '123456',
    ],
]);

Attach a source

Attaches the Source to a Customer.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$sourceId true string null The source unique identifier.
Usage
$source = $stripe->sources()->attach('cus_FtAnrEozrF5NDy', 'src_1FR439Eind3TueVhKWibD8fH');

Detach a source

Detaches the Source from a Customer.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$sourceId true string null The source unique identifier.
Usage
$source = $stripe->sources()->detach('cus_FtAnrEozrF5NDy', 'src_1FR439Eind3TueVhKWibD8fH');

Payment Intents

A Payment Intent guides you through the process of collecting a payment from your customer.

We recommend that you create exactly one Payment Intent for each order or customer session in your system. You can reference the Payment Intent later to see the history of payment attempts for a particular session.

A Payment Intent transitions through multiple statuses throughout its lifetime as it interfaces with Stripe.js to perform authentication flows and ultimately creates at most one successful charge.

Create a payment intent

Creates a Payment Intent object.

Arguments
Key Required Type Default Description
$parameters true array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
amount required boolean required A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency).
currency false string false Three-letter ISO currency code, in lowercase.
application_fee_amount false integer false The amount of the application fee (if any) that will be applied to the payment and transferred to the application owner’s Stripe account.
capture_method false string false One of `automatic` (default) or `manual`. When the capture method is `automatic`, Stripe automatically captures funds when the customer authorizes the payment.
confirm false boolean false Set to `true` to attempt to confirm this Payment Intent immediately.
confirmation_method false string false One of `automatic` (default) or `manual`. When the confirmation method is `automatic`, a Payment Intent can be confirmed using a publishable key. After `next_action`s are handled, no additional confirmation is required to complete the payment.
customer false string null ID of the Customer this Payment Intent belongs to, if one exists.
description false string null An arbitrary string attached to the Payment Intent. Often useful for displaying to users.
metadata false array [] A set of key/value pairs that you can attach to a Payment Intent object.
off_session false boolean null Set to `true` to indicate that the customer is not in your checkout flow during this payment attempt, and therefore is unable to authenticate.
on_behalf_of false string null The Stripe account ID for which this Payment Intent is created.
payment_method false string null ID of the Payment Method (a Payment Method, Card, BankAccount, or saved Source object) to attach to this Payment Intent.
payment_method_options false array [] Payment-method-specific configuration for this Payment Intent.
payment_method_types false array ["card"] The list of Payment Method types that this Payment Intent is allowed to set up. If this is not provided, defaults to `["card"]`. Valid Payment Method types include: `card`.
receipt_email false string null Email address that the receipt for the resulting payment will be sent to.
return_url false string null The URL to redirect your customer back to after they authenticate or cancel their payment on the payment method’s app or site. If you’d prefer to redirect to a mobile application, you can alternatively supply an application URI scheme. This parameter can only be used with `confirm` is `true`.
save_payment_method false boolean null If the Payment Intent has a `payment_method` and a `customer` or if you’re attaching a payment method to the Payment Intent in this request, you can pass `save_payment_method` as `true` to save the payment method to the customer.
setup_future_usage false boolean null Indicates that you intend to make future payments with this PaymentIntent’s payment method.
shipping false array null Shipping information for this PaymentIntent.
statement_descriptor false string null For non-card charges, you can use this value as the complete description that appears on your customers’ statements.
statement_descriptor_suffix false string null Provides information about a card payment that customers see on their statements.
transfer_data false array null The parameters used to automatically create a Transfer when the payment succeeds.
transfer_group false string null A string that identifies the resulting payment as part of a group.
Usage
$paymentIntent = $stripe->paymentIntents()->create([
    'amount' => 2000,
    'currency' => 'usd',
    'payment_method_types' => [
        'card',
    ],
]);

echo $paymentIntent['id'];

Retrieve a payment intent

Retrieves the details of a Payment Intent that has previously been created.

Arguments
Key Required Type Default Description
$paymentIntentId true string null The payment intent unique identifier.
Usage
$paymentIntent = $stripe->paymentIntents()->find('pi_1FFOKyEind3TueVhoddAahvY');

Update a payment intent

Updates properties on a Payment Intent without confirming.

Arguments
Key Required Type Default Description
$paymentIntentId true string null The payment intent unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
amount required boolean required A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency).
application_fee_amount false integer false The amount of the application fee (if any) that will be applied to the payment and transferred to the application owner’s Stripe account.
currency false string false Three-letter ISO currency code, in lowercase.
customer false string null ID of the Customer this Payment Intent belongs to, if one exists.
description false string null An arbitrary string attached to the Payment Intent. Often useful for displaying to users.
metadata false array [] A set of key/value pairs that you can attach to a Payment Intent object.
payment_method false string null ID of the Payment Method (a Payment Method, Card, BankAccount, or saved Source object) to attach to this Payment Intent.
payment_method_types false array ["card"] The list of Payment Method types that this Payment Intent is allowed to set up. If this is not provided, defaults to `["card"]`. Valid Payment Method types include: `card`.
receipt_email false string null Email address that the receipt for the resulting payment will be sent to.
save_payment_method false boolean null If the Payment Intent has a `payment_method` and a `customer` or if you’re attaching a payment method to the Payment Intent in this request, you can pass `save_payment_method` as `true` to save the payment method to the customer.
setup_future_usage false boolean null Indicates that you intend to make future payments with this PaymentIntent’s payment method.
shipping false array null Shipping information for this PaymentIntent.
statement_descriptor false string null For non-card charges, you can use this value as the complete description that appears on your customers’ statements.
statement_descriptor_suffix false string null Provides information about a card payment that customers see on their statements.
transfer_data false array null The parameters used to automatically create a Transfer when the payment succeeds.
transfer_group false string null A string that identifies the resulting payment as part of a group.
Usage
$paymentIntent = $stripe->paymentIntents()->update('pi_1FFOKyEind3TueVhoddAahvY', [
    'metadata' => [
        'order_id' => '123456',
    ],
]);

echo $paymentIntent['id'];

Retrieve all payment intents

Returns a list of Payment Intents.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
created false string null A filter on the list based on the object created field.
customer false string null Only return Payment Intents for the customer specified by this customer ID.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
Usage
$paymentIntents = $stripe->paymentIntents()->all();

foreach ($paymentIntents['data'] as $paymentIntent) {
    var_dump($paymentIntent['id']);
}

Cancel a payment intent

A Payment Intent object can be canceled when it is in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action.

Once canceled, no additional charges will be made by the Payment Intent and any operations on the Payment Intent will fail with an error.

For Payment Intents with a status of requires_capture, the remaining amount_capturable will automatically be refunded.

Arguments
Key Required Type Default Description
$paymentIntentId true string null The payment intent unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
cancellation_reason false string null Reason for canceling this Payment Intent. Possible values are `duplicate`, `fraudulent`, `requested_by_customer`, or `abandoned`.
Usage
$paymentIntent = $stripe->paymentIntents()->cancel('pi_1FFOKyEind3TueVhoddAahvY');

Confirm a payment intent

Confirm that your customer intends to pay with current or provided payment method. Upon confirmation, the Payment Intent will attempt to initiate a payment.

Arguments
Key Required Type Default Description
$paymentIntentId true string null The payment intent unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
off_session false boolean null Set to `true` to indicate that the customer is not in your checkout flow during this payment attempt, and therefore is unable to authenticate.
payment_method false string null ID of the payment method (a PaymentMethod, Card, BankAccount, or saved Source object) to attach to this Payment Intent.
payment_method_options false string null Payment-method-specific configuration for this Payment Intent.
payment_method_types false array null The list of payment method types (e.g. card) that this Payment Intent is allowed to use.
receipt_email false string null Email address that the receipt for the resulting payment will be sent to.
return_url false string null The URL to redirect your customer back to after they authenticate or cancel their payment on the payment method’s app or site.
save_payment_method false boolean null If the Payment Intent has a `payment_method` and a `customer or if you’re attaching a payment method to the Payment Intent in this request, you can pass the `save_payment_method` as `true` to save the payment method to the customer.
setup_future_usage false boolean null Indicates that you intend to make future payments with this PaymentIntent’s payment method.
shipping false array null Shipping information for this PaymentIntent.
Usage
$paymentIntent = $stripe->paymentIntents()->confirm('pi_1FFOKyEind3TueVhoddAahvY', [
    'payment_method' => 'pm_card_visa',
]);

Cancel a payment intent

Capture the funds of an existing uncaptured Payment Intent when its status is requires_capture.

Uncaptured Payment Intents will be canceled exactly seven days after they are created.

Arguments
Key Required Type Default Description
$paymentIntentId true string null The payment intent unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
amount_to_capture false integer null The amount to capture from the Payment Intent, which must be less than or equal to the original amount.
amount_to_capture false integer null The amount to capture from the Payment Intent, which must be less than or equal to the original amount.
application_fee_amount false integer null The amount of the application fee (if any) that will be applied to the payment and transferred to the application owner’s Stripe account.
statement_descriptor false string null For non-card charges, you can use this value as the complete description that appears on your customers’ statements.
statement_descriptor_suffix false string null Provides information about a card payment that customers see on their statements.
transfer_data false array null The parameters used to automatically create a Transfer when the payment is captured.
Usage
$paymentIntent = $stripe->paymentIntents()->capture('pi_1FFOKyEind3TueVhoddAahvY');

Setup Intents

A SetupIntent guides you through the process of setting up a customer's payment credentials for future payments. For example, you could use a SetupIntent to set up your customer's card without immediately collecting a payment. Later, you can use PaymentIntents to drive the payment flow.

Create a SetupIntent as soon as you're ready to collect your customer's payment credentials. Do not maintain long-lived, unconfirmed SetupIntents as they may no longer be valid. The SetupIntent then transitions through multiple statuses as it guides you through the setup process.

Successful SetupIntents result in payment credentials that are optimized for future payments. For example, cardholders in certain regions may need to be run through Strong Customer Authentication at the time of payment method collection in order to streamline later off-session payments.

By using SetupIntents, you ensure that your customers experience the minimum set of required friction, even as regulations change over time.

Create a setup intent

Creates a Setup Intent object.

Arguments
Key Required Type Default Description
$parameters true array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
confirm false boolean false Set to `true` to attempt to confirm this Setup Intent immediately.
customer false string null ID of the Customer this Setup Intent belongs to, if one exists.
description false string null An arbitrary string attached to the Setup Intent. Often useful for displaying to users.
metadata false array [] A set of key/value pairs that you can attach to a Setup Intent object.
on_behalf_of false string null The Stripe account ID for which this Setup Intent is created.
payment_method false string null ID of the Payment Method (a Payment Method, Card, BankAccount, or saved Source object) to attach to this Setup Intent.
payment_method_options false array [] Payment-method-specific configuration for this SetupIntent.
payment_method_types false array ["card"] The list of Payment Method types that this Setup Intent is allowed to set up. If this is not provided, defaults to `["card"]`. Valid Payment Method types include: `card`.
return_url false string null The URL to redirect your customer back to after they authenticate or cancel their payment on the payment method’s app or site. If you’d prefer to redirect to a mobile application, you can alternatively supply an application URI scheme. This parameter can only be used with `confirm` is `true`.
usage false string null Indicates how the payment method is intended to be used in the future. If not provided, this value defaults to off_session. Possible values: `on_session`, `off_session`.
Usage
$paymentMethod = $stripe->paymentMethods()->create([
    'type' => 'card',
    'card' => [
        'number' => '4242424242424242',
        'exp_month' => 9,
        'exp_year' => 2020,
        'cvc' => '314'
    ],
]);

echo $paymentMethod['id'];

Retrieve a setup intent

Retrieves the details of a Setup Intent that has previously been created.

Arguments
Key Required Type Default Description
$setupIntentId true string null The setup intent unique identifier.
Usage
$setupIntent = $stripe->setupIntents()->find('seti_123456789');

Update a setup intent

Updates a Payment Method object. A PaymentMethod must be attached a customer to be updated.

Arguments
Key Required Type Default Description
$setupIntentId true string null The setup intent unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
customer true array null ID of the Customer this Setup Intent belongs to, if one exists.
description false string null An arbitrary string attached to the object. Often useful for displaying to users.
metadata false array [] A set of key/value pairs that you can attach to a setup intent object.
payment_method false string null ID of the payment method (a PaymentMethod, Card, BankAccount, or saved Source object) to attach to this Setup Intent.
payment_method_types false array ["card" The list of payment method types (e.g. card) that this Setup Intent is allowed to set up. If this is not provided, defaults to ["card"].
Usage
$setupIntent = $stripe->setupIntents()->update('seti_123456789', [
    'metadata' => [
        'order_id' => '123456',
    ],
]);

Retrieve all setup intents

Returns a list of Setup Intents.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
created false string null A filter on the list based on the object created field.
customer false string null Only return Setup Intents for the customer specified by this customer ID.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
payment_method required string null Only return Setup Intents associated with the specified payment method.
starting_after false string null A cursor to be used in pagination.
Usage
$setupIntents = $stripe->setupIntents()->all();

foreach ($setupIntents['data'] as $setupIntent) {
    var_dump($setupIntent['id']);
}

Confirm a setup intent

Confirm that your customer intends to set up the current or provided payment method. For example, you would confirm a Setup Intent when a customer hits the “Save” button on a payment method management page on your website.
If the selected payment method does not require any additional steps from the customer, the Setup Intent will transition to the succeeded status.

Otherwise, it will transition to the requires_action status and suggest additional actions via next_action. If setup fails, the Setup Intent will transition to the requires_payment_method status.

Arguments
Key Required Type Default Description
$setupIntentId true string null The setup intent unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
payment_method false string null ID of the payment method (a PaymentMethod, Card, BankAccount, or saved Source object) to attach to this Setup Intent.
return_url false string null The URL to redirect your customer back to after they authenticate on the payment method’s app or site.
Usage
$setupIntent = $stripe->setupIntents()->confirm('seti_123456789', [
    'payment_method' => 'pm_card_visa',
]);

Cancel a setup intent

A Setup Intent can be canceled when it is in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action.

Once canceled, setup is abandoned and any operations on the SetupIntent will fail with an error.

Arguments
Key Required Type Default Description
$setupIntentId true string null The setup intent unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
cancellation_reason false string null Reason for canceling this Setup Intent. Possible values are `abandoned`, `requested_by_customer`, or `duplicate`.
Usage
$setupIntent = $stripe->setupIntents()->cancel('seti_123456789');

Subscriptions

Subscriptions allow you to charge a customer's card on a recurring basis. A subscription ties a customer to a particular plan.

Create a subscription

Creates a new subscription on an existing customer.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$parameters true array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
plan true string null The plan unique identifier.
coupon false string null The coupon unique identifier.
trial_end false integer null UTC integer timestamp representing the end of the trial period the customer will get before being charged for the first time.
source false string | array null The source can either be a token or a dictionary containing the source details.
quantity false integer 1 The quantity you'd like to apply to the subscription you're creating.
application_fee_percent false decimal null A positive decimal (with at most two decimal places) between 1 and 100.
tax_percent false decimal null A positive decimal (with at most two decimal places) between 1 and 100.
metadata false array [] A set of key/value pairs that you can attach to a subscription object.
Usage
$subscription = $stripe->subscriptions()->create('cus_4EBumIjyaKooft', [
    'plan' => 'monthly',
]);

echo $subscription['id'];

Retrieve a subscription

Retrieves the details of an existing customer subscription.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$subscriptionId true string null The subscription unique identifier.
Usage
$subscription = $stripe->subscriptions()->find('cus_4EBumIjyaKooft', 'sub_4ETjGeEPC5ai9J');

echo $subscription['id'];

Update a subscription

Updates an existing subscription on a customer to match the specified parameters. When changing plans or quantities, we will optionally prorate the price we charge next month to make up for any price changes.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$subscriptionId true string null The subscription unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
plan false string null The plan unique identifier.
coupon false string null The coupon unique identifier.
prorate false boolean null The coupon unique identifier.
trial_end false integer null Flag telling Stripe whether to prorate switching plans during a billing cycle.
source false string | array null The source can either be a token or a dictionary containing the source details.
quantity false integer 1 The quantity you'd like to apply to the subscription you're creating.
application_fee_percent false decimal null A positive decimal (with at most two decimal places) between 1 and 100.
tax_percent false decimal null A positive decimal (with at most two decimal places) between 1 and 100.
metadata false array [] A set of key/value pairs that you can attach to a subscription object.
Usage
$subscription = $stripe->subscriptions()->update('cus_4EBumIjyaKooft', 'sub_4ETjGeEPC5ai9J', [
    'plan' => 'monthly',
]);

Cancel a subscription

Cancels a customer's subscription. If you set the atPeriodEnd argument to true, the subscription will remain active until the end of the period, at which point it will be canceled and not renewed. By default, the subscription is terminated immediately. In either case, the customer will not be charged again for the subscription. Note, however, that any pending invoice items that you've created will still be charged for at the end of the period unless manually deleted. If you've set the subscription to cancel at period end, any pending prorations will also be left in place and collected at the end of the period, but if the subscription is set to cancel immediately, pending prorations will be removed.

By default, all unpaid invoices for the customer will be closed upon subscription cancellation. We do this in order to prevent unexpected payment retries once the customer has canceled a subscription. However, you can reopen the invoices manually after subscription cancellation to have us proceed with automatic retries, or you could even re-attempt payment yourself on all unpaid invoices before allowing the customer to cancel the subscription at all.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$subscriptionId true string null The subscription unique identifier.
$atPeriodEnd false boolean false A flag that if set to true will delay the cancellation of the subscription until the end of the current period.
$subscription = $stripe->subscriptions()->cancel('cus_4EBumIjyaKooft', 'sub_4ETjGeEPC5ai9J');
Cancel at the end of the period
$subscription = $stripe->subscriptions()->cancel('cus_4EBumIjyaKooft', 'sub_4ETjGeEPC5ai9J', true);

Reactivate a subscription

Reactivates a customer's subscription.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$subscriptionId true string null The subscription unique identifier.
$subscription = $stripe->subscriptions()->reactivate('cus_4EBumIjyaKooft', 'sub_4ETjGeEPC5ai9J');

Delete a subscription discount

Removes the currently applied discount on a subscription.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$subscriptionId true string null The subscription unique identifier.
Usage
$customer = $stripe->subscriptions()->deleteDiscount('cus_4EBumIjyaKooft', 'sub_4ETjGeEPC5ai9J');

Retrieve all subscriptions

You can see a list of the customer's active subscriptions. Note that the 10 most recent active subscriptions are always available by default on the customer object. If you need more than those 10, you can use the limit and starting_after parameters to page through additional subscriptions.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
Usage
$subscriptions = $stripe->subscriptions()->all('cus_4EBumIjyaKooft');

foreach ($subscriptions['data'] as $subscription) {
    var_dump($subscription['id']);
}

Tax Rates

Tax rates can be applied to invoices and subscriptions to collect tax.

Create a tax rate

Creates a new Tax Rate.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
display_name true string null The display name of the tax rate, which will be shown to users.
inclusive true boolean null This specifies if the tax rate is inclusive or exclusive.
percentage true numeric null This represents the tax rate percent out of 100.
active false boolean true Flag determining whether the tax rate is active or inactive. Inactive tax rates continue to work where they are currently applied however they cannot be used for new applications.
description false string null An arbitrary string attached to the tax rate for your internal use only. It will not be visible to your customers.
jurisdiction false string null The jurisdiction for the tax rate.
metadata false array [] A set of key/value pairs that you can attach to a tax rate object.
Usage
$taxRate = $stripe->taxRates()->create([
    'display_name' => 'VAT',
    'description' => 'VAT Germany',
    'jurisdiction' => 'DE',
    'percentage' => 19.0,
    'inclusive' => false,
]);

echo $taxRate['id'];

Retrieve a tax rate

Retrieves the details of an existing tax rate.

Arguments
Key Required Type Default Description
$taxRateId true string null The tax rate unique identifier.
Usage
$taxRate = $stripe->taxRates()->find('txr_1FR43AEind3TueVhoseBEvm9');

echo $taxRate['jurisdiction'];

Update a tax rate

Updates an existing tax rate.

Arguments
Key Required Type Default Description
$taxRateId true string null The tax rate unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
active false boolean true Flag determining whether the tax rate is active or inactive. Inactive tax rates continue to work where they are currently applied however they cannot be used for new applications.
description false string null An arbitrary string attached to the tax rate for your internal use only. It will not be visible to your customers.
display_name false string null The display name of the tax rate, which will be shown to users.
jurisdiction false string null The jurisdiction for the tax rate.
metadata false array [] A set of key/value pairs that you can attach to a tax rate object.
Usage
$taxRate = $stripe->taxRates()->update('txr_1FR43AEind3TueVhoseBEvm9', [
    'metadata' => [
        'foo' => 'bar',
    ],
]);

echo $taxRate['jurisdiction'];

Retrieve all tax rates

Returns a list of your tax rates. Tax rates are returned sorted by creation date, with the most recently created tax rates appearing first.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
active false boolean null Optional flag to filter by tax rates that are either active or not active (archived)
created false string null A filter on the list based on the object created field.
ending_before false string null A cursor to be used in pagination.
inclusive false boolean 10 Optional flag to filter by tax rates that are inclusive (or those that are not inclusive)
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
Usage
$taxRates = $stripe->taxRates()->all();

foreach ($taxRates['data'] as $taxRate) {
    var_dump($taxRate['jurisdiction']);
}

Plans

A subscription plan contains the pricing information for different products and feature levels on your site. For example, you might have a €10/month plan for basic features and a different €20/month plan for premium features.

Create a plan

You can create plans easily via the plan management page of the Stripe dashboard. Plan creation is also accessible via the API if you need to create plans on the fly.

Arguments
Key Required Type Default Description
$parameters true array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
id true string null The plan unique identifier.
amount true number null A positive amount for the transaction.
currency true string null 3-letter ISO code for currency.
interval true string null Specifies billing frequency. Either week, month or year.
interval_count false integer 1 The number of intervals between each subscription billing.
name true string null The name of the plan.
trial_period_days false string null Specifies a trial period in (an integer number of) days.
metadata false array [] A set of key/value pairs that you can attach to a transfer object.
statement_descriptor false string null An arbitrary string which will be displayed on the customer's bank statement.
Usage
$plan = $stripe->plans()->create([
    'id'                   => 'monthly',
    'name'                 => 'Monthly (30$)',
    'amount'               => 30.00,
    'currency'             => 'USD',
    'interval'             => 'month',
    'statement_descriptor' => 'Monthly Subscription to Foo Bar Inc.',
]);

echo $plan['id'];

Retrieve a plan

Retrieves the plan with the given ID.

Arguments
Key Required Type Default Description
$planId true string null The plan unique identifier.
Usage
$plan = $stripe->plans()->find('monthly');

echo $plan['name'];

Update a plan

Updates the name of a plan. Other plan details (price, interval, etc.) are, by design, not editable.

Arguments
Key Required Type Default Description
$planId true string null The plan unique identifier.
$parameters true array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
name true string null The name of the plan.
metadata false array [] A set of key/value pairs that you can attach to a transfer object.
statement_descriptor false string null An arbitrary string which will be displayed on the customer's bank statement.
Usage
$plan = $stripe->plans()->update('monthly', [
    'name' => 'Monthly Subscription',
]);

echo $plan['name'];

Delete a plan

You can delete plans via the plan management page of the Stripe dashboard. However, deleting a plan does not affect any current subscribers to the plan; it merely means that new subscribers can't be added to that plan. You can also delete plans via the API.

Arguments
Key Required Type Default Description
$planId true string null The plan unique identifier.
Usage
$plan = $stripe->plans()->delete('monthly');

Retrieve all plans

Returns a list of your plans.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
Usage
$plans = $stripe->plans()->all();

foreach ($plans['data'] as $plan) {
    var_dump($plan['id']);
}

Coupons

A coupon contains information about a percent-off discount you might want to apply to a customer. Coupons only apply to invoices created for recurring subscriptions and invoice items; they do not apply to one-off charges.

Create a coupon

You can create coupons easily via the coupon management page of the Stripe dashboard. Coupon creation is also accessible via the API if you need to create coupons on the fly.

A coupon has either a percent_off or an amount_off and currency. If you set an amount_off, that amount will be subtracted from any invoice's subtotal. For example, an invoice with a subtotal of $10 will have a final total of $0 if a coupon with an amount_off of 2000 is applied to it and an invoice with a subtotal of $30 will have a final total of $10 if a coupon with an amount_off of 2000 is applied to it.

Arguments
Key Required Type Default Description
$parameters true array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
id false string null The coupon unique identifier, if not provided a random string will be generated.
duration true string null Specifies how long the discount will be in effect. Can be `forever`, `once` or `repeating`.
amount_off false number null A positive amount representing the amount to subtract from an invoice total (required if percent_off is not passed).
currency true string null 3-letter ISO code for currency.
duration_in_months false integer null If duration is repeating, a positive integer that specifies the number of months the discount will be in effect.
max_redemptions false integer null A positive integer specifying the number of times the coupon can be redeemed before it’s no longer valid.
metadata false array [] A set of key/value pairs that you can attach to a coupon object.
percent_off false integer null A positive integer between 1 and 100 that represents the discount the coupon will apply (required if amount_off is not passed).
redeem_by false integer null Unix timestamp specifying the last time at which the coupon can be redeemed.
Usage
$coupon = $stripe->coupons()->create([
    'id'          => '50-PERCENT-OFF',
    'duration'    => 'forever',
    'percent_off' => 50,
]);

echo $coupon['id'];

Retrieve a coupon

Retrieves the coupon with the given ID.

Arguments
Key Required Type Default Description
$couponId true string null The coupon unique identifier.
Usage
$coupon = $stripe->coupons()->find('50-PERCENT-OFF');

echo $coupon['percent_off'];

Update a coupon

Updates the specified coupon by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

Arguments
Key Required Type Default Description
$couponId true string null The coupon unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
metadata false array [] A set of key/value pairs that you can attach to a coupon object.
Usage
$coupon = $stripe->coupons()->update('50-PERCENT-OFF', [
    'metadata' => [
        'foo' => 'Bar',
    ],
]);

Delete a coupon

You can delete coupons via the coupon management page of the Stripe dashboard. However, deleting a coupon does not affect any customers who have already applied the coupon; it means that new customers can't redeem the coupon. You can also delete coupons via the API.

Arguments
Key Required Type Default Description
$couponId true string null The coupon unique identifier.
Usage
$coupon = $stripe->coupons()->delete('50-PERCENT-OFF');

Retrieve all coupons

Returns a list of your coupons.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
created false string null A filter on the list based on the object created field.
customer false string null The customer unique identifier.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
Usage
$coupons = $stripe->coupons()->all();

foreach ($coupons['data'] as $coupon) {
    var_dump($coupon['id']);
}

Invoices

Invoices are statements of what a customer owes for a particular billing period, including subscriptions, invoice items, and any automatic proration adjustments if necessary.

Create an invoice

If you need to invoice your customer outside the regular billing cycle, you can create an invoice that pulls in all pending invoice items, including prorations. The customer's billing cycle and regular subscription won't be affected.

Once you create the invoice, it'll be picked up and paid automatically, though you can choose to pay it right away.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
application_fee false integer null An application fee to add on to this invoice.
description false string null An arbitrary string which you can attach to a invoice object.
metadata false array [] A set of key/value pairs that you can attach to a invoice object.
statement_descriptor false string null Extra information about a charge for the customer’s credit card statement.
subscription false string null The subscription unique identifier to invoice.
tax_percent false decimal null The percent tax rate applied to the invoice, represented as a decimal number
Usage
$invoice = $stripe->invoices()->create('cus_4EBumIjyaKooft');

Retrieve an invoice

Retrieves the invoice with the given ID.

Arguments
Key Required Type Default Description
$invoiceId true string null The invoice unique identifier.
Usage
$invoice = $stripe->invoices()->find('in_4EgP02zb8qxsLq');

echo $invoice['paid'];

Retrieve an invoice line items

When retrieving an invoice, you'll get a lines property containing the total count of line items and the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.

Arguments
Key Required Type Default Description
$invoiceId true string null The invoice unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
customer false string null The customer unique identifier.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
subscription false string null The subscription unique identifier.
Usage
$lines = $stripe->invoices()->invoiceLineItems('in_4EgP02zb8qxsLq');

foreach ($lines['data'] as $line) {
    var_dump($line['id']);
}

Retrieve an upcoming invoice

At any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discount that is applicable to the customer.

Note that when you are viewing an upcoming invoice, you are simply viewing a preview -- the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer's discount.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$subscriptionId false string null The subscription unique identifier.
Usage
$invoice = $stripe->invoices()->upcomingInvoice('cus_4EBumIjyaKooft');

foreach ($invoice['lines']['data'] as $item) {
    var_dump($item['id']);
}

Update an invoice

Until an invoice is paid, it is marked as open (closed=false). If you'd like to stop Stripe from automatically attempting payment on an invoice or would simply like to close the invoice out as no longer owed by the customer, you can update the closed parameter.

Arguments
Key Required Type Default Description
$invoiceId true string null The invoice unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
application_fee false integer null An application fee to add on to this invoice.
closed false boolean null Boolean representing whether an invoice is closed or not. To close an invoice, pass true.
description false string null An arbitrary string which you can attach to a invoice object.
forgiven false boolean null Boolean representing whether an invoice is forgiven or not.
metadata false array [] A set of key/value pairs that you can attach to a invoice object.
statement_descriptor false string null Extra information about a charge for the customer’s credit card statement.
subscription false string null The subscription unique identifier to invoice.
tax_percent false decimal null The percent tax rate applied to the invoice, represented as a decimal number
Usage
$invoice = $stripe->invoices()->update('in_4EgP02zb8qxsLq', [
    'closed' => true,
]);

Pay an invoice

Stripe automatically creates and then attempts to pay invoices for customers on subscriptions. We'll also retry unpaid invoices according to your retry settings. However, if you'd like to attempt to collect payment on an invoice out of the normal retry schedule or for some other reason, you can do so.

Arguments
Key Required Type Default Description
$invoiceId true string null The invoice unique identifier.
Usage
$invoice = $stripe->invoices()->pay('in_4EgP02zb8qxsLq');

Retrieve all invoices

You can list all invoices, or list the invoices for a specific customer. The invoices are returned sorted by creation date, with the most recently created invoices appearing first.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
customer false string null The customer unique identifier.
date false string null A filter on the list based on the object date field.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
Usage
$invoices = $stripe->invoices()->all();

foreach ($invoices['data'] as $invoice) {
    var_dump($invoice['id']);
}

Invoice Items

Sometimes you want to add a charge or credit to a customer but only actually charge the customer's card at the end of a regular billing cycle. This is useful for combining several charges to minimize per-transaction fees or having Stripe tabulate your usage-based billing totals.

Create a new invoice item

Adds an arbitrary charge or credit to the customer's upcoming invoice.

Arguments
Key Required Type Default Description
$customerId true string null The customer unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
amount true number null A positive amount for the transaction.
currency true string null 3-letter ISO code for currency.
subscription false string null The subscription unique identifier to add this invoice item to
description false string null An arbitrary string which you can attach to a invoice object.
metadata false array [] A set of key/value pairs that you can attach to a invoice object.
Usage
$invoiceItem = $stripe->invoiceItems()->create('cus_4EBumIjyaKooft', [
    'amount'   => 50.00,
    'currency' => 'USD',
]);

echo $invoiceItem['id'];

Retrieve an invoice item

Retrieves the invoice item with the given ID.

Arguments
Key Required Type Default Description
$invoiceItemId true string null The invoice item unique identifier.
Usage
$invoiceItem = $stripe->invoiceItems()->find('ii_4Egr3tUtHjVEnm');

echo $invoiceItem['amount'];

Update an invoice item

Updates the amount or description of an invoice item on an upcoming invoice. Updating an invoice item is only possible before the invoice it's attached to is closed.

Arguments
Key Required Type Default Description
$invoiceItemId true string null The invoice item unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
amount true number null A positive amount for the transaction.
description false string null An arbitrary string which you can attach to a invoice object.
metadata false array [] A set of key/value pairs that you can attach to a invoice object.
Usage
$invoiceItem = $stripe->invoiceItems()->update('ii_4Egr3tUtHjVEnm', [
    'description' => 'Candy',
    'metadata'    => [
        'foo' => 'Bar',
    ],
]);

Delete an invoice item

Removes an invoice item from the upcoming invoice. Removing an invoice item is only possible before the invoice it's attached to is closed.

Arguments
Key Required Type Default Description
$invoiceItemId true string null The invoice item unique identifier.
Usage
$stripe->invoiceItems()->delete('ii_4Egr3tUtHjVEnm');

Retrieve all invoice items

Returns a list of your invoice items. Invoice Items are returned sorted by creation date, with the most recently created invoice items appearing first.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
created false string null A filter on the list based on the object created field.
customer false string null The customer unique identifier.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
Usage
$invoiceItems = $stripe->invoiceItems()->all();

foreach ($invoiceItems['data'] as $invoiceItem) {
    var_dump($invoiceItem['id']);
}

Disputes

A dispute occurs when a customer questions your charge with their bank or credit card company. When a customer disputes your charge, you're given the opportunity to respond to the dispute with evidence that shows the charge is legitimate.

Retrieve a dispute

Retrieves the dispute with the given ID.

Arguments
Key Required Type Default Description
$disputeId true string null The dispute unique identifier.
Usage
$dispute = $stripe->disputes()->find('dp_1FNKXICyvLc26QsPT1TD52kl');

echo $dispute['status'];

Update a dispute

When you get a dispute, contacting your customer is always the best first step. If that doesn't work, you can submit evidence in order to help us resolve the dispute in your favor. You can do this in your dashboard, but if you prefer, you can use the API to submit evidence programmatically.

Depending on your dispute type, different evidence fields will give you a better chance of winning your dispute. You may want to consult the Stripe guide to dispute types to help you figure out which evidence fields to provide.

Arguments
Key Required Type Default Description
$chargeId true string null The charge unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
evidence false string null An evidence that you can attach to a dispute object.
metadata false array [] A set of key/value pairs that you can attach to a charge object.
submit false boolean true Whether to immediately submit evidence to the bank. If `false`, evidence is staged on the dispute. Staged evidence is visible in the API and Dashboard, and can be submitted to the bank by making another request with this attribute set to `true` (the default).
Usage
$dispute = $stripe->disputes()->update('ch_4ECWMVQp5SJKEx', [
    'evidence' => 'Customer agreed to drop the dispute.',
]);

Close a dispute

Closing the dispute for a charge indicates that you do not have any evidence to submit and are essentially 'dismissing' the dispute, acknowledging it as lost.

The status of the dispute will change from under_review to lost. Closing a dispute is irreversible.

Arguments
Key Required Type Default Description
$chargeId true string null The charge unique identifier.
Usage
$dispute = $stripe->disputes()->close('ch_4ECWMVQp5SJKEx');

Retrieve all disputes

Returns a list of your disputes.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
created false string null A filter on the list based on the object created field.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
Usage
$disputes = $stripe->disputes()->all();

foreach ($disputes['data'] as $dispute) {
    var_dump($dispute['id']);
}

Transfers

When Stripe sends you money or you initiate a transfer to a third party recipient's bank account or debit card, a transfer object will be created. You can retrieve individual transfers as well as list all transfers.

Create a transfer

To send funds from your Stripe account to a third-party recipient or to your own bank account, you create a new transfer object. Your Stripe balance must be able to cover the transfer amount, or you'll receive an "Insufficient Funds" error.

If your API key is in test mode, money won't actually be sent, though everything else will occur as if in live mode.

Arguments
Key Required Type Default Description
$transferId true string null The transfer unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
amount true number null A positive amount for the transaction.
currency true string null 3-letter ISO code for currency.
recipient true string null The ID of an existing, verified recipient.
description false string null An arbitrary string which you can attach to a transfer object.
bank_account false string null If a recipient has both a bank account and a card attached, this parameter or the `card` parameter must be provided, but never both.
card false string null The card unique identifier.
statement_descriptor false string null An arbitrary string which will be displayed on the recipient's bank or card statement.
metadata false array [] A set of key/value pairs that you can attach to a transfer object.
Usage
$transfer = $stripe->transfers()->create([
    'amount'    => 10.00,
    'currency'  => 'USD',
    'recipient' => 'rp_4EYxxX0LQWYDMs',
]);

echo $transfer['id'];

Retrieve a transfer

Retrieves the details of an existing transfer. Supply the unique transfer ID from either a transfer creation request or the transfer list, and Stripe will return the corresponding transfer information.

Arguments
Key Required Type Default Description
$transferId true string null The transfer unique identifier.
Usage
$transfer = $stripe->transfers()->find('tr_15nBIqJvzVWl1WTebSIGDfRv');

echo $transfer['id'];

Update a transfer

Updates the specified transfer by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

This request accepts only the description and metadata as arguments.

Arguments
Key Required Type Default Description
$transferId true string null The transfer unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
description false string null An arbitrary string which you can attach to a transfer object.
metadata false array [] A set of key/value pairs that you can attach to a transfer object.
Usage
$transfer = $stripe->transfers()->update('tr_15nBIqJvzVWl1WTebSIGDfRv', [
    'description' => 'Transfer to John Doe',
]);

echo $transfer['description'];

Retrieve all transfers

Returns a list of existing transfers sent to third-party bank accounts or that Stripe has sent you. The transfers are returned in sorted order, with the most recently created transfers appearing first.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
created false string null A filter on the list based on the object created field.
date false string null A filter on the list based on the object date field.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
recipient false string null The recipient unique identifier.
starting_after false string null A cursor to be used in pagination.
status false string null Only return transfers that have the given status: `pending`, `paid`, or `failed`.
Usage
$transfers = $stripe->transfers()->all();

foreach ($transfers['data'] as $transfer) {
    var_dump($transfer['id']);
}

Transfer Reversals

A previously created transfer can be reversed if it has not yet been paid out. Funds will be refunded to your available balance, and the fees you were originally charged on the transfer will be refunded. You may not reverse automatic Stripe transfers.

Create a reversal

When you create a new reversal, you must specify a transfer to create it on.

Creating a new reversal on a transfer that has previously been created but not paid out will return the funds to your available balance and refund the fees you were originally charged on the transfer. You may not reverse automatic Stripe transfers.

When reversing transfers to Stripe accounts, you can optionally reverse part of the transfer. You can do so as many times as you wish until the entire transfer has been reversed.

Once entirely reversed, a transfer can't be reversed again. This method will return an error when called on an already-reversed transfer, or when trying to reverse more money than is left on a transfer.

Arguments
Key Required Type Default Description
$transferId true string null The transfer unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
amount false number null A positive amount for the transaction.
refund_application_fee false boolean false Boolean indicating whether the application fee should be refunded when reversing this reversal.
metadata false array [] A set of key/value pairs that you can attach to a reversal object.
description false string null An arbitrary string which you can attach to a reversal object.
Usage
$reversal = $stripe->transferReversals()->create('tr_15nBIqJvzVWl1WTebSIGDfRv');

echo $reversal['id'];

Retrieve a reversal

By default, you can see the 10 most recent reversals stored directly on the transfer object, but you can also retrieve details about a specific reversal stored on the transfer.

Arguments
Key Required Type Default Description
$transferId true string null The transfer unique identifier.
$transferReversalId true string null The transfer reversal unique identifier.
Usage
$reversal = $stripe->transferReversals()->find('tr_15nBIqJvzVWl1WTebSIGDfRv', 'trr_15nBIqJvzVWl1WTeMR8Spwxe');

echo $reversal['description'];

Update a reversal

Updates the specified reversal by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

This request only accepts metadata and description as arguments.

Arguments
Key Required Type Default Description
$transferId true string null The transfer unique identifier.
$transferReversalId true string null The transfer reversal unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
metadata false array [] A set of key/value pairs that you can attach to a reversal object.
description false string null An arbitrary string which you can attach to a reversal object.
Usage
$reversal = $stripe->transferReversals()->update('tr_15nBIqJvzVWl1WTebSIGDfRv', 'trr_15nBIqJvzVWl1WTeMR8Spwxe', [
    'description' => 'Reversed the transfer.',
]);

echo $reversal['description'];

Retrieve all reversals

You can see a list of the reversals belonging to a specific transfer. Note that the 10 most recent reversals are always available by default on the transfer object. If you need more than those 10, you can use this API method and the limit and starting_after parameters to page through additional reversals.

Arguments
Key Required Type Default Description
$transferId true string null The transfer unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
Usage
$reversals = $stripe->transferReversals()->all('tr_15nBIqJvzVWl1WTebSIGDfRv');

foreach ($reversals['data'] as $reversal) {
    var_dump($reversal['id']);
}

Recipients

With recipient objects, you can transfer money from your Stripe account to a third party bank account or debit card. The API allows you to create, delete, and update your recipients. You can retrieve individual recipients as well as a list of all your recipients.

Create a recipient

Creates a new recipient object and verifies both the recipient's identity and, if provided, the recipient's bank account information or debit card.

Arguments
Key Required Type Default Description
$parameters true array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
name true string null The recipient's full, legal name.
type true string null Type of the recipient: either `individual` or `corporation`.
tax_id false string null The recipient's tax ID, as a string. For type individual, the full SSN; for type corporation, the full EIN.
bank_account false string | array null A bank account to attach to the recipient.
card false string | array null The card token or an array.
email false string null The recipient's email address.
description false string null An arbitrary string which you can attach to a recipient object.
metadata false array [] A set of key/value pairs that you can attach to a recipient object.
Usage
$recipient = $stripe->recipients()->create([
    'name' => 'John Doe',
    'type' => 'individual',
]);

Retrieve a recipient

Retrieves the details of an existing recipient. You need only supply the unique recipient identifier that was returned upon recipient creation.

Arguments
Key Required Type Default Description
$recipientId true string null The recipient unique identifier.
Usage
$recipient = $stripe->recipients()->find('rp_5jSK7FKTY7mMbr');

echo $recipient['id'];

Update a recipient

Updates the specified recipient by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

If you update the name or tax ID, the identity verification will automatically be rerun. If you update the bank account, the bank account validation will automatically be rerun.

Arguments
Key Required Type Default Description
$recipientId true string null The recipient unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
name false string null The recipient's full, legal name.
tax_id false string null The recipient's tax ID, as a string. For type individual, the full SSN; for type corporation, the full EIN.
bank_account false string | array null A bank account to attach to the recipient.
card false string | array null The card token or an array.
default_cart false string null The card unique identifier.
email false string null The recipient's email address.
description false string null An arbitrary string which you can attach to a recipient object.
metadata false array [] A set of key/value pairs that you can attach to a recipient object.
Usage
$recipient = $stripe->recipients()->update('rp_5jSK7FKTY7mMbr', [
    'name' => 'John Doe Inc.',
]);

Delete a recipient

Permanently deletes a recipient. It cannot be undone.

Arguments
Key Required Type Default Description
$recipientId true string null The recipient unique identifier.
$cardId true string null The card unique identifier.
Usage
$recipient = $stripe->recipients()->destroy([
    'id' => 'rp_4EYRyEYthf2Doc',
]);

Retrieve all recipients

Returns a list of your recipients. The recipients are returned sorted by creation date, with the most recently created recipient appearing first.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
created false string null A filter on the list based on the object created field.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
verified false boolean null Only return recipients that are verified or unverified.
Usage
$recipients = $stripe->recipients()->all();

foreach ($recipients['data'] as $recipient) {
    var_dump($recipient['id']);
}

Products

Store representations of products you sell in product objects, used in conjunction with SKUs. Products may be physical goods, to be shipped, or digital.

Create a product

Creates a new product object.

Arguments
Key Required Type Default Description
$parameters true array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
id true string null The products unique identifier.
name true string null The product’s name, meant to be displayable to the customer.
active false boolean null Only return products that are active or inactive (e.g. pass false to list all inactive products).
attributes false array [] A list of up to 5 alphanumeric attributes that each SKU can provide values for (e.g. `[ "color", "size" ]`).
caption false string null A short one-line description of the product, meant to be displayable to the customer.
description false string null The product’s description, meant to be displayable to the customer.
images false array [] A list of up to 8 URLs of images for this product, meant to be displayable to the customer.
metadata false array [] A set of key/value pairs that you can attach to a transfer object.
package_dimensions false array [] The dimensions of this product, from the perspective of shipping. A SKU associated with this product can override this value by having its own `package_dimensions`.
shippable false boolean true Whether this product is shipped (i.e. physical goods). Defaults to `true`.
url false string null A URL of a publicly-accessible webpage for this product.
Usage
$product = $stripe->products()->create([
    'name'        => 'T-shirt',
    'description' => 'Comfortable gray cotton t-shirts',
    'attributes'  => [ 'size', 'gender' ]
]);

echo $product['id'];

Retrieve a product

Retrieves the details of an existing product. Supply the unique product ID from either a product creation request or the product list, and Stripe will return the corresponding product information.

Arguments
Key Required Type Default Description
$productId true string null The product unique identifier.
Usage
$product = $stripe->products()->find('prod_72587E4aVLiMy6');

echo $product['name'];

Updates a product

Updates the specific product by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

Note that a product's attributes are not editable. Instead, you would need to deactivate the existing product and create a new one with the new attribute values.

Arguments
Key Required Type Default Description
$productId true string null The product unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
active false boolean null Only return products that are active or inactive (e.g. pass false to list all inactive products).
caption false string null A short one-line description of the product, meant to be displayable to the customer.
description false string null The product’s description, meant to be displayable to the customer.
images false array [] A list of up to 8 URLs of images for this product, meant to be displayable to the customer.
metadata false array [] A set of key/value pairs that you can attach to a transfer object.
name false string null The product’s name, meant to be displayable to the customer.
package_dimensions false array [] The dimensions of this product, from the perspective of shipping. A SKU associated with this product can override this value by having its own `package_dimensions`.
shippable false boolean true Whether this product is shipped (i.e. physical goods). Defaults to `true`.
url false string null A URL of a publicly-accessible webpage for this product.
Usage
$product = $stripe->products()->update('pr_16nYIkJvzVWl1WTezKYABD87', [
    'description' => 'Comfortable gray cotton t-shirts',
]);

echo $product['id'];

Retrieve all products

Returns a list of your products. The products are returned sorted by creation date, with the most recently created products appearing first.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
active false boolean null Only return products that are active or inactive (e.g. pass `false` to list all inactive products).
ending_before false string null A cursor to be used in pagination.
ids false string null Only return products with the given IDs.
limit false integer 10 A limit on the number of objects to be returned.
shippable false boolean null Only return products that can be shipped (i.e., physical, not digital products).
starting_after false string null A cursor to be used in pagination.
url false string null Only return products with the given url.
Usage
$products = $stripe->products()->all();

foreach ($products['data'] as $product) {
    var_dump($product['id']);
}

SKUs

Stores representations of stock keeping units. SKUs describe specific product variations, taking into account any combination of: attributes, currency, and cost. For example, a product may be a t- shirt, whereas a specific SKU represents the size: large, color: red version of that shirt.

Can also be used to manage inventory.

Create an SKU

Creates a new product object.

Arguments
Key Required Type Default Description
$parameters true array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
id false string null The identifier for the SKU. Must be unique. If not provided, an identifier will be randomly generated.
currency true string null 3-letter ISO code for currency.
inventory true array [] Description of the SKU’s inventory.
price true number null The cost of the item as a positive integer in the smallest currency unit (that is, 100 cents to charge $1.00, or 1 to charge ¥1, Japanese Yen being a 0-decimal currency).
product true string null The ID of the product this SKU is associated with.
active false boolean null Only return products that are active or inactive (e.g. pass false to list all inactive products).
attributes false array [] A list of up to 5 alphanumeric attributes that each SKU can provide values for (e.g. `[ "color", "size" ]`).
image false string null The URL of an image for this SKU, meant to be displayable to the customer.
metadata false array [] A set of key/value pairs that you can attach to a transfer object.
package_dimensions false array [] The dimensions of this product, from the perspective of shipping. A SKU associated with this product can override this value by having its own `package_dimensions`.
Usage
$sku = $stripe->skus()->create([
    'product'   => 'pr_16nYIkJvzVWl1WTezKYABD87',
    'price'     => 1500,
    'currency'  => 'usd',
    'inventory' => [
        'type'     => 'finite',
        'quantity' => 500
    ],
    'attributes' => [
        'size'   => 'Medium',
        'gender' => 'Unisex',
    ],
]);

echo $sku['id'];

Retrieve a SKU

Retrieves the details of an existing SKU. Supply the unique SKU identifier from either a SKU creation request or from the product, and Stripe will return the corresponding SKU information.

Arguments
Key Required Type Default Description
$skuId true string null The SKU unique identifier.
Usage
$sku = $stripe->skus()->find('t-shirt-small-red');

echo $sku['name'];

Updates an SKU

Updates the specific product by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

Note that a product's attributes are not editable. Instead, you would need to deactivate the existing product and create a new one with the new attribute values.

Arguments
Key Required Type Default Description
$skuId true string null The SKU unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
active false boolean null Only return products that are active or inactive (e.g. pass false to list all inactive products).
currency false string null 3-letter ISO code for currency.
image false string null The URL of an image for this SKU, meant to be displayable to the customer.
inventory false array [] Description of the SKU’s inventory.
metadata false array [] A set of key/value pairs that you can attach to a transfer object.
package_dimensions false array [] The dimensions of this product, from the perspective of shipping. A SKU associated with this product can override this value by having its own `package_dimensions`.
price false number null The cost of the item as a positive integer in the smallest currency unit (that is, 100 cents to charge $1.00, or 1 to charge ¥1, Japanese Yen being a 0-decimal currency).
Usage
$sku = $stripe->skus()->update('sk_16nYNvJvzVWl1WTeba414tlY', [
    'metadata' => [
        'foo' => 'Bar',
    ],
]);

echo $sku['id'];

Retrieve all SKUs

Returns a list of your SKUs. The SKUs are returned sorted by creation date, with the most recently created SKUs appearing first.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
active false boolean null Only return SKUs that are active or inactive (e.g. pass `false` to list all inactive products).
attributes false array null Only return SKUs that have the specified key/value pairs in this partially constructed dictionary. Can be specified only if `product` is also supplied. For instance, if the associated product has attributes `["color", "size"]`, passing in `attributes[color]=red` returns all the SKUs for this product that have `color` set to `red`.
ending_before false string null A cursor to be used in pagination.
ids false string null Only return SKUs with the given IDs.
in_stock false string null Only return SKUs that are either in stock or out of stock (e.g. pass false to list all SKUs that are out of stock). If no value is provided, all SKUs are returned.
limit false integer 10 A limit on the number of objects to be returned.
product false string null The ID of the product whose SKUs will be retrieved.
starting_after false string null A cursor to be used in pagination.
Usage
$skus = $stripe->skus()->all();

foreach ($skus['data'] as $sku) {
    var_dump($sku['id']);
}

Orders

The purchase of previously defined products by end customers is handled through the creation of order objects. You can create, retrieve, and pay individual orders, as well as list all orders. Orders are identified by a unique random ID.

Create an order

Creates a new order object.

Arguments
Key Required Type Default Description
$parameters true array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
currency true string null 3-letter ISO code for currency.
customer false string null The ID of an existing customer that will be charged in this request.
email false string null The email address of the customer placing the order.
items false array [] List of items constituting the order.
metadata false array [] A set of key/value pairs that you can attach to a transfer object.
shipping false array [] Shipping address for the order. Required if any of the SKUs are for products that have `shippable` set to true.
Usage
$order = $stripe->orders()->create([
    'currency' => 'usd',
    'items' => [
        [
            'type'   => 'sku',
            'parent' => 't-shirt-small-red',
        ],
    ],
    'shipping' => [
        'name'    => 'Jenny Rosen',
        'address' => [
            'line1'       => '1234 Main street',
            'city'        => 'Anytown',
            'country'     => 'US',
            'postal_code' => '123456',
        ],
    ],
    'email' => 'jenny@ros.en'
]);

echo $order['id'];

Retrieve an order

Retrieves the details of an existing order. Supply the unique order ID from either an order creation request or the order list, and Stripe will return the corresponding order information.

Arguments
Key Required Type Default Description
$orderId true string null The order unique identifier.
Usage
$order = $stripe->orders()->find('or_16nYXbJvzVWl1WTe7t5ODS8z');

echo $order['status'];

Updates an order

Updates the specific order by setting the values of the parameters passed. Any parameters not provided will be left unchanged. This request accepts only the metadata, and status as arguments.

Arguments
Key Required Type Default Description
$orderId true string null The order unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
coupon false string null A coupon code that represents a discount to be applied to this order. Must be one-time duration and in same currency as the order.
metadata false array [] A set of key/value pairs that you can attach to a transfer object.
selected_shipping_method false string null The shipping method to select for fulfilling this order. If specified, must be one of the `id`s of a shipping method in the `shipping_methods` array. If specified, will overwrite the existing selected shipping method, updating `items` as necessary.
status false string null Current order status. One of `created`, `paid`, `canceled`, `fulfilled`, or `returned`.
Usage
$order = $stripe->orders()->update('or_16nYXbJvzVWl1WTe7t5ODS8z', [
    'metadata' => [
        'foo' => 'Bar',
    ],
]);

echo $order['status'];

Pay an order

Pay an order by providing a source to create a payment.

Arguments
Key Required Type Default Description
$orderId true string null The order unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
customer false string null The ID of an existing customer that will be charged in this request.
source false string | array null A payment source to be charged, such as a credit card. If you also pass a customer ID, the source must be the ID of a source belonging to the customer. Otherwise, if you do not pass a customer ID, the source you provide must either be a token, like the ones returned by Stripe.js, or a associative array containing a user's credit card details, with the options described below. Although not all information is required, the extra info helps prevent fraud.
email false string null The email address of the customer placing the order. If a `customer` is specified, that customer's email address will be used.
application_fee false integer null An application fee to add on to this order payment.
metadata false array [] A set of key/value pairs that you can attach to a transfer object.
Usage
$order = $stripe->orders()->pay('or_16nYXbJvzVWl1WTe7t5ODS8z');

echo $order['status'];

Retrieve all orders

Returns a list of your orders. The orders are returned sorted by creation date, with the most recently created orders appearing first.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
ending_before false string null A cursor to be used in pagination.
ids false string null Only return orders with the given IDs.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
status false string null Only return orders that have the given status. One of `created`, `paid`, `fulfilled`, or `refunded`.
Usage
$orders = $stripe->orders()->all();

foreach ($orders['data'] as $order) {
    var_dump($order['id']);
}

Application Fees

When you collect a transaction fee on top of a charge made for your user (using Stripe Connect), an application fee object is created in your account. You can list, retrieve, and refund application fees.

Retrieve an application fee

Arguments
Key Required Type Default Description
$applicationFeeId true string null The application fee unique identifier.
Usage
$fee = $stripe->applicationFees()->find('fee_4EUveQeJwxqxD4');

echo $fee['id'];

Retrieve all application fees

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
charge false string null Only return application fees for the charge specified by this charge ID.
created false string null A filter on the list based on the object created field.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
Usage
$fees = $stripe->applicationFees()->all();

foreach ($fees['data'] as $fee) {
    var_dump($fee['id']);
}

Application Fee Refunds

Application Fee Refund objects allow you to refund an application fee that has previously been created but not yet refunded. Funds will be refunded to the Stripe account that the fee was originally collected from.

Create an application fee refund

Arguments
Key Required Type Default Description
$applicationFeeId true string null The application fee id unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
amount false number null A positive amount representing how much of this fee to refund.
metadata false array [] A set of key/value pairs that you can attach to a charge object.
Usage
$fee = $stripe->applicationFeeRefunds()->create('fee_4EUveQeJwxqxD4', [
    'amount' => 10.30,
]);

Retrieve an application fee refund

Arguments
Key Required Type Default Description
$applicationFeeId true string null The application fee unique identifier.
$refundId true string null The application fee refund unique identifier.
Usage
$fee = $stripe->applicationFeeRefunds()->find('fee_4EUveQeJwxqxD4', 'fr_5jSKUTcb2ZkbRA');

echo $fee['id'];

Update an application fee refund

Arguments
Key Required Type Default Description
$applicationFeeId true string null The application fee unique identifier.
$refundId true string null The application fee refund unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
metadata false array [] A set of key/value pairs that you can attach to a charge object.
Usage
$fee = $stripe->applicationFeeRefunds()->update('fee_4EUveQeJwxqxD4', 'fr_5jSKUTcb2ZkbRA', [
    'metadata' => [
        'foo' => 'bar'
    ],
]);

echo $fee['id'];

Retrieve all application fee refunds

Arguments
Key Required Type Default Description
$applicationFeeId true string null The application fee unique identifier.
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
Usage
$fees = $stripe->applicationFees()->all('fee_4EUveQeJwxqxD4');

foreach ($fees['data'] as $fee) {
    var_dump($fee['id']);
}

Account

This is an object representing your Stripe account. You can retrieve it to see properties on the account like its current e-mail address or if the account is enabled yet to make live charges.

Retrieve information about your Stripe account.

Usage
$account = $stripe->account()->details();

echo $account['email'];

Balance

This is an object representing your Stripe balance. You can retrieve it to see the balance currently on your Stripe account.

You can also retrieve a list of the balance history, which contains a full list of transactions that have ever contributed to the balance (charges, refunds, transfers, and so on).

Retrieve account balance

Retrieves the current account balance, based on the API key that was used to make the request.

Usage
$balance = $stripe->balance()->current();

echo $balance['pending']['amount'];

Retrieve a balance history

Retrieves the balance transaction with the given ID.

Arguments
Key Required Type Default Description
$transactionId true string null The transaction unique identifier.
Usage
$balance = $stripe->balance()->find('txn_4EI2Pu1gPR27yT');

echo $balance['amount'];

Retrieve all the balance history

Returns a list of transactions that have contributed to the Stripe account balance (includes charges, refunds, transfers, and so on). The transactions are returned in sorted order, with the most recent transactions appearing first.

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
available_on false array null A filter on the list based on the object available_on field.
created false array null A filter on the list based on the object created field.
currency false string null
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
source false array null A filter on the list based on the object source field.
starting_after false string null A cursor to be used in pagination.
transfer false string null For automatic Stripe transfers only, only returns transactions that were transferred out on the specified transfer ID.
type false string null Only returns transactions of the given type. One of: `charge`, `refund`, `adjustment`, `application_fee`, `application_fee_refund`, `transfer` or `transfer_failure`.
Usage
$history = $stripe->balance()->all();

foreach ($history['data'] as $balance) {
    var_dump($balance['id']);
}

Events

Events are our way of letting you know about something interesting that has just happened in your account. When an interesting event occurs, we create a new event object. For example, when a charge succeeds we create a charge.succeeded event; or, when an invoice can't be paid we create an invoice.payment_failed event. Note that many API requests may cause multiple events to be created. For example, if you create a new subscription for a customer, you will receive both a customer.subscription.created event and a charge.succeeded event.

Retrieve an event

Arguments
Key Required Type Default Description
$eventId true string null The event unique identifier.
Usage
$event = $stripe->events()->find('evt_4ECnKrmXyNn8IM');

echo $event['type'];

Retrieve all events

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
created false string null A filter on the list based on the object created field.
delivery_success false boolean null Filter events by whether all webhooks were successfully delivered.
object_id false string null The object identifier.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
starting_after false string null A cursor to be used in pagination.
type false string null A string containing a specific event name, or group of events using * as a wildcard.
types false array [] An array of up to 20 strings containing specific event names.
Usage
$events = $stripe->events()->all();

foreach ($events['data'] as $event) {
    var_dump($event);
}

Files

A file may have been uploaded by yourself using the create file request (for example, when uploading a dispute evidence) or it may have been created by Stripe (for example, the results of a Sigma scheduled query).

Create a file

To upload a file to Stripe, you’ll need to send a request of type multipart/form-data.

The request should contain the file you would like to upload, as well as the parameters for creating a file.

Arguments
Key Required Type Default Description
$file require string null The file to upload. This is the path to a file on your local storage.
$purpose require string null The purpose of the uploaded file. Possible values are `business_icon`, `business_logo`, `customer_signature`, `dispute_evidence`, `identity_document`, `pci_document`, or `tax_document_user_upload.
file_link_data false array null Optional parameters to automatically create a file link for the newly created file.
Usage
$filePath = realpath(__DIR__.'/../files/verify-account.jpg');

$purpose = 'identity_document';

$file = $stripe->files()->create($filePath, $purpose);

echo $file['id'];

Retrieve a file

Arguments
Key Required Type Default Description
$fileId true string null The file unique identifier.
Usage
$file = $stripe->files()->find('file_1EwIDlEind3TueVhON4nGOZi');

echo $file['url'];

Retrieve all files

Arguments
Key Required Type Default Description
$parameters false array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
created false string null A filter on the list based on the object created field.
ending_before false string null A cursor to be used in pagination.
limit false integer 10 A limit on the number of objects to be returned.
purpose false string null The file purpose to filter queries by. If none is provided, files will not be filtered by purpose.
starting_after false string null A cursor to be used in pagination.
Usage
$files = $stripe->files()->all();

foreach ($files['data'] as $file) {
    var_dump($file);
}

Tokens

Often you want to be able to charge credit cards or send payments to bank accounts without having to hold sensitive card information on your own servers. Stripe.js makes this easy in the browser, but you can use the same technique in other environments with our token API.

Create a card token

Creates a single use token that wraps the details of a credit card. This token can be used in place of a credit card dictionary with any API method. These tokens can only be used once: by creating a new charge object, or attaching them to a customer.

Arguments
Key Required Type Default Description
$parameters true array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
card true string | array null The card unique identifier.
customer false string null A customer to create a token for.
Usage
$token = $stripe->tokens()->create([
    'card' => [
        'number'    => '4242424242424242',
        'exp_month' => 6,
        'exp_year'  => 2015,
        'cvc'       => 314,
    ],
]);

echo $token['id'];

Create a bank account token

Creates a single use token that wraps the details of a bank account. This token can be used in place of a bank account dictionary with any API method. These tokens can only be used once: by attaching them to a recipient.

Arguments
Key Required Type Default Description
$parameters true array null Please refer to the list below for a valid list of keys that can be passed on this array.
$parameters
Key Required Type Default Description
bank_account true string | array null A bank account to attach to the recipient.
Usage
$token = $stripe->tokens()->create([
    'bank_account' => [
        'country'        => 'US',
        'routing_number' => '110000000',
        'account_number' => '000123456789',
    ],
]);

echo $token['id'];

Retrieve a token

Retrieves the token with the given ID.

Arguments
Key Required Type Default Description
$tokenId true string null The token unique identifier.
Usage
$token = $stripe->tokens()->find('tok_15D2JOJvzVWl1WTewpv4hU8c');

Exceptions

The Stripe API will throw a few exceptions when something is wrong, like when a credit card with a bad number is submited, an expired credit card or even when Stripe.com itself has done something wrong.

Here is the list of all the exceptions that the Stripe API throws with a brief description:

Exception Description
Cartalyst\Stripe\Exception\BadRequestException This exception will be thrown when the data sent through the request is mal formed.
Cartalyst\Stripe\Exception\UnauthorizedException This exception will be thrown if your Stripe API Key is incorrect.
Cartalyst\Stripe\Exception\InvalidRequestException This exception will be thrown whenever the request fails for some reason.
Cartalyst\Stripe\Exception\NotFoundException This exception will be thrown whenever a request results on a 404.
Cartalyst\Stripe\Exception\CardErrorException This exception will be thrown whenever the credit card is invalid.
Cartalyst\Stripe\Exception\ServerErrorException This exception will be thrown whenever Stripe does something wrong.

Usage

Below is an example of using the API to find a customer, but this customer doesn't exist, so it'll throw a NotFoundException.

try {
    $customer = $stripe->customers()->find('foobar');

    echo $customer['email'];
} catch (Cartalyst\Stripe\Exception\NotFoundException $e) {
    // Get the status code
    $code = $e->getCode();

    // Get the error message returned by Stripe
    $message = $e->getMessage();

    // Get the error type returned by Stripe
    $type = $e->getErrorType();
}

Pagination

Handling pagination on APIs is very hard and instead of manually handling the pagination, the Stripe package comes with a resource iterator which handles all of this for you, automatically!

Here is an example of grabbing all the customers:

$customers = $stripe->customersIterator();

foreach ($customers as $customer) {
    var_dump($customer['id']);
}

You can still pass any API argument as you would with any normal API method:

$customers = $stripe->customersIterator([
    'created' => 123456789,
]);

foreach ($customers as $customer) {
    var_dump($customer['id']);
}

Addons

Addons extends the functionality and features of Stripe.

Billing Laravel

This addon adds billing functionality to your Laravel application.

Learn more about the Stripe Billing Laravel by following one of the following links:

You wont find fancy lifestyle graphics and marketing bravado here. Just cold... hard... code...

Code Well, Rock On!
Processing Payment...