The following samples demonstrate how to work with this library.
This call is very straight forward and simply returns the converted currency values for the requested amount.
The fully functional sample code displayed here is found in /application/controllers/paypal/samples/Adaptive_payments.php.
An empty version of this function can be found in /application/controlles/paypal/templates/Adaptive_payments.php.
function Convert_currency()
{
// Prepare request arrays
$BaseAmountList = array();
$BaseAmountData = array(
'Code' => 'USD', // Currency code.
'Amount' => '100.00' // Amount to be converted.
);
array_push($BaseAmountList, $BaseAmountData);
$ConvertToCurrencyList = array('BRL', 'AUD', 'CAD'); // Currency Codes
$PayPalRequestData = array(
'BaseAmountList' => $BaseAmountList,
'ConvertToCurrencyList' => $ConvertToCurrencyList
);
$PayPalResult = $this->paypal_adaptive->ConvertCurrency($PayPalRequestData);
if(!$this->paypal_adaptive->APICallSuccessful($PayPalResult['Ack']))
{
$errors = array('Errors'=>$PayPalResult['Errors']);
$this->load->view('paypal/samples/error',$errors);
}
else
{
// Successful call. Load view or whatever you need to do here.
$data = array('PayPalResult'=>$PayPalResult);
$this->load->view('paypal/samples/convert_currency',$data);
}
}