File Coverage

blib/lib/Net/Braintree/Transaction.pm
Criterion Covered Total %
statement 18 65 27.6
branch 0 10 0.0
condition n/a
subroutine 6 22 27.2
pod 0 16 0.0
total 24 113 21.2


line stmt bran cond sub pod time code
1             package Net::Braintree::Transaction;
2 1     1   297 use Net::Braintree::Transaction::CreatedUsing;
  1         1  
  1         23  
3 1     1   396 use Net::Braintree::Transaction::EscrowStatus;
  1         3  
  1         34  
4 1     1   460 use Net::Braintree::Transaction::Source;
  1         1  
  1         27  
5 1     1   315 use Net::Braintree::Transaction::Status;
  1         2  
  1         23  
6 1     1   336 use Net::Braintree::Transaction::Type;
  1         3  
  1         26  
7              
8 1     1   4 use Moose;
  1         1  
  1         7  
9             extends "Net::Braintree::ResultObject";
10             my $meta = __PACKAGE__->meta;
11              
12             sub BUILD {
13 0     0 0   my ($self, $attributes) = @_;
14 0           my $sub_objects = { 'disputes' => 'Net::Braintree::Dispute'};
15 0           $meta->add_attribute('subscription', is => 'rw');
16 0 0         $self->subscription(Net::Braintree::Subscription->new($attributes->{subscription})) if ref($attributes->{subscription}) eq 'HASH';
17 0           delete($attributes->{subscription});
18 0           $meta->add_attribute('disbursement_details', is => 'rw');
19 0 0         $self->disbursement_details(Net::Braintree::DisbursementDetails->new($attributes->{disbursement_details})) if ref($attributes->{disbursement_details}) eq 'HASH';
20 0           delete($attributes->{disbursement_details});
21              
22 0           $meta->add_attribute('paypal_details', is => 'rw');
23 0 0         $self->paypal_details(Net::Braintree::PayPalDetails->new($attributes->{paypal})) if ref($attributes->{paypal}) eq 'HASH';
24 0           delete($attributes->{paypal});
25              
26 0           $self->setup_sub_objects($self, $attributes, $sub_objects);
27 0           $self->set_attributes_from_hash($self, $attributes);
28             }
29              
30             sub sale {
31 0     0 0   my ($class, $params) = @_;
32 0           $class->create($params, 'sale');
33             }
34              
35             sub credit {
36 0     0 0   my ($class, $params) = @_;
37 0           $class->create($params, 'credit');
38             }
39              
40             sub submit_for_settlement {
41 0     0 0   my ($class, $id, $amount) = @_;
42 0           my $params = {};
43 0 0         $params->{'amount'} = $amount if $amount;
44 0           $class->gateway->transaction->submit_for_settlement($id, $params);
45             }
46              
47             sub void {
48 0     0 0   my ($class, $id) = @_;
49 0           $class->gateway->transaction->void($id);
50             }
51              
52             sub refund {
53 0     0 0   my ($class, $id, $amount) = @_;
54 0           my $params = {};
55 0 0         $params->{'amount'} = $amount if $amount;
56 0           $class->gateway->transaction->refund($id, $params);
57             }
58              
59             sub create {
60 0     0 0   my ($class, $params, $type) = @_;
61 0           $params->{'type'} = $type;
62 0           $class->gateway->transaction->create($params);
63             }
64              
65             sub find {
66 0     0 0   my ($class, $id) = @_;
67 0           $class->gateway->transaction->find($id);
68             }
69              
70             sub search {
71 0     0 0   my ($class, $block) = @_;
72 0           $class->gateway->transaction->search($block);
73             }
74              
75             sub hold_in_escrow {
76 0     0 0   my ($class, $id) = @_;
77 0           $class->gateway->transaction->hold_in_escrow($id);
78             }
79              
80             sub release_from_escrow {
81 0     0 0   my ($class, $id) = @_;
82 0           $class->gateway->transaction->release_from_escrow($id);
83             }
84              
85             sub cancel_release {
86 0     0 0   my ($class, $id) = @_;
87 0           $class->gateway->transaction->cancel_release($id);
88             }
89              
90             sub all {
91 0     0 0   my $class = shift;
92 0           $class->gateway->transaction->all;
93             }
94              
95             sub clone_transaction {
96 0     0 0   my ($class, $id, $params) = @_;
97 0           $class->gateway->transaction->clone_transaction($id, $params);
98             }
99              
100             sub gateway {
101 0     0 0   Net::Braintree->configuration->gateway;
102             }
103              
104             sub is_disbursed {
105 0     0 0   my $self = shift;
106 0           $self->disbursement_details->is_valid();
107             };
108              
109             1;