Don't like ads? PRO users don't see any ads ;-)
Guest

ksugihara

By: a guest on Aug 17th, 2012  |  syntax: PHP  |  size: 1.16 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. try {  
  2.         //create instance of the complex types classes
  3.         $currencytype = new CurrencyType();
  4.         $currencytype->code = 'USD';
  5.         $currencytype->amount = '100';
  6.  
  7.         $currency = new CurrencyList();
  8.         $currency->currency = $currencytype;
  9.  
  10.         $currencycode = new CurrencyCodeList();
  11.         $currencycode->currencyCode = 'JPY';
  12.  
  13.         $xrequestEnvelope = new RequestEnvelope();
  14.  
  15.         //Creating instance of the PreapprovalRequest to be the payload for the Preapproval api call with required field
  16.         $params = new ConvertCurrencyRequest();
  17.  
  18.         $params->requestEnvelope = $xrequestEnvelope;                  
  19.         $params->baseAmountList = $currency;
  20.         $params->convertToCurrencyList = $currencycode;
  21.        
  22.        
  23.  
  24. //API credential http headers
  25.         $http_headers = "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
  26.                     "X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
  27.                         "X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
  28.                         "X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
  29.                         "X-PAYPAL-MESSAGE-PROTOCOL: " .$API_MessageProtocol. "\r\n";
  30.  
  31.  
  32. $opts = array( 'http' => array('method'=>'POST','header'=>$http_headers));