コード例 #1
0
ファイル: PayPal.php プロジェクト: guss77/kohana-paypal
 public static function execute($payerID, $localTrxID)
 {
     $trxid = Session::instance()->get_once(self::SESSION_TOKEN);
     $impl = new PayPal();
     $response = $impl->complete($trxid, $payerID);
     $localTrxID = $impl->retrieveLocalTrx($localTrxID);
     self::debug("Paypal response for " . serialize($localTrxID), $response);
     $target = $impl->approved($localTrxID, $response->id, $response->payer->payer_info, $impl->extractSales($response->transactions));
     HTTP::redirect($target);
 }
コード例 #2
0
ファイル: index.php プロジェクト: kreative/f3-pypl
    // Reroute buyer to PayPal with resulting transaction token
    if ($result['ACK'] != 'Success') {
        // Handle API error code
        die('Error with API call - ' . $result["L_ERRORCODE0"]);
    } else {
        // Redirect Buyer to PayPal
        $f3->reroute($result['redirect'] . '&useraction=commit');
    }
});
$f3->route('GET /complete', function ($f3) {
    // grab token & PayerID from URL
    $token = $f3->get('GET.token');
    $payerid = $f3->get('GET.PayerID');
    // complete the transaction
    $paypal = new PayPal();
    $result = $paypal->complete($token, $payerid);
    if ($result['ACK'] != 'Success' && $result['ACK'] != 'SuccessWithWarning') {
        // Handle API error code
        die('Error with API call - ' . $result["L_ERRORCODE0"]);
    } else {
        // Update back office - save transaction id, payment status etc
        // Display thank you/receipt to the buyer.
        $f3->set('itemcount', 0);
        $f3->set('txnid', $result['PAYMENTINFO_0_TRANSACTIONID']);
        echo \Template::instance()->render('receipt.html');
    }
});
$f3->route('GET /refund', function ($f3) {
    // Get transaction id from URL
    $txnid = $f3->get('GET.txnid');
    // Refund the transaction