
ksugihara
By: a guest on
Aug 17th, 2012 | syntax:
PHP | size: 1.16 KB | hits: 17 | expires: Never
try {
//create instance of the complex types classes
$currencytype = new CurrencyType();
$currencytype->code = 'USD';
$currencytype->amount = '100';
$currency = new CurrencyList();
$currency->currency = $currencytype;
$currencycode = new CurrencyCodeList();
$currencycode->currencyCode = 'JPY';
$xrequestEnvelope = new RequestEnvelope();
//Creating instance of the PreapprovalRequest to be the payload for the Preapproval api call with required field
$params = new ConvertCurrencyRequest();
$params->requestEnvelope = $xrequestEnvelope;
$params->baseAmountList = $currency;
$params->convertToCurrencyList = $currencycode;
//API credential http headers
$http_headers = "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
"X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
"X-PAYPAL-MESSAGE-PROTOCOL: " .$API_MessageProtocol. "\r\n";
$opts = array( 'http' => array('method'=>'POST','header'=>$http_headers));