Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  BUSINESS::STRIPE (3)

.ds Aq ’


Business::Stripe - Interface for Stripe payment system.



 my $stripe = Business::Stripe->new(
    -api_key => c6EiNIusHip8x5hkdIjtur7KNUA3TTpE

     amount => 400,
     card => tok_5EuIyKyCTc0f2V,
     description => Ice cream
 ) and return $stripe->success;

 print $stripe->error->{message}, "\n";


Provides common bindings for Stripe payment system. Any API calls that do not have bindings can be access through the generic api method.


new ({options})

Requires -api_key given to you as part of your Stripe account. Optional -url can override default:

api (method, path, params,...)

Generic function that sends requests to Stripe. Check Stripe API Reference <> for specific calls.

Assuming you’re not using Stripe.js to generate a token given the card information, you can do that using this call:

 my $token = $stripe->api(post, tokens,
     card[number]    => 4242424242424242,
     card[exp_month] => 12,
     card[exp_year]  => 2012,
     card[cvc]       => 123

Let’s create a new plan to subscribe the customer to:

 $stripe->api(post, plans,
     amount           => 500,
     id               => cone,
     currency         => usd,
     interval         => month,
     name             => The cone plan

Now, let’s create a customer object with the above token and subscribe the customer to our monthly $5 ice cream cone plan:

 my $customer = $stripe->api(post, customers,
     card            => $token,
     email           =>,
     description     => Ice creamer,
     plan            => cone

Customer wants to cancel the subscription:

 $stripe->api(delete, "customers/$customer/subscription");

method One of post, get, or delete.
path Either charges, events, invoices, events/{ID}, etc. Check API doc for complete list.
params This optional set of parameters can be a single element or a list of key/value pairs.
All actions can be performed by using only this method. The two set of functions charges and customers provided in this package are made available for functions that are used frequently in common implementations.

error (void)

Method returns 0 when encounter error conditions. The JSON object returned by Stripe can be retrieved via this method.

 print $stripe->error->{message}, "\n";

success (void)

When calls are successful a positive value is returned or if possible, the ID. Stripe’s JSON object can be retrieved via this method. Specific values are defined in the Stripe API Documentation.

 print $stripe->success->{data}->[0]->{description}, "\n";


Set of methods that handle credit/debit card such as charging a card, refund, retrieve specifc charge and list charges.

charges_create ({params})

Charge the credit card.


Assumes currency in usd. Uses token from Stripe.js.

    amount => 10,
    card => tok_Wzm6ewTBrkVvC3,
    description =>

amount Positive integer larger than 50 (amount is specified in cents).
currency 3-letter ISO code. Defaults to usd (it’s the only one supported).
customer Required if not using card below. The ID of an exisiting customer.
card Required if not using customer above. Uses Token acquired from Stripe.js or give it the card details.
description (optional) Descriptive text identifying the charge (recommend using customer’s email).

Returns the id if success (check success for JSON object). If error (use error for JSON object) returns 0.

charges_retrieve (id)

Takes the charge id value and yields data about the charge.


charges_refund (id, [amount])

Refund a specific amount (or if omitted, full refund) to the charge id. amount is in cents.

 ### refunds full amount

 ### refunds $5 over charge
 $stripe->charges_refund(ch_uxLBSIZB8azrSr, 500);

charges_list ({params})

List all the charges for a particular customer or list everything.

 ### lists next 5 charges
 $stripe->charges_list(count => 5, offset => 1);

count Optional number of records to return. Defaults to 10.
offset Optional paging marker. Defaults to 0.
customer Optional customer’s ID for filtering.

 ### list top 10 charges for this customer
 $stripe->charges_list(customer => cus_gpj0mzwbQKBI7c);


Multiple charges associated to a customer. By creating a customer, you don’t have to ask for credit card information every charge.

customers_create ({params})

Creates a new customer according to the credit card information or token given. Use this method to create a customer-ID for the given card (token when used in conjunction with Stripe.js). The customer-ID can be passed to charges_create’s customer parameter instead of card so that you don’t have to ask for credit card info again.

 ### creates the customer
 my $cid = $stripe->customers_create(
    card => tok_Wzm6ewTBrkVvC3,
    email =>,
    description => userid-123456

 ### charges the customer $5
 $cid and $stripe->charges_create(
    customer => $cid,
    amount => 500,
    description => userid-123456 paid $5

card Can either be a token or credit card info.
coupon Optional discount coupon code discount.
email Optional customer’s email.
description Optional description.

Returns customer’s ID if successful.

customers_retrieve (id)

Gets the customer’s object.


customers_update (id, [{params}])

Updates customer’s information.

    card => tok_Wzm6ewTBrkVvC3,
    description => new card

customers_delete (id)

Deletes the customer.


customers_list ({params})

List all customers.

 $stripe->customers_list(count => 20);

count Optional number of records to return. Defaults to 10.
offset Optional paging marker. Defaults to 0.
customers_subscribe (id, {params})

Subscribes a customer to a specified plan:

     plan => basic,
     prorate => false

Assuming basic is a plan already created in your Stripe account. If the customer already subscribed to a plan, this will change the plan to this new one.

customers_unsubscribe (id, [{param}])

Unsubscribe the customer from the plan that customer is subscribing to.

        at_period_end => true

    Helper Methods

_compose (resource, [{params}])

Helper function takes in a resource, defined by the Stripe API doc. Current resources:



Stripe.js Documentation <>.

Stripe Full API Reference <>.

Full featured implementation by Luke Closs Net::Stripe.


This module is implemented as a single-file package. If you don’t want to use the CPAN distribution, you can download from the root directory and renamed it to


Edit and remove the :: between the package name on the first line to:

 package BusinessStripe;

Include the file in your program:

 use BusinessStripe;
 my $stripe = BusinessStripe->new(
     -api_key => c6EiNIusHip8x5hkdIjtur7KNUA3TTpE


2012-03-27 v0.01 Initial release
2012-03-28 v0.02 Revised documentations, add README so tests won’t fail.
2012-04-01 v0.03 Update docs with better examples. Added customers_subscribe and customers_unsubscribe.
2012-10-18 v0.04 Add dependencies to META.json and Makefile.PL.
2015-11-16 v0.05 Fix POD errors. Removed errneous currency from create tokens example.


Paul Pham (@phamnp)


Copyright (C) 2015 Aquaron. All Rights Reserved.

This program and library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 STRIPE (3) 2015-11-17

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.