Net::Stripe - API client for Stripe.com
version 0.25
my $stripe = Net::Stripe->new(api_key => $API_KEY);
my $card_token = 'a token';
my $charge = $stripe->post_charge( # Net::Stripe::Charge
amount => 12500,
currency => 'usd',
card => $card_token,
description => 'YAPC Registration',
);
print "Charge was not paid!\n" unless $charge->paid;
my $card = $charge->card; # Net::Stripe::Card
# look up a charge by id
my $same_charge = $stripe->get_charge(charge_id => $charge->id);
# ... and the api mirrors https://stripe.com/docs/api
# Charges: post_charge() get_charge() refund_charge() get_charges()
# Customer: post_customer()
This module is a wrapper around the Stripe.com HTTP API. Methods are generally named after the HTTP method and the object name.
This method returns Moose objects for responses from the API.
This creates a new stripe api object. The following parameters are accepted:
- api_key
-
This is required. You get this from your Stripe Account settings.
- debug
-
You can set this to true to see extra debug info.
- debug_network
-
You can set this to true to see the actual network requests.
Reader: api_base
Type: Str
Additional documentation: This is the base part of the URL for every request made
Reader: api_key
Type: Str
This attribute is required.
Additional documentation: You get this from your Stripe Account settings
Reader: debug
Writer: debug
Type: Bool
Additional documentation: The debug flag
Reader: debug_network
Writer: debug_network
Type: Bool
Additional documentation: The debug network request flag
Reader: ua
Type: Object
Additional documentation: The LWP::UserAgent that is used for requests
Retrieve a balance transaction
https://stripe.com/docs/api#retrieve_balance_transaction
id - Str - balance transaction ID to retrieve.
Returns a Net::Stripe::BalanceTransaction
$stripe->get_balance_transaction(id => 'id');
Create a new charge
https://stripe.com/docs/api#create_charge
amount - Int - amount to charge
currency - Str - currency for charge
customer - Net::Stripe::Customer, HashRef or Str - customer to charge - optional
card - Net::Stripe::Card, Net::Stripe::Token, Str or HashRef - card to use - optional
description - Str - description for the charge - optional
metadata - HashRef - metadata for the charge - optional
capture - Bool - optional
statement_description - Str - description for statement - optional
application_fee - Int - optional
Returns Net::Stripe::Charge
$stripe->post_charge(currency => 'USD', amount => 500, customer => 'testcustomer');
Retrieve a charge.
https://stripe.com/docs/api#retrieve_charge
charge_id - Str - charge id to retrieve
Returns Net::Stripe::Charge
$stripe->get_charge(charge_id => 'chargeid');
Refunds a charge
https://stripe.com/docs/api#refund_charge
charge - Net::Stripe::Charge or Str - charge or charge_id to refund
amount - Int - amount to refund in cents, optional
Returns a new Net::Stripe::Refund.
$stripe->refund_charge(charge => $charge, amount => 500);
Returns a Net::Stripe::List object containing Net::Stripe::Charge objects.
https://stripe.com/docs/api#list_charges
created - HashRef - created conditions to match, optional
customer - Net::Stripe::Customer or Str - customer to match
ending_before - Str - ending before condition, optional
limit - Int - maximum number of charges to return, optional
starting_after - Str - starting after condition, optional
Returns a list of Net::Stripe::Charge objects.
$stripe->get_charges(customer => $customer, limit => 5);
Create or update a customer.
https://stripe.com/docs/api#create_customer
customer - Net::Stripe::Customer - existing customer to update, optional
account_balance - Int, optional
card - Net::Stripe::Card, Net::Stripe::Token, Str or HashRef, default card for the customer, optional
coupon - Str, optional
description - Str, optional
email - Str, optional
metadata - HashRef, optional
plan - Str, optional
quantity - Int, optional
trial_end - Int or Str, optional
Returns a Net::Stripe::Customer object
my $customer = $stripe->post_customer(
card => $fake_card,
email => '[email protected]',
description => 'Test for Net::Stripe',
);
Returns the subscriptions for a customer
https://stripe.com/docs/api#list_subscriptions
customer - Net::Stripe::Customer or Str
ending_before - Str, optional
limit - Int, optional
starting_after - Str, optional
Returns a list of Net::Stripe::Subscription objects
Retrieve a customer
https://stripe.com/docs/api#retrieve_customer
customer_id - Str - the customer id to retrieve
Returns a Net::Stripe::List object containing Net::Stripe::Customer objects.
$stripe->get_customer(customer_id => $id);
Delete a customer
https://stripe.com/docs/api#delete_customer
customer - Net::Stripe::Customer or Str - the customer to delete
Returns a Net::Stripe::Customer object
$stripe->delete_customer(customer => $customer);
Returns a list of customers.
https://stripe.com/docs/api#list_customers
created - HashRef - created conditions, optional
ending_before - Str, optional
limit - Int, optional
starting_after - Str, optional
Returns a Net::Stripe::List object containing Net::Stripe::Customer objects.
$stripe->get_customers(limit => 7);
Retrieve information about a customer's card.
https://stripe.com/docs/api#retrieve_card
customer - Net::Stripe::Customer or Str - the customer
card_id - Str - the card ID to retrieve
Returns a Net::Stripe::Card
$stripe->get_card(customer => 'customer_id', card_id => 'abcdef');
Create or update a card
https://stripe.com/docs/api#create_card
customer - Net::Stripe::Customer or Str
card - Net::Stripe::Card or HashRef
Returns a Net::Stripe::Card
$stripe->create_card(customer => $customer, card => $card);
Returns a list of cards
https://stripe.com/docs/api#list_cards
customer - Net::Stripe::Customer or Str
ending_before - Str, optional
limit - Int, optional
starting_after - Str, optional
Returns a Net::Stripe::List object containing Net::Stripe::Card objects.
$stripe->list_cards(customer => 'abcdec', limit => 10);
Delete a card.
https://stripe.com/docs/api#delete_card
customer - Net::Stripe::Customer or Str
card - Net::Stripe::Card or Str
Returns a Net::Stripe::Card.
$stripe->delete_card(customer => $customer, card => $card);
Adds or updates a subscription for a customer.
https://stripe.com/docs/api#create_subscription
customer - Net::Stripe::Customer
subscription - Net::Stripe::Subscription or Str
card - Net::Stripe::Card, Net::Stripe::Token, Str or HashRef, default card for the customer, optional
coupon - Str, optional
description - Str, optional
plan - Str, optional
quantity - Int, optional
trial_end - Int, or Str optional
application_fee_percent - Int, optional
prorate - Bool, optional
Returns a Net::Stripe::Customer object
$stripe->post_subscription(customer => $customer, plan => 'testplan');
Returns a customers subscription
customer - Net::Stripe::Customer or Str
Returns a Net::Stripe::Subscription
$stripe->get_subscription(customer => 'test123');
Cancel a customer's subscription
https://stripe.com/docs/api#cancel_subscription
customer - Net::Stripe::Customer or Str
subscription - Net::Stripe::Subscription or Str
at_period_end - Bool, optional
Returns a Net::Stripe::Subscription object.
$stripe->delete_subscription(customer => $customer, subscription => $subscription);
Create a new token
https://stripe.com/docs/api#create_card_token
- card - Net::Stripe::Card or HashRef
Returns a Net::Stripe::Token
$stripe->post_token(card => $test_card);
Retreives an existing token.
https://stripe.com/docs/api#retrieve_token
token_id - Str
Returns a Net::Stripe::Token
$stripe->get_token(token_id => 'testtokenid');
Create a new plan
https://stripe.com/docs/api#create_plan
id - Str - identifier of the plan
amount - Int - cost of the plan in cents
currency - Str
interval - Str
interval_count - Int - optional
name - Str - name of the plan
trial_period_days - Int - optional
statement_description - Str - optional
Returns a Net::Stripe::Plan object
$stripe->post_plan(
id => "free-$future_ymdhms",
amount => 0,
currency => 'usd',
interval => 'year',
name => "Freeplan $future_ymdhms",
);
Retrieves a plan.
plan_id - Str
Returns a Net::Stripe::Plan
$stripe->get_plan(plan_id => 'plan123');
Delete a plan.
https://stripe.com/docs/api#delete_plan
plan_id - Net::Stripe::Plan or Str
Returns a Net::Stripe::Plan object
$stripe->delete_plan(plan_id => $plan);
Return a list of Plans
https://stripe.com/docs/api#list_plans
ending_before - Str, optional
limit - Int, optional
starting_after - Str, optional
Returns a Net::Stripe::List object containing Net::Stripe::Plan objects.
$stripe->get_plans(limit => 10);
Create or update a coupon
https://stripe.com/docs/api#create_coupon
id - Str, optional
duration - Str
amount_offset - Int, optional
currency - Str, optional
duration_in_months - Int, optional
max_redemptions - Int, optional
metadata - HashRef, optional
percent_off - Int, optional
redeem_by - Int, optional
Returns a Net::Stripe::Coupon object.
$stripe->post_coupon(
id => $coupon_id,
percent_off => 100,
duration => 'once',
max_redemptions => 1,
redeem_by => time() + 100,
);
Retreive a coupon
https://stripe.com/docs/api#retrieve_coupon
coupon_id - Str
Returns a Net::Stripe::Coupon object.
$stripe->get_coupon(coupon_id => 'id');
Delete a coupon
https://stripe.com/docs/api#delete_coupon
coupon_id - Str
Returns a Net::Stripe::Coupon
$stripe->delete_coupon(coupon_id => 'coupon123');
ending_before - Str, optional
limit - Int, optional
starting_after - Str, optional
Returns a Net::Stripe::List object containing Net::Stripe::Coupon objects.
$stripe->get_coupons(limit => 15);
Update an invoice
invoice - Net::Stripe::Invoice, Str
application_fee - Int - optional
closed - Bool - optional
description - Str - optional
metadata - HashRef - optional
Returns a Net::Stripe::Invoice
$stripe->post_invoice(invoice => $invoice, closed => 'true')
invoice_id - Str
Returns a Net::Stripe::Invoice
$stripe->get_invoice(invoice_id => 'testinvoice');
invoice_id - Str
Returns a Net::Stripe::Invoice
$stripe->pay_invoice(invoice_id => 'testinvoice');
Returns a list of invoices
https://stripe.com/docs/api#list_customer_invoices
customer - Net::Stripe::Customer or Str, optional
date - Int or HashRef, optional
ending_before - Str, optional
limit - Int, optional
starting_after - Str, optional
Returns a Net::Stripe::List object containing Net::Stripe::Invoice objects.
$stripe->get_invoices(limit => 10);
Create a new invoice
https://stripe.com/docs/api#create_invoice
customer - Net::Stripe::Customer, Str
application_fee - Int - optional
description - Str - optional
metadata - HashRef - optional
subscription - Net::Stripe::Subscription or Str, optional
Returns a Net::Stripe::Invoice
$stripe->create_invoice(customer => 'custid', description => 'test');
invoice_id - Str
Returns a Net::Stripe::Invoice
$stripe->get_invoice(invoice_id => 'test');
customer, Net::Stripe::Cusotmer or Str
Returns a Net::Stripe::Invoice
$stripe->get_upcominginvoice(customer => $customer);
Create an invoice item.
https://stripe.com/docs/api#create_invoiceitem
customer - Net::Stripe::Customer or Str
amount - Int
currency - Str
invoice - Net::Stripe::Invoice or Str, optional
subscription - Net::Stripe::Subscription or Str, optional
description - Str, optional
metadata - HashRef, optional
Returns a Net::Stripe::Invoiceitem object
$stripe->create_invoiceitem(customer => 'test', amount => 500, currency => 'USD');
Update an invoice item.
https://stripe.com/docs/api#create_invoiceitem
invoice_item - Net::Stripe::Invoiceitem or Str
amount - Int, optional
description - Str, optional
metadata - HashRef, optional
Returns a Net::Stripe::Invoiceitem
$stripe->post_invoiceitem(invoice_item => 'itemid', amount => 750);
Retrieve an invoice item.
invoice_item - Str
Returns a Net::Stripe::Invoiceitem
$stripe->get_invoiceitem(invoice_item => 'testitemid');
Delete an invoice item
invoice_item - Net::Stripe::Invoiceitem or Str
Returns a Net::Stripe::Invoiceitem
$stripe->delete_invoiceitem(invoice_item => $invoice_item);
customer - Net::Stripe::Customer or Str, optional
date - Int or HashRef, optional
ending_before - Str, optional
limit - Int, optional
starting_after - Str, optional
Returns a Net::Stripe::List object containing Net::Stripe::Invoiceitem objects.
$stripe->get_invoiceitems(customer => 'test', limit => 30);
=discount_method delete_customer_discount
Deleting a Customer-wide Discount
https://stripe.com/docs/api/curl#delete_discount
customer - Net::Stripe::Customer or Str - the customer with a discount to delete
$stripe->delete_customer_discount(customer => $customer);
returns hashref of the form
{
deleted => <bool>
}
https://stripe.com, https://stripe.com/docs/api
Luke Closs
Rusty Conover
Andrew Solomon <[email protected]>
Sachin Sebastian <[email protected]>
Tom Eliaz <[email protected]>
Brian Collins <[email protected]>
Devin M. Certas <[email protected]>
Dimitar Petrov <[email protected]>
Dylan Reinhold <[email protected]>
Hermann Calabria <[email protected]>
Jonathan "Duke" Leto <[email protected]>
Luke Closs <[email protected]>
Olaf Alders <[email protected]>
Rusty Conover <[email protected]>
This software is copyright (c) 2011 by Prime Radiant, Inc., (c) copyright 2014 Lucky Dinosaur LLC..
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.