File: RecurringPayments.t

package info (click to toggle)
libbusiness-paypal-api-perl 0.69-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 280 kB
  • ctags: 51
  • sloc: perl: 1,856; makefile: 2
file content (123 lines) | stat: -rw-r--r-- 3,394 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# -*- mode: cperl -*-
use Test::More;
if( ! $ENV{WPP_TEST} || ! -f $ENV{WPP_TEST} ) {
    plan skip_all => 'No WPP_TEST env var set. Please see README to run tests';
}
else {
    plan tests => 3;
}

use_ok( 'Business::PayPal::API::RecurringPayments' );
#########################

require 't/API.pl';

my %args = do_args();

my $pp = new Business::PayPal::API::RecurringPayments(%args);

#$Business::PayPal::API::Debug = 1;
my %response = $pp->SetCustomerBillingAgreement
  (
   BillingType => 'RecurringPayments',
   BillingAgreementDescription => '10.00 per month for 1 year',
   ReturnURL  => 'http://www.google.com/',
   CancelURL  => 'http://www.google.com/', 
   BuyerEmail => $args{BuyerEmail},
  );
#$Business::PayPal::API::Debug = 0;

my $token = $response{Token};

ok( $token, "Got token" );
like( $response{Ack}, qr/Success/ , "SetCustomerBillingAgreement successful" );

exit;

die "No token from PayPal! Check your authentication information and try again."
  unless $token;


my $pp_url = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_customer-billing-agreement&token=$token";

=pod

print STDERR <<"_TOKEN_";

Now paste the following URL into your browser (you'll need to have
another browser window already logged into the PayPal developer site):

  $pp_url

Login to PayPal as the Buyer you specified in '$ENV{WPP_TEST}' and
proceed to checkout (this authorizes the transaction represented by
the token). When finished, PayPal will redirect you to a non-existent
URL:

  http://localhost/return.html?token=$token&PayerID=XXXXXXXXXXXXX

Notice the *PayerID* URL argument (XXXXXXXXXXXXX) on the redirect from
PayPal.
_TOKEN_

print STDERR "\nType or paste that PayerID here and hit Enter: \n";

my $payerid = <STDIN>; chomp $payerid;

die "Need a PayerID.\n" unless $payerid;

=cut


## CreateRecurringPaymentsProfile
#$Business::PayPal::API::Debug = 1;
my %profile = $pp->CreateRecurringPaymentsProfile
  ( Token => $token,

    ## RecurringPaymentProfileDetails
    SubscriberName => 'Joe Schmoe',

    SubscriberShipperName            => 'Schmoe House',
    SubscriberShipperStreet1         => '1234 Street St.',
    SubscriberShipperCityName        => 'Orem',
    SubscriberShipperStateOrProvince => 'UT',
    SubscriberShipperPostalCode      => '84222',
    SubscriberShipperCountry         => 'USA',
    SubscriberShipperPhone           => '123-123-1234',

    BillingStartDate => '2009-12-01Z',
    ProfileReference => 'BH12341234',

    ## ScheduleDetails
    Description => '12 Month Hosting Package: We Love You!',

    InitialAmount     => '12.34',

    TrialBillingPeriod      => 'Month',
    TrialBillingFrequency   => 1,
    TrialTotalBillingCycles => 1,
    TrialAmount             => 0.00,
    TrialShippingAmount     => 0.00,
    TrialTaxAmount          => 0.00,

    PaymentBillingPeriod      => 'Year',
    PaymentBillingFrequency   => 1,
    PaymentTotalBillingCycles => 1,
    PaymentAmount             => 95.40,
    PaymentShippingAmount     => 0.00,
    PaymentTaxAmount          => 0.00,

#    MaxFailedPayments         => 1,
#    AutoBillOutstandingAmount => 'AddToNextBilling',
  );

#$Business::PayPal::API::Debug = 0;


## GetBillingAgreementCustomerDetails
#$Business::PayPal::API::Debug = 1;
my %details = $pp->GetBillingAgreementCustomerDetails($token);
#$Business::PayPal::API::Debug = 0;

like( $details{Ack}, qr/Success/ , "details ok" );