1Stripe(3)             User Contributed Perl Documentation            Stripe(3)
2
3
4

NAME

6       Business::Stripe - Interface for Stripe payment system.
7

SYNOPSIS

9        my $stripe     = Business::Stripe->new(
10           -api_key         => 'c6EiNIusHip8x5hkdIjtur7KNUA3TTpE'
11        );
12
13        $stripe->charges_create(
14            amount         => 400,
15            card           => 'tok_5EuIyKyCTc0f2V',
16            description    => 'Ice cream'
17        ) and return $stripe->success;
18
19        print $stripe->error->{message}, "\n";
20

DESCRIPTION

22       Provides common bindings for Stripe payment system.  Any API calls that
23       do not have bindings can be access through the generic "api" method.
24
25   Methods
26       new ({options})
27
28       Requires "-api_key" given to you as part of your Stripe account.
29       Optional "-url" can override default:
30
31        https://api.stripe.com/v1/
32
33       api (method, path, params,...)
34
35       Generic function that sends requests to Stripe.  Check Stripe API
36       Reference <https://stripe.com/docs/api> for specific calls.
37
38       Assuming you're not using Stripe.js to generate a token given the card
39       information, you can do that using this call:
40
41        my $token = $stripe->api('post', 'tokens',
42            'card[number]'    => '4242424242424242',
43            'card[exp_month]' => 12,
44            'card[exp_year]'  => 2012,
45            'card[cvc]'       => 123
46        );
47
48       Let's create a new plan to subscribe the customer to:
49
50        $stripe->api('post', 'plans',
51            amount           => 500,
52            id               => 'cone',
53            currency         => 'usd',
54            interval         => 'month',
55            name             => 'The cone plan'
56        );
57
58       Now, let's create a "customer" object with the above token and
59       subscribe the customer to our monthly $5 ice cream "cone" plan:
60
61        my $customer = $stripe->api('post', 'customers',
62            card            => $token,
63            email           => 'paul@example.com',
64            description     => 'Ice creamer',
65            plan            => 'cone'
66        );
67
68       Customer wants to cancel the subscription:
69
70        $stripe->api('delete', "customers/$customer/subscription");
71
72       parameters
73
74       method
75           One of "post", "get", or "delete".
76
77       path
78           Either "charges", "events", "invoices", "events/{ID}", etc.  Check
79           API doc for complete list.
80
81       params
82           This optional set of parameters can be a single element or a list
83           of key/value pairs.
84
85       All actions can be performed by using only this method.  The two set of
86       functions "charges" and "customers" provided in this package are made
87       available for functions that are used frequently in common
88       implementations.
89
90       error (void)
91
92       Method returns 0 when encounter error conditions.  The JSON object
93       returned by Stripe can be retrieved via this method.
94
95        print $stripe->error->{message}, "\n";
96
97       success (void)
98
99       When calls are successful a positive value is returned or if possible,
100       the ID. Stripe's JSON object can be retrieved via this method. Specific
101       values are defined in the Stripe API Documentation.
102
103        print $stripe->success->{data}->[0]->{description}, "\n";
104
105   Charges
106       Set of methods that handle credit/debit card such as charging a card,
107       refund, retrieve specifc charge and list charges.
108
109       charges_create ({params})
110
111       Charge the credit card.
112
113       parameters
114
115       Assumes currency in "usd". Uses token from Stripe.js.
116
117        $stripe->charges_create(
118           amount         => 10,
119           card         => 'tok_Wzm6ewTBrkVvC3',
120           description => 'customer@example.com'
121        );
122
123       amount
124           Positive integer larger than 50 (amount is specified in cents).
125
126       currency
127           3-letter ISO code. Defaults to "usd" (it's the only one supported).
128
129       customer
130           Required if not using "card" below.  The "ID" of an exisiting
131           customer.
132
133       card
134           Required if not using "customer" above.  Uses Token acquired from
135           Stripe.js or give it the card details.
136
137       description (optional)
138           Descriptive text identifying the charge (recommend using customer's
139           email).
140
141       returns
142
143       Returns the "id" if success (check "success" for JSON object).  If
144       error (use "error" for JSON object) returns 0.
145
146       charges_retrieve (id)
147
148       Takes the charge "id" value and yields data about the charge.
149
150        $stripe->charges_retrieve('ch_uxLBSIZB8azrSr');
151
152       charges_refund (id, [amount])
153
154       Refund a specific "amount" (or if omitted, full refund) to the charge
155       "id".  "amount" is in cents.
156
157        ### refunds full amount
158        $stripe->charges_refund('ch_uxLBSIZB8azrSr');
159
160        ### refunds $5 over charge
161        $stripe->charges_refund('ch_uxLBSIZB8azrSr', 500);
162
163       charges_list ({params})
164
165       List all the charges for a particular "customer" or list everything.
166
167        ### lists next 5 charges
168        $stripe->charges_list(count => 5, offset => 1);
169
170       parameters
171
172       count
173           Optional number of records to return.  Defaults to 10.
174
175       offset
176           Optional paging marker. Defaults to 0.
177
178       customer
179           Optional customer's ID for filtering.
180
181            ### list top 10 charges for this customer
182            $stripe->charges_list(customer => 'cus_gpj0mzwbQKBI7c');
183
184   Customers
185       Multiple charges associated to a customer. By creating a customer, you
186       don't have to ask for credit card information every charge.
187
188       customers_create ({params})
189
190       Creates a new customer according to the credit card information or
191       token given.  Use this method to create a customer-ID for the given
192       "card" (token when used in conjunction with Stripe.js).  The customer-
193       ID can be passed to "charges_create"'s "customer" parameter instead of
194       "card" so that you don't have to ask for credit card info again.
195
196        ### creates the customer
197        my $cid    = $stripe->customers_create(
198           card        => 'tok_Wzm6ewTBrkVvC3',
199           email       => 'customer@example.com',
200           description => 'userid-123456'
201        );
202
203        ### charges the customer $5
204        $cid and $stripe->charges_create(
205           customer    => $cid,
206           amount      => 500,
207           description => 'userid-123456 paid $5'
208        );
209
210       options
211
212       card
213           Can either be a token or credit card info.
214
215       coupon
216           Optional discount coupon code discount.
217
218       email
219           Optional customer's email.
220
221       description
222           Optional description.
223
224       returns
225
226       Returns customer's ID if successful.
227
228       customers_retrieve (id)
229
230       Gets the customer's object.
231
232        $stripe->customers_retrieve('cus_gpj0mzwbQKBI7c');
233
234       customers_update (id, [{params}])
235
236       Updates customer's information.
237
238        $stripe->customers_update('cus_gpj0mzwbQKBI7c',
239           card        => 'tok_Wzm6ewTBrkVvC3',
240           description => 'new card'
241        );
242
243       customers_delete (id)
244
245       Deletes the customer.
246
247        $stripe->customers_delete('cus_gpj0mzwbQKBI7c');
248
249       customers_list ({params})
250
251       List all customers.
252
253        $stripe->customers_list(count => 20);
254
255       parameters
256
257       count
258           Optional number of records to return. Defaults to 10.
259
260       offset
261           Optional paging marker. Defaults to 0.
262
263       customers_subscribe (id, {params})
264
265       Subscribes a customer to a specified plan:
266
267        $stripe->customers_subscribe('cus_YrUZejr9oojQjs',
268            plan       => 'basic',
269            prorate    => 'false'
270        );
271
272       Assuming "basic" is a plan already created in your Stripe account.  If
273       the customer already subscribed to a plan, this will change the plan to
274       this new one.
275
276       customers_unsubscribe (id, [{param}])
277
278       Unsubscribe the customer from the plan that customer is subscribing to.
279
280        $stripe->customers_unsubscribe('cus_YrUZejr9oojQjs',
281           at_period_end   => 'true'
282        );
283
284   Helper Methods
285       _compose (resource, [{params}])
286
287       Helper function takes in a resource, defined by the Stripe API doc.
288       Current resources:
289
290        charges
291        coupons
292        customers
293        invoices
294        invoiceitems
295        plans
296        tokens
297        events
298

REPOSITORY

300       <https://github.com/aquaron/Business-Stripe>
301

SEE ALSO

303       Stripe.js Documentation <https://stripe.com/docs/stripe.js>.
304
305       Stripe Full API Reference <https://stripe.com/docs/api>.
306
307       Full featured implementation by Luke Closs Net::Stripe.
308

SINGLE FILE INSTALLATION

310       This module is implemented as a single-file package.  If you don't want
311       to use the CPAN distribution, you can download "Stripe.pm" from the
312       root directory and renamed it to "BusinessStripe.pm":
313
314        mv Stripe.pm BusinessStripe.pm
315
316       Edit "BusinessStripe.pm" and remove the "::" between the package name
317       on the first line to:
318
319        package BusinessStripe;
320
321       Include the file in your program:
322
323        use BusinessStripe;
324        my $stripe = BusinessStripe->new(
325            -api_key => 'c6EiNIusHip8x5hkdIjtur7KNUA3TTpE'
326        );
327        $stripe->charges_list;
328

HISTORY

330       2012-03-27
331          v0.01 Initial release
332
333       2012-03-28
334          v0.02 Revised documentations, add README so tests won't fail.
335
336       2012-04-01
337          v0.03 Update docs with better examples.  Added "customers_subscribe"
338          and "customers_unsubscribe".
339
340       2012-10-18
341          v0.04 Add dependencies to META.json and Makefile.PL.
342
343       2015-11-16
344          v0.05 Fix POD errors.  Removed errneous "currency" from create
345          tokens example.
346
347       2016-11-14
348          v0.06 Fix documentation, change tabs to spaces instead.
349

AUTHOR

351       Paul Pham (@phamnp)
352
354       Copyright (C) 2016 Aquaron. All Rights Reserved.
355
356       This program and library is free software; you can redistribute it
357       and/or modify it under the same terms as Perl itself.
358
359
360
361perl v5.28.0                      2016-11-15                         Stripe(3)
Impressum