This is an automated email from the git hooks/post-receive script. js pushed a commit to annotated tag debian/1.163200-1 in repository libmagpie-perl.
commit 3552b15ca36233849d97fad1782f283f8400b8c4 Author: Chris Prather <[email protected]> Date: Fri Feb 21 20:55:09 2014 -0500 add a Stripe input transformer --- lib/Magpie/Transformer/Input/Stripe.pm | 59 ++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/lib/Magpie/Transformer/Input/Stripe.pm b/lib/Magpie/Transformer/Input/Stripe.pm new file mode 100644 index 0000000..05148ba --- /dev/null +++ b/lib/Magpie/Transformer/Input/Stripe.pm @@ -0,0 +1,59 @@ +package Magpie::Transformer::Input::Stripe; +use Moose; +extends qw(Magpie::Transformer); +use Magpie::Constants; +use Net::Stripe; + +__PACKAGE__->register_events(qw(transform)); +sub load_queue { return qw(transform) } + +has stripe => ( + isa => 'Net::Stripe', + is => 'ro', + lazy => 1, + builder => '_build_stripe' + +); + +sub _build_stripe { + my $self = shift; + try { + $self->resolve_asset(service => 'stripe'); + } catch { + try { + my $api_key = $self->resolve_asset($api_key); + Net::Stripe->new( api_key => $api_key); + } + catch { + $self->set_error({status_code => 500, reason => "Couldn't find stripe service or API key"); + } + }; +} + +sub transform { + my $self = shift; + my $ctxt = shift; + my $data = $self->resource->data // $ctxt->{data}; + return SERVER_ERROR unless $data; + unless (defined $data->{stripeToken}) { + $self->set_error( { status_code => 402, reason => 'No stripeToken found'} ); + return DONE; + try { + my $desc = "Payment for $$data{resourceName}: $$data{student}{name}"; + $self->stripe->post_charge( + amount => $data->{amount}, + currency => 'usd', + card => $data->{stripeToken}, + description => $desc, + ); + return OK; + } + catch { + $self->set_error( { status_code => 400, reason => $_ } ); + return DECLINED; + }; + +} + +1; +__END__ -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmagpie-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits
