| 1 | package Business::CPI::Gateway::Test; | ||||||||||
| 2 | # ABSTRACT: Fake gateway | ||||||||||
| 3 | |||||||||||
| 4 | 6 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 6 | our $VERSION = '0.924'; # VERSION | |||||||||
| 7 | |||||||||||
| 8 | 6 | extends 'Business::CPI::Gateway::Base'; | |||||||||
| 9 | 6 | with 'Business::CPI::Role::Gateway::FormCheckout'; | |||||||||
| 10 | |||||||||||
| 11 | 3 | ▶ | sub get_hidden_inputs { | ||||||||
|
Subroutine
get_hidden_inputs: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||
| 12 | 3 | my ( $self, $info ) = @_; | |||||||||
| 13 | |||||||||||
| 14 | 3 | my $buyer = $info->{buyer}; | |||||||||
| 15 | 3 | my $cart = $info->{cart}; | |||||||||
| 16 | |||||||||||
| 17 | my @hidden_inputs = ( | ||||||||||
| 18 | receiver_email => $self->receiver_id, | ||||||||||
| 19 | currency => $self->currency, | ||||||||||
| 20 | encoding => $self->form_encoding, | ||||||||||
| 21 | payment_id => $info->{payment_id}, | ||||||||||
| 22 | 3 | buyer_name => $buyer->name, | |||||||||
| 23 | buyer_email => $buyer->email, | ||||||||||
| 24 | ); | ||||||||||
| 25 | |||||||||||
| 26 | 3 | my %buyer_extra = ( | |||||||||
| 27 | address_line1 => 'shipping_address', | ||||||||||
| 28 | address_line2 => 'shipping_address2', | ||||||||||
| 29 | address_city => 'shipping_city', | ||||||||||
| 30 | address_state => 'shipping_state', | ||||||||||
| 31 | address_country => 'shipping_country', | ||||||||||
| 32 | address_zip_code => 'shipping_zip', | ||||||||||
| 33 | ); | ||||||||||
| 34 | |||||||||||
| 35 | 3 | for (keys %buyer_extra) { | |||||||||
| 36 | 18 | ▶ | if (my $value = $buyer->$_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 11 | push @hidden_inputs, ( $buyer_extra{$_} => $value ); | |||||||||
| 38 | } | ||||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 3 | my %cart_extra = ( | |||||||||
| 42 | discount => 'discount_amount', | ||||||||||
| 43 | handling => 'handling_amount', | ||||||||||
| 44 | tax => 'tax_amount', | ||||||||||
| 45 | ); | ||||||||||
| 46 | |||||||||||
| 47 | 3 | for (keys %cart_extra) { | |||||||||
| 48 | 9 | ▶ | if (my $value = $cart->$_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 9 | push @hidden_inputs, ( $cart_extra{$_} => $value ); | |||||||||
| 50 | } | ||||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 3 | my $i = 1; | |||||||||
| 54 | |||||||||||
| 55 | 3 | foreach my $item (@{ $info->{items} }) { | |||||||||
| 56 | 6 | push @hidden_inputs, | |||||||||
| 57 | ( | ||||||||||
| 58 | "item${i}_id" => $item->id, | ||||||||||
| 59 | "item${i}_desc" => $item->description, | ||||||||||
| 60 | "item${i}_price" => $item->price, | ||||||||||
| 61 | "item${i}_qty" => $item->quantity, | ||||||||||
| 62 | ); | ||||||||||
| 63 | |||||||||||
| 64 | 6 | ▶ | if (my $weight = $item->weight) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | 1 | push @hidden_inputs, ( "item${i}_weight" => $weight * 1000 ); # show in grams | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 6 | ▶ | if (my $ship = $item->shipping) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | 1 | push @hidden_inputs, ( "item${i}_shipping" => $ship ); | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 6 | ▶ | if (my $ship = $item->shipping_additional) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | 1 | push @hidden_inputs, ( "item${i}_shipping2" => $ship ); | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | 6 | $i++; | |||||||||
| 77 | } | ||||||||||
| 78 | |||||||||||
| 79 | 3 | $i = 1; | |||||||||
| 80 | |||||||||||
| 81 | 3 | foreach my $receiver (@{ $cart->_receivers }) { | |||||||||
| 82 | 2 | push @hidden_inputs, | |||||||||
| 83 | ( | ||||||||||
| 84 | "receiver${i}_id" => $receiver->account->gateway_id, | ||||||||||
| 85 | "receiver${i}_percent" => sprintf("%.2f", 0+$receiver->percent_amount), | ||||||||||
| 86 | ); | ||||||||||
| 87 | 2 | $i++; | |||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | 3 | return @hidden_inputs; | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | # TODO | ||||||||||
| 94 | # use SQLite? | ||||||||||
| 95 | # sub get_notification_details {} | ||||||||||
| 96 | # sub query_transactions {} | ||||||||||
| 97 | # sub get_transaction_details {} | ||||||||||
| 98 | |||||||||||
| 99 | 6 | 1; | |||||||||
| 100 | |||||||||||
| 101 | __END__ | ||||||||||