summaryrefslogtreecommitdiff
path: root/InternetSecure.pm
diff options
context:
space:
mode:
authorfbriere <fbriere>2006-02-18 00:26:11 +0000
committerfbriere <fbriere>2006-02-18 00:26:11 +0000
commit227f87ababc68077ac00d2fb5ee52f080370cbff (patch)
treea81ffbbde08049285679dffcfd67108f3efb368d /InternetSecure.pm
parent2fcb22b534898f165cddcbbf8822020e77c8f248 (diff)
Added taxes()
Diffstat (limited to 'InternetSecure.pm')
-rwxr-xr-xInternetSecure.pm37
1 files changed, 31 insertions, 6 deletions
diff --git a/InternetSecure.pm b/InternetSecure.pm
index 10d7d6e..a7b1d0f 100755
--- a/InternetSecure.pm
+++ b/InternetSecure.pm
@@ -42,9 +42,12 @@ sub set_defaults {
receipt_number sales_number uuid guid
date
card_type cardholder
- total_amount
+ total_amount taxes
avs_response cvv2_response
));
+
+ # Just in case someone tries to call taxes() *before* submit()
+ $self->taxes( {} );
}
# OnlinePayment's get_fields now filters out undefs in 3.x. :(
@@ -223,6 +226,27 @@ sub infuse {
}
}
+sub extract_taxes {
+ my ($self, $response) = @_;
+
+ my %taxes;
+
+ my $products = $response->{Products};
+ return unless $products;
+
+ foreach my $node (@$products) {
+ my $flags = $node->{flags};
+ if ($flags &&
+ grep($_ eq '{TAX}', @$flags) &&
+ grep($_ eq '{CALCULATED}', @$flags))
+ {
+ $taxes{ $node->{code} } = $node->{subtotal};
+ }
+ }
+
+ return %taxes;
+}
+
# Parse the server's response and set various fields
#
sub parse_response {
@@ -267,7 +291,7 @@ sub parse_response {
$self->card_type(CARD_TYPES->{$self->card_type});
- $self->{products_raw} = $response->{Products};
+ $self->taxes( { $self->extract_taxes($response) } );
return $self;
}
@@ -513,6 +537,11 @@ Date and time of the transaction. Format is C<YYYY/MM/DD hh:mm:ss>.
Total amount billed for this order, including taxes.
+=item taxes()
+
+Returns a I<reference> to a hash that maps tax names (such as C<GST>) to the
+amount that was billed for each.
+
=item cardholder()
Cardholder's name. This is currently a mere copy of the B<name> field passed
@@ -535,10 +564,6 @@ following:
=back
-=item products_raw()
-
-...
-
=back