public function makePaymentUsingPayPal($total, $currency, $paymentDesc, $returnUrl, $cancelUrl) { $payer = new Payer(); $payer->setPaymentMethod("paypal"); // Specify the payment amount. $amount = new Amount(); $amount->setCurrency($currency); $amount->setTotal($total); // ###Transaction // A transaction defines the contract of a // payment - what is the payment for and who // is fulfilling it. Transaction is created with // a 'Payee' and 'Amount' types $transaction = new Transaction(); $transaction->setAmount($amount); $transaction->setDescription($paymentDesc); $redirectUrls = new RedirectUrls(); $redirectUrls->setReturnUrl($returnUrl); $redirectUrls->setCancelUrl($cancelUrl); $payment = new Payment(); $payment->setRedirectUrls($redirectUrls); $payment->setIntent("sale"); $payment->setPayer($payer); $payment->setTransactions(array($transaction)); $payment->create(getApiContext()); return $payment; }