Git Product home page Git Product logo

stripe-perl's Introduction

NAME

Net::Stripe - API client for Stripe.com

VERSION

version 0.25

SYNOPSIS

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() 

DESCRIPTION

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.

METHODS

new PARAMHASH

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.

ATTRIBUTES

api_base

Reader: api_base

Type: Str

Additional documentation: This is the base part of the URL for every request made

api_key

Reader: api_key

Type: Str

This attribute is required.

Additional documentation: You get this from your Stripe Account settings

debug

Reader: debug

Writer: debug

Type: Bool

Additional documentation: The debug flag

debug_network

Reader: debug_network

Writer: debug_network

Type: Bool

Additional documentation: The debug network request flag

ua

Reader: ua

Type: Object

Additional documentation: The LWP::UserAgent that is used for requests

Balance Transaction Methods

get_balance_transaction

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');

Charge Methods

post_charge

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');

get_charge

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');

refund_charge

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);

get_charges

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);

Customer Methods

post_customer

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',
);

list_subscriptions

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

get_customer

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_customer

Delete a customer

https://stripe.com/docs/api#delete_customer

Returns a Net::Stripe::Customer object

$stripe->delete_customer(customer => $customer);

get_customers

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);

Card Methods

get_card

Retrieve information about a customer's card.

https://stripe.com/docs/api#retrieve_card

Returns a Net::Stripe::Card

$stripe->get_card(customer => 'customer_id', card_id => 'abcdef');

post_card

Create or update a card

https://stripe.com/docs/api#create_card

Returns a Net::Stripe::Card

$stripe->create_card(customer => $customer, card => $card);

get_cards

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_card

Delete a card.

https://stripe.com/docs/api#delete_card

Returns a Net::Stripe::Card.

$stripe->delete_card(customer => $customer, card => $card);

Subscription Methods

post_subscription

Adds or updates a subscription for a customer.

https://stripe.com/docs/api#create_subscription

Returns a Net::Stripe::Customer object

$stripe->post_subscription(customer => $customer, plan => 'testplan');

get_subscription

Returns a customers subscription

Returns a Net::Stripe::Subscription

$stripe->get_subscription(customer => 'test123');

delete_subscription

Cancel a customer's subscription

https://stripe.com/docs/api#cancel_subscription

Returns a Net::Stripe::Subscription object.

$stripe->delete_subscription(customer => $customer, subscription => $subscription);

Token Methods

post_token

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);

get_token

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');

Plan Methods

post_plan

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",
);

get_plan

Retrieves a plan.

  • plan_id - Str

Returns a Net::Stripe::Plan

$stripe->get_plan(plan_id => 'plan123');

delete_plan

Delete a plan.

https://stripe.com/docs/api#delete_plan

Returns a Net::Stripe::Plan object

$stripe->delete_plan(plan_id => $plan);

get_plans

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);

Coupon Methods

post_coupon

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,
);

get_coupon

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_coupon

Delete a coupon

https://stripe.com/docs/api#delete_coupon

  • coupon_id - Str

Returns a Net::Stripe::Coupon

$stripe->delete_coupon(coupon_id => 'coupon123');

get_coupons

  • 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);

Invoice Methods

post_invoice

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')

get_invoice

  • invoice_id - Str

Returns a Net::Stripe::Invoice

$stripe->get_invoice(invoice_id => 'testinvoice');

pay_invoice

  • invoice_id - Str

Returns a Net::Stripe::Invoice

$stripe->pay_invoice(invoice_id => 'testinvoice');

get_invoices

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_invoice

Create a new invoice

https://stripe.com/docs/api#create_invoice

Returns a Net::Stripe::Invoice

$stripe->create_invoice(customer => 'custid', description => 'test');

get_invoice

  • invoice_id - Str

Returns a Net::Stripe::Invoice

$stripe->get_invoice(invoice_id => 'test');

get_upcominginvoice

Returns a Net::Stripe::Invoice

$stripe->get_upcominginvoice(customer => $customer);

Invoice Item Methods

create_invoiceitem

Create an invoice item.

https://stripe.com/docs/api#create_invoiceitem

Returns a Net::Stripe::Invoiceitem object

$stripe->create_invoiceitem(customer => 'test', amount => 500, currency => 'USD');

post_invoiceitem

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);

get_invoiceitem

Retrieve an invoice item.

  • invoice_item - Str

Returns a Net::Stripe::Invoiceitem

$stripe->get_invoiceitem(invoice_item => 'testitemid');

delete_invoiceitem

Delete an invoice item

Returns a Net::Stripe::Invoiceitem

$stripe->delete_invoiceitem(invoice_item => $invoice_item);

get_invoiceitems

  • 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

$stripe->delete_customer_discount(customer => $customer);

returns hashref of the form

{
  deleted => <bool>
}

SEE ALSO

https://stripe.com, https://stripe.com/docs/api

AUTHORS

  • Luke Closs

  • Rusty Conover

CONTRIBUTORS

COPYRIGHT AND LICENSE

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.