Formatting and naming changes in t/SubscriptionPayments.t
This commit is contained in:
		
							parent
							
								
									8b755e0e66
								
							
						
					
					
						commit
						267e814e70
					
				
					 1 changed files with 44 additions and 33 deletions
				
			
		| 
						 | 
					@ -1,8 +1,11 @@
 | 
				
			||||||
# -*- mode: cperl -*-
 | 
					# -*- mode: cperl -*-
 | 
				
			||||||
use Test::More;
 | 
					 | 
				
			||||||
use strict;
 | 
					use strict;
 | 
				
			||||||
 | 
					use warnings;
 | 
				
			||||||
use autodie qw(:all);
 | 
					use autodie qw(:all);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use Cwd;
 | 
					use Cwd;
 | 
				
			||||||
 | 
					use List::AllUtils;
 | 
				
			||||||
 | 
					use Test::More;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
 | 
					if ( !$ENV{WPP_TEST} || !-f $ENV{WPP_TEST} ) {
 | 
				
			||||||
    plan skip_all =>
 | 
					    plan skip_all =>
 | 
				
			||||||
| 
						 | 
					@ -33,7 +36,7 @@ This works, and seems to be correct, albeit odd.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
=cut
 | 
					=cut
 | 
				
			||||||
 | 
					
 | 
				
			||||||
open(SUBSCRIPTION_PAY_HTML, ">", "subscription-payment.html");
 | 
					open SUBSCRIPTION_PAY_HTML, '>', 'subscription-payment.html';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
print SUBSCRIPTION_PAY_HTML <<_SUBSCRIPTION_PAYMENT_DATA_
 | 
					print SUBSCRIPTION_PAY_HTML <<_SUBSCRIPTION_PAYMENT_DATA_
 | 
				
			||||||
<html>
 | 
					<html>
 | 
				
			||||||
| 
						 | 
					@ -58,7 +61,7 @@ print SUBSCRIPTION_PAY_HTML <<_SUBSCRIPTION_PAYMENT_DATA_
 | 
				
			||||||
</html>
 | 
					</html>
 | 
				
			||||||
_SUBSCRIPTION_PAYMENT_DATA_
 | 
					_SUBSCRIPTION_PAYMENT_DATA_
 | 
				
			||||||
    ;
 | 
					    ;
 | 
				
			||||||
close(SUBSCRIPTION_PAY_HTML);
 | 
					close SUBSCRIPTION_PAY_HTML;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
my $cwd = getcwd;
 | 
					my $cwd = getcwd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,36 +76,44 @@ if you haven't made one yet, you can visit:
 | 
				
			||||||
and use the sandbox buyer account to make the payment.
 | 
					and use the sandbox buyer account to make the payment.
 | 
				
			||||||
_PROFILEID_
 | 
					_PROFILEID_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
my $startdate = '1998-01-01T01:45:10.00Z';
 | 
					my $start_date = '1998-01-01T01:45:10.00Z';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
my $ts   = new Business::PayPal::API::TransactionSearch( %args );
 | 
					my $ts = Business::PayPal::API::TransactionSearch->new( %args );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
my $resp = $ts->TransactionSearch(StartDate => $startdate);
 | 
					my $resp = $ts->TransactionSearch( StartDate => $start_date );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ok(scalar @{$resp} > 0, "Some transactions found");
 | 
					ok( scalar @{$resp} > 0, 'Some transactions found' );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					my ( $profileID, %possible_txn_ids );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
my($profileID, %possibleTransactionIDs);
 | 
					 | 
				
			||||||
foreach my $record ( @{$resp} ) {
 | 
					foreach my $record ( @{$resp} ) {
 | 
				
			||||||
    if ( $record->{Type} =~ /Recurring/ ) {
 | 
					    if ( $record->{Type} =~ /Recurring/ ) {
 | 
				
			||||||
        if ( $record->{Status} =~ /Completed/ ) {
 | 
					        if ( $record->{Status} =~ /Completed/ ) {
 | 
				
			||||||
      $possibleTransactionIDs{$record->{TransactionID}} = $record;
 | 
					            $possible_txn_ids{ $record->{TransactionID} } = $record;
 | 
				
			||||||
    } elsif ($record->{Status} =~ /Created/) {
 | 
					        }
 | 
				
			||||||
 | 
					        elsif ( $record->{Status} =~ /Created/ ) {
 | 
				
			||||||
            $profileID = $record->{TransactionID};
 | 
					            $profileID = $record->{TransactionID};
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
ok(defined $profileID, "Subscription Payment Creation Record and ProfileID Found");
 | 
					 | 
				
			||||||
ok(scalar(keys %possibleTransactionIDs) > 0, "Subscription Payment Transactions Found");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
$resp = $ts->TransactionSearch(StartDate => $startdate,
 | 
					ok( defined $profileID,
 | 
				
			||||||
                               ProfileID => $profileID);
 | 
					    'Subscription Payment Creation Record and ProfileID Found' );
 | 
				
			||||||
 | 
					ok( scalar keys %possible_txn_ids > 0,
 | 
				
			||||||
 | 
					    'Subscription Payment Transactions Found'
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
my $foundAtLeastOne = 0;
 | 
					my $date_search_res = $ts->TransactionSearch(
 | 
				
			||||||
foreach my $record (@{$resp}) {
 | 
					    ProfileID => $profileID,
 | 
				
			||||||
  # One of these will need to be in the possibleTransactionID list (i.e.,
 | 
					    StartDate => $start_date,
 | 
				
			||||||
  # we're assuming that at least one payment has occured in this repeating).
 | 
					);
 | 
				
			||||||
  if (defined $possibleTransactionIDs{$record->{TransactionID}}) {
 | 
					
 | 
				
			||||||
    $foundAtLeastOne = 1; last;
 | 
					# One of these will need to be in the possibleTransactionID list (i.e., we're
 | 
				
			||||||
 | 
					# assuming that at least one payment has occured in this repeating).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ok( List::AllUtils::any {
 | 
				
			||||||
 | 
					        defined $possible_txn_ids{ $_->{TransactionID} }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					    @{$date_search_res},
 | 
				
			||||||
ok($foundAtLeastOne, "Found one payment transaction under the given Profile ID");
 | 
					    'Found one payment transaction under the given Profile ID'
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue