forked from thenbrent/paypal-digital-goods-php-examples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
return.php
55 lines (48 loc) · 2.66 KB
/
return.php
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
<?php
require_once( 'functions.php' );
?>
<html>
<head>
<title>PayPal Recurring Payments Return Page</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div class="container">
<h2>PayPal Recurring Payments Demo</h2>
<?php // Returning from PayPal & Payment Cancelled ?>
<?php if( isset( $_GET['paypal'] ) && $_GET['paypal'] == 'cancel' ) : ?>
<script>if (window!=top) {top.location.replace(document.location);}</script>
<p>Your subscription has been cancelled. <a href="<?php echo get_script_uri(); ?>" target="_top">Try again? »</a></p>
<?php // Returning from PayPal & Payment Authorised ?>
<?php elseif( isset( $_GET['paypal'] ) && $_GET['paypal'] == 'paid' ) :
// Process the payment or start the Subscription
if( isset( $_GET['PayerID'] ) ) {
$paypal = create_example_purchase();
$response = $paypal->process_payment();
} else {
$paypal = create_example_subscription();
$response = $paypal->start_subscription();
}
?>
<h3>Payment Complete!</h3>
<?php if( isset( $_GET['PayerID'] ) ) { ?>
<p>Your Transaction ID is <?php echo $response['PAYMENTINFO_0_TRANSACTIONID']; ?></p>
<p>You can use this Transaction ID to see the details of your subscription like so:</p>
<pre><code>get_transaction_details( $response['PAYMENTINFO_0_TRANSACTIONID'] );</code></pre>
<p><a href="<?php echo get_script_uri( 'check-profile.php?transaction_id=' . urlencode($response['PAYMENTINFO_0_TRANSACTIONID']) ) ?>" target="_top">View Transaction Details »</a></p>
<?php } else { ?>
<p>Your Payment Profile ID is <?php echo $response['PROFILEID']; ?></p>
<p>You can use this Profile ID to see the details of your subscription like so:</p>
<pre><code>$paypal->get_profile_details('<?php echo $response['PROFILEID']; ?>');</code></pre>
<p><a href="<?php echo get_script_uri( 'check-profile.php?profile_id=' . urlencode($response['PROFILEID']) ) ?>" target="_top">Check Profile »</a></p>
<p>You can use suspend this subscription like this:</p>
<pre><code>$paypal->manage_subscription_status('<?php echo $response['PROFILEID']; ?>', 'Suspend');</code></pre>
<p><a href="<?php echo get_script_uri( 'check-profile.php?profile_id=' . urlencode($response['PROFILEID']) . '&action=suspend' ) ?>" target="_top">Suspend »</a></p>
<p>Or permanently cancel it like this:</p>
<pre><code>$paypal->manage_subscription_status('<?php echo $response['PROFILEID']; ?>', 'Cancel');</code></pre>
<p><a href="<?php echo get_script_uri( 'check-profile.php?profile_id=' . urlencode($response['PROFILEID']) . '&action=cancel' ) ?>" target="_top">Cancel »</a></p>
<?php } ?>
<?php endif; ?>
</div>
</body>
</html>