forked from LiveCarta/PayPal-PHP-SDK
Updates to LIPP & Future Payments
- Updated LIPP Sample code - Updated Future Payments to have helper functions for retrieving access token - Updated Logging Syntax to include timestamp and response json
This commit is contained in:
@@ -1,40 +1,42 @@
|
||||
<?php
|
||||
// #Execute Payment Sample
|
||||
// This sample shows how you can complete
|
||||
// a payment that has been approved by
|
||||
// the buyer by logging into paypal site.
|
||||
// You can optionally update transaction
|
||||
// information by passing in one or more transactions.
|
||||
// API used: POST '/v1/payments/payment/<payment-id>/execute'.
|
||||
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
use PayPal\Api\ExecutePayment;
|
||||
use PayPal\Api\Payment;
|
||||
use PayPal\Api\PaymentExecution;
|
||||
session_start();
|
||||
if(isset($_GET['success']) && $_GET['success'] == 'true') {
|
||||
|
||||
// Get the payment Object by passing paymentId
|
||||
// payment id was previously stored in session in
|
||||
// CreatePaymentUsingPayPal.php
|
||||
$paymentId = $_SESSION['paymentId'];
|
||||
$payment = Payment::get($paymentId, $apiContext);
|
||||
|
||||
// PaymentExecution object includes information necessary
|
||||
// to execute a PayPal account payment.
|
||||
// The payer_id is added to the request query parameters
|
||||
// when the user is redirected from paypal back to your site
|
||||
$execution = new PaymentExecution();
|
||||
$execution->setPayerId($_GET['PayerID']);
|
||||
|
||||
//Execute the payment
|
||||
// (See bootstrap.php for more on `ApiContext`)
|
||||
$result = $payment->execute($execution, $apiContext);
|
||||
|
||||
echo "<html><body><pre>";
|
||||
echo $result->toJSON(JSON_PRETTY_PRINT);
|
||||
echo "</pre><a href='../index.html'>Back</a></body></html>";
|
||||
|
||||
} else {
|
||||
echo "User cancelled payment.";
|
||||
}
|
||||
<?php
|
||||
// #Execute Payment Sample
|
||||
// This sample shows how you can complete
|
||||
// a payment that has been approved by
|
||||
// the buyer by logging into paypal site.
|
||||
// You can optionally update transaction
|
||||
// information by passing in one or more transactions.
|
||||
// API used: POST '/v1/payments/payment/<payment-id>/execute'.
|
||||
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
use PayPal\Api\ExecutePayment;
|
||||
use PayPal\Api\Payment;
|
||||
use PayPal\Api\PaymentExecution;
|
||||
session_start();
|
||||
if(isset($_GET['success']) && $_GET['success'] == 'true') {
|
||||
|
||||
// Get the payment Object by passing paymentId
|
||||
// payment id was previously stored in session in
|
||||
// CreatePaymentUsingPayPal.php
|
||||
$paymentId = $_SESSION['paymentId'];
|
||||
$payment = Payment::get($paymentId, $apiContext);
|
||||
|
||||
// PaymentExecution object includes information necessary
|
||||
// to execute a PayPal account payment.
|
||||
// The payer_id is added to the request query parameters
|
||||
// when the user is redirected from paypal back to your site
|
||||
$execution = new PaymentExecution();
|
||||
$execution->setPayerId($_GET['PayerID']);
|
||||
|
||||
//Execute the payment
|
||||
// (See bootstrap.php for more on `ApiContext`)
|
||||
$result = $payment->execute($execution, $apiContext);
|
||||
|
||||
echo "<html><body><pre>";
|
||||
echo $result->toJSON(JSON_PRETTY_PRINT);
|
||||
echo "</pre><a href='../index.html'>Back</a></body></html>";
|
||||
|
||||
} else {
|
||||
echo "<html><body><h1>";
|
||||
echo "User cancelled payment.";
|
||||
echo "</h1><a href='../index.html'>Back</a></body></html>";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user