/**
* Create a payment using a previously obtained
* credit card id. The corresponding credit
* card is used as the funding instrument.
*
* @param string $creditCardId credit card id
* @param string $total Payment amount with 2 decimal points
* @param string $currency 3 letter ISO code for currency
* @param string $paymentDesc
*/
function makePaymentUsingCC($creditCardId, $total, $currency, $paymentDesc)
{
$ccToken = new CreditCardToken();
$ccToken->setCreditCardId($creditCardId);
$fi = new FundingInstrument();
$fi->setCreditCardToken($ccToken);
$payer = new Payer();
$payer->setPaymentMethod("credit_card");
$payer->setFundingInstruments(array($fi));
// 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);
$payment = new Payment();
$payment->setIntent("sale");
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
$payment->create(new Paypalinit());
return $payment;
}