7 use vars qw/ @ISA @EXPORT /;
16 use Business::OnlinePayment;
26 Common helper methods for all test units
28 =head1 BAMBORA DEVELOPER ACCOUNT
30 Do not use live credentials with these test units. Bambora
31 provides no way to specifiy a test payment gateway. They issue
32 test accounts instead. See L<https://dev.na.bambora.com>
36 # set environment variables with credentials
37 export BAMBORA_MERCHANT_ID=8675309
38 export BAMBORA_API_KEY=XOXOXOXOXOXOXOX
44 prove -lv t/031-payments-card-normal-authorizaiton.t
50 A basic Business::OnlinePayment content hash, containing a
51 valid Bambora test card number, with Bambora's specified
52 correct billing address for their test cards
54 See L<https://dev.na.bambora.com/docs/references/payment_APIs/test_cards>
60 #action => 'Normal Authorization',
64 owner => 'Business OnlinePayment',
65 name => 'Mitch Jackson',
66 address => '1407 Graymalkin Lane',
72 invoice_number => time(),
73 card_number => '4030000010001234',
76 phone => '251-300-1300',
77 email => 'mitch@freeside.biz',
81 =head2 inspect_response $response, \%expect, \@expect
83 Given $response, a decoded json api response, check the
84 response contains the keys/value defined in %expect, and
85 that response keys exist for keynames defined in @expect
89 sub inspect_response {
90 no warnings 'uninitialized';
93 my $expect_href = shift || {};
94 my $expect_aref = shift || [];
96 die 'Expected $response hashref parameter'
99 for my $k ( keys %{$expect_href} ) {
101 $response->{$k} eq $expect_href->{$k},
102 sprintf '$response->%s: %s eq %s',
109 for my $k ( @{$expect_aref} ) {
111 defined $response->{$k},
112 sprintf '$response->%s defined: %s',
118 =head2 inspect_transaction $transaction, \%expect, \@expect
120 Given a B::OP $tr, call methods defined as keys within %expect,
121 and validate the returned values match the values in %expect.
122 Check the methods defined in @expect return true values
126 sub inspect_transaction {
127 no warnings 'uninitialized';
129 my $expect_href = shift || {};
130 my $expect_aref = shift || [];
132 die 'Expected $tr B::OP transaction parameter'
135 for my $k ( keys %{$expect_href} ) {
137 $tr->can($k) && $tr->$k() eq $expect_href->{$k},
138 sprintf '$tr->%s: %s eq %s',
140 $tr->can($k) ? $tr->$k() : 'METHOD MISSING',
145 for my $k ( @{$expect_aref} ) {
147 $tr->can($k) && defined $tr->$k(),
148 sprintf '$tr->%s defined: %s',
150 $tr->can($k) ? $tr->$k() : 'METHOD MISSING',
156 =head2 make_api_request \%content
158 Given a %content href, create a B::OP transaction and submit it
160 Returns the transaction object, and the decoded json response
164 sub make_api_request {
166 die 'expected href' unless ref $content;
169 ok( $tr = Business::OnlinePayment->new('Bambora'), 'Instantiatiate transaction' );
170 ok( $tr->content( %$content ), 'Hand %content to transaction' );
173 eval { $tr->submit };
174 ok( !$@, "Submit request to create Payment Profile, action: $content->{action}" );
183 my $response = $tr->response_decoded || {};
185 return ( $tr, $response );