Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once '/home/hat3tank/public_html/users/init.php';
- $db = DB::getInstance();
- $user_id = $user->data()->id;
- use PayPal\Api\Payment;
- use PayPal\Api\PaymentExecution;
- require 'app/start.php';
- if(isset($_GET['success'])) {
- $approved = $_GET['success'] === 'true';
- if($approved) {
- $payerId = $_GET['PayerID'];
- //Get the payment_id from database
- $paymentId = $db->get('transactions_paypal',['hash','=',$_SESSION['paypal_hash']]);
- $paymentId = $paymentId->first()->payment_id;
- //Get the paypal payment
- $payment = Payment::get($paymentId, $paypal);
- $execution = new PaymentExecution();
- $execution->setPayerId($payerId);
- //Execute Paypal Payment
- $payment->execute($execution, $paypal);
- $fields = array (
- 'user_id' => $user_id,
- 'permission_id' => 4
- );
- //update the logged in user's account info
- $db->insert('user_permission_matches',$fields);
- // //UNset PayPal hasg
- // unset($_SESSION['paypal_hash']);
- //Redirect user to success page, alter these to take you your own redirect.
- header('Location: payment_success.php');
- } else {
- header('Location: payment_cancelled.php');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement