예제 #1
0
<?php

$server = $_SERVER['HTTP_HOST'];
$server2 = $_SERVER['REQUEST_URI'];
$path = 'http://' . $server . $server2;
$url = chop($path, 'paypal.php');
if (isset($_POST['token'])) {
    include 'dbCon.php';
    include 'bootstrap.php';
    $token = $_POST['token'];
    $final = getOrderDatesThroughToken($pdo, $token);
    if ($final != false) {
        $id = $final['id'];
        $value = (double) $final['value'];
        $currency = $final['code'];
        $shipping = (double) $final['shipping'];
        $total = (double) $value + (double) $shipping;
        include 'paypalPayment.php';
    } else {
        $error = 'Błąd podczas przetwarzania - niewłaściwy numer token!';
        include 'error.html';
    }
} else {
    $error = 'Błąd podczas przetwarzania żądania płatności Paypal';
    include 'error.html';
}
예제 #2
0
<?php

include 'dbCon.php';
include_once 'bootstrap.php';
use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\ExecutePayment;
use PayPal\Api\Payment;
use PayPal\Api\PaymentExecution;
use PayPal\Api\Transaction;
if (isset($_GET['success']) && $_GET['success'] == 'true') {
    $token = $_GET['merchantToken'];
    $dbInfos = getOrderDatesThroughToken($pdo, $token);
    if ($dbInfos != null) {
        $currency = 'PLN';
        $clientName = $dbInfos['name'];
        $email = $dbInfos['email'];
        $orderName = $dbInfos['id'];
        $productValue = (double) $dbInfos['value'];
        $shipping = (double) $dbInfos['shipping'];
        $paymentAmount = $productValue + $shipping;
        $finalAddress = 'http://' . $_SERVER['SERVER_NAME'] . '/payment/';
        $paymentId = $_GET['paymentId'];
        $payment = Payment::get($paymentId, $apiContext);
        $execution = new PaymentExecution();
        $execution->setPayerId($_GET['PayerID']);
        $transaction = new Transaction();
        $amount = new Amount();
        $details = new Details();
        $details->setShipping($shipping)->setSubtotal($productValue);
        $amount->setCurrency($currency);