Giter VIP home page Giter VIP logo

business-stripe's Introduction

Business::Stripe

This module provides common Perl 5 bindings to the Stripe payment system with minimal dependencies and overhead.

Any API calls that do not have bindings can be easily accessed through the generic api method.

Basic Usage

    my $stripe = Business::Stripe->new(
        -api_key => 'your-api-key-here',
    );

    ## get the payment token from Stripe.js, then:
    my $success = $stripe->charges_create(
        amount         => 400,  # in cents
        source         => $token_from_stripe_js,
        description    => 'Ice cream'
    );

    if ($success) {
        return $stripe->success();  # <-- the returned JSON structure
    }
    else {
        die $stripe->error->{message};
    }

    my $customer = $stripe->api('post', 'customers',
        email       => '[email protected]',
        name        => 'Jane S. Customer',
        description => 'Displayed alongside the customer on your dashboard',
        source      => $token_id,
    ) and $stripe->success;
    die $stripe->error unless $customer;

Please refer to Business::Stripe's complete documentation for more examples and thorough documentation. After installation, the same documentation may be accessed on your terminal by typing:

perldoc Business::Stripe

on your terminal.

Installation

To install this module via cpanm:

> cpanm Business::Stripe

Or, at the cpan shell:

cpan> install Business::Stripe

If you wish to install it manually, download and unpack the tarball and run the following commands:

perl Makefile.PL
make
make test
make install

Of course, instead of downloading the tarball you may simply clone the git repository:

$ git clone git://github.com/aquaron/Business-Stripe.git

Finally, you can also just download Stripe.pm and include it as part of your distribution (though in this case you should probably rename it to something like BusinessStripe.pm).

LICENSE AND COPYRIGHT

Copyright (C) 2012-2019 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 5 itself.

See http://dev.perl.org/licenses/ for more information.

business-stripe's People

Contributors

brianhorakh avatar garu avatar ibrierley avatar mstevens avatar ohkneebee avatar pham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

business-stripe's Issues

add support for Business::OnlinePayment

@ivanfreeside asked on RT:


It would be nice if Business::Stripe worked with the Perl standard for
credit card processors, Business::OnlinePayment. Right now
Business::Stripe is kind-of like havin a database driver that doesn't
work with DBI.

We are of course aware that tokenization and recurring payments are a
new part of the base B:OP API and are definitely willing to work with
you to extend and standardize that base API for your needs. See the
AuthorizeNet, PayflowPro and CardFortress modules for examples of
modules that provide similar features.

This is of course a wishlist "bug". :)

Ivan Kohler
Business::OnlinePayment maintainer

Add support for idempotent requests..

Stripe can support Idempotent requests, i.e https://stripe.com/docs/api/idempotent_requests

I was looking at maybe adding this, but I'm wondering about best place in the code for it to hang (that's if its wanted). As it needs to turn into a header, the current header code looks for the Stripe objects longer term api credentials and things like that, but I guess someone may want to add idempotency for a charge, but not something else, so feels like it has to be a per call addition.

We could add an add_headers(hashref) method which gets stored in $self->{headers}, adds them in _compose to @headers, then undeffed ? Any other thoughts ?

Currency parameter from documentation example creating tokens throws an API error

In the documentation for creating a token with the following example:

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

The currency parameter throws the following error:

{
  error: 
  {
    type: "invalid_request_error",
    message: "Received unknown parameter: currency",
    param: "currency"
  },
}

Removing the currency parameter works as expected.

add helpers for Stripe's Payment Intent endpoints (EU regulation)

Hi, my understanding is that Stripe will be changing and using things like payment intents (e.g https://stripe.com/docs/payments/payment-intents ) to support SCA (Strong Customer Authentication) https://stripe.com/docs/strong-customer-authentication/migration#sca-updates

I'm a little confused as to whether Business::Stripe will continue to work.

Does anyone know if it will continue to work and be unaffected, or whether there will need to be some code changes ?

Allow POST requests without content

The _compose method decides the user wants to POST based on the amount of content params being passed in, not on the user specifying they want to POST.

    if ($_[0] and $_[0] eq 'delete') {
        $res = $self->{-ua}->request(
            DELETE $url, @headers
        );
    } elsif (scalar @_ > 1 || (@_ == 1 && ref $_[0] eq 'ARRAY')) {
        $res = $self->{-ua}->request(
            POST $url, @headers, Content => [ @_ == 1 ? @{$_[0]} : @_ ]
        );
    } else {
        $res = $self->{-ua}->request(
            GET $url, @headers
        );
    }

This means the following request is interpreted as a GET request, regardless of specifically saying I want a POST.

    my $id = $stripe->api( 'post', "payment_intents/$payment_intent_id/capture" );

I can trick the logic to POST by passing in an empty arrayref.

    my $id = $stripe->api( 'post', "payment_intents/$payment_intent_id/capture", [] );

but I shouldn't need to, it should do a POST if I told it to do a POST. Stripe's API allows POST without content, so the client should also.

I may have time to create a pull request later to fix this, with the goal of also retaining the fallback behavior of "do what I mean." But this issue is a request to change the behavior.

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.