title: Paypal with delphi using REST API Return Payment Empty
body: <p>i try to make a delphi application using paypal REST API.</p>
  
  <p>First the TOKEN and is working fine:</p>
  
  <pre><code>var
    slParameters:TStringList;
    Response:TStringStream;
    json, sTokenType:string;
    PayPalObj:TJSONObject;
    jTokenValue:TJSONValue;
  begin
  memLog.Lines.Clear;
  memLog.Lines.Add('TOKEN');
  btnPayment.Enabled := False;
  http.Request.ContentType := 'application/x-www-form-urlencoded';
  http.Request.Accept := 'application/json';
  http.Request.AcceptLanguage := 'en_US';
  http.Request.BasicAuthentication := True;
  http.Request.Username := 'AQXYqhB1xxHcxHIg2grwyWny6VcGSJsvlMI4v1vNEPrTzbhZc4bHVEJXmvgX';
  http.Request.Password := 'EE9wTBCqyKWWRRLU5otmzvE407va_NitLwnegxKwtt_D9RmmXbh7_kePLN3I';
  
  slParameters := TStringList.Create;
  Response := TStringStream.Create;
  try
    //get an access token
    slParameters.Add('grant_type=client_credentials');
    json := http.Post('https://api.sandbox.paypal.com/v1/oauth2/token', slParameters);
    //json := Response.DataString;
    PayPalObj := TJSONObject.ParseJSONValue(TEncoding.ASCII.GetBytes(json), 0) as TJSONObject;
    try
      jTokenValue := PayPalObj.Get('access_token').JsonValue;
      AccessToken := jTokenValue.Value;
      jTokenValue := PayPalObj.Get('token_type').JsonValue;
      sTokenType := jTokenValue.Value;
  
      Memo1.Lines.Clear;
      Memo1.Lines.Text := PayPalObj.ToString;
      Memo1.Lines.Add('Size: ' + IntToStr(PayPalObj.EstimatedByteSize));
    finally
      PayPalObj.Free;
    end;
  
    if sTokenType &lt;&gt; 'Bearer' then
      Exit;
  
    if AccessToken = '' then
      Exit;
  
    lblToken.Caption := Format('Token: %s - Type: %s', [AccessToken, sTokenType]);
    btnPayment.Enabled := True;
  finally
    Response.Free;
    slParameters.Free;
  end;end;
  
  procedure TfrmPayPalREST.httpAuthorization(Sender: TObject;
    Authentication: TIdAuthentication; var Handled: Boolean);
  begin
  memLog.Lines.Add('*** Authorization ***');
  memLog.Lines.Add(Authentication.ToString);
  memLog.Lines.Add(' ');
  </code></pre>
  
  <p>But on the payment, always returns a empty json response</p>
  
  <pre><code>var
    PayPalObj :TJSONObject;
    PayPalObj2 :TJSONObject;
    RedirectObj :TJSONObject;
    PayerObj :TJSONObject;
  
    TransactionsArray : TJSONArray;
    AmountObj : TJSONObject;
    TransactionObj : TJSONObject;
    FundingArray : TJSONArray;
    CreditCardObj : TJSONObject;
  
    ssJson : TStringStream;
    json, Authorization:string;
  begin
  //create a payment
  memLog.Lines.Add('PAYMENT');
  PayPalObj := TJSONObject.Create;
  try
    RedirectObj := TJSONObject.Create;
    try
      RedirectObj.AddPair(TJSONPair.Create('return_url', TJSONString.Create('http://blahblah.com/return')));
      RedirectObj.AddPair(TJSONPair.Create('cancel_url', TJSONString.Create('http://blahblah.com/cancel')));
    except
      RedirectObj.Free;
      Exit;
    end;
  
    PayerObj := TJSONObject.Create;
    try
      PayerObj.AddPair(TJSONPair.Create('payment_method', TJSONString.Create('credit_card')));
  
      CreditCardObj := TJSONObject.Create;
      CreditCardObj.AddPair('number', '5500005555555559');
      CreditCardObj.AddPair('type', 'mastercard');
      CreditCardObj.AddPair('expire_month', '12');
      CreditCardObj.AddPair('expire_year', '2018');
      CreditCardObj.AddPair('cvv2', '111');
      CreditCardObj.AddPair('first_name', 'yo');
      CreditCardObj.AddPair('last_name', 'tu');
  
      FundingArray := TJSONArray.Create;
      FundingArray.Add(CreditCardObj);
  
      PayerObj.AddPair(TJSONPair.Create('funding_instruments', FundingArray));
    except
      PayerObj.Free;
      Exit;
    end;
  
    TransactionsArray := TJSONArray.Create;
    AmountObj := TJSONObject.Create;
    TransactionObj := TJSONObject.Create;
    try
      AmountObj.AddPair('currency', TJSONString.Create('USD'));
      AmountObj.AddPair('total', TJSONString.Create('1'));
      TransactionObj.AddPair('amount', AmountObj);
      TransactionObj.AddPair('description', TJSONString.Create('payment description'));
      TransactionsArray.Add(TransactionObj);
    except
      TransactionsArray.Free;
      AmountObj.Free;
      TransactionObj.Free;
      Exit;
    end;
  
    PayPalObj.AddPair(TJSONPair.Create('intent', TJSONString.Create('sale')));
    PayPalObj.AddPair(TJSONPair.Create('payer', PayerObj));
    PayPalObj.AddPair(TJSONPair.Create('transactions', TransactionsArray));
    //PayPalObj.AddPair(TJSONPair.Create('redirect_urls', RedirectObj));
  
    Memo1.Lines.Add(' ');
    Memo1.Lines.Add(PayPalObj.ToString);
    Memo1.Lines.Add('Size: ' + IntToStr(PayPalObj.EstimatedByteSize));
  
    http.Request.Clear;
    http.Request.ContentType := 'application/json';
    http.Request.CustomHeaders.Clear;
    //http.Request.CustomHeaders.FoldLines := False;  //have tried this with no success
    Authorization := Format('Bearer %s', [AccessToken]);
    http.Request.CustomHeaders.AddValue('Authorization', Authorization);  //token obtained from first request
  
    Memo1.Lines.Add(' ');
    Memo1.Lines.Add(http.Request.CustomHeaders.Text);
    ssJson := TStringStream.Create(PayPalObj.ToString, TEncoding.ASCII);
    try
      json := http.Post('https://api.sandbox.paypal.com/v1/payments/payment', ssJson);
      lblPayment.Caption := json;
  
      PayPalObj2 := TJSONObject.ParseJSONValue(TEncoding.ASCII.GetBytes(json), 0) as TJSONObject;
      if Assigned(PayPalObj2) then
        try
          Memo1.Lines.Add(' ');
          Memo1.Lines.Add(PayPalObj2.ToString);
        finally
          PayPalObj2.Free;
        end;
    finally
      ssJson.Free;
    end;
  finally
    PayPalObj.Free;
  end;
  </code></pre>
  
  <p>Any One know why? Thank you for the help</p>
  
  <p>Using Delphi XE6 with Indy, this is a android app by the way</p>
  
  <p><a href="http://www.itcmx.com/PayPalREST.rar" rel="nofollow noreferrer">Delphi Source Code</a></p>
  
  <p>PS: i use the follow question: 
  <a href="https://stackoverflow.com/questions/26395669/using-paypal-rest-client-with-delphi-xe2/26436321#26436321">Using PayPal REST client with Delphi XE2</a> but there is not any answer there</p>