title: in PayPal, is it possible to do checkout with normal button, not paypal button?
body: <p>I am using PayPal Rest API, and I make PHP page that let buyers do payment.</p>
  
  <p>I make code from this link - <a href="https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/server-side-REST-integration/" rel="nofollow noreferrer">https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/server-side-REST-integration/</a></p>
  
  <p>So I made 'Buy Now' button like this code:</p>
  
  <pre><code>    &lt;div id="paypal-button"&gt;&lt;/div&gt;
  
      &lt;script&gt;
          paypal.Button.render({
          env: 'sandbox', // Or 'sandbox',
  
          commit: true, // Show a 'Pay Now' button
  
          style: {
              color: 'blue',
              size: 'large',
              shape: 'rect',
              label: 'buynow',
          },
  
          payment: function(data, actions) {
              alert('1');
              /* 
              * Set up the payment here 
              */
          },
  
          onAuthorize: function(data, actions) {
              alert('2');
              /* 
              * Execute the payment here 
              */
          },
  
          onCancel: function(data, actions) {
              alert('3');
              /* 
              * Buyer cancelled the payment 
              */
          },
  
          onError: function(err) {
              alert('4');
              /* 
              * An error occurred during the transaction 
              */
          }
          }, '#paypal-button');
      &lt;/script&gt;
  </code></pre>
  
  <p>But actually payment should be done when click other normal button, not this paypal button. (This is related with my logic.)</p>
  
  <p>So when click that normal button, paypal payment should be done.</p>
  
  <ul>
  <li>I thought it can be done by triggering click event of paypal button.</li>
  </ul>
  
  <p>But it seems not so simple to do that.
  I see paypal button is in iframe with different domain. It makes hard to trigger any event.</p>
  
  <ul>
  <li>So I thought one another way to do this - when click payment button, doing payment from server-side. And it returns paypal checkout page url to redirect. and open new small window manually from this paypal checkout page url.</li>
  </ul>
  
  <p>It is from this link - <a href="http://paypal.github.io/PayPal-PHP-SDK/sample/doc/payments/CreatePaymentUsingPayPal.html" rel="nofollow noreferrer">http://paypal.github.io/PayPal-PHP-SDK/sample/doc/payments/CreatePaymentUsingPayPal.html</a></p>
  
  <p>and code is like this </p>
  
  <pre><code>    $payer = new Payer();
      $payer-&gt;setPaymentMethod('paypal');
  
      $item_1 = new Item();
      $item_1-&gt;setName('Item 1') /** item name **/
          -&gt;setCurrency('USD')
          -&gt;setQuantity(1)
          -&gt;setPrice($amountVal); /** unit price **/
  
      $shipping_address = new ShippingAddress();
      $shipping_address-&gt;setCity('San Jose');
      $shipping_address-&gt;setCountryCode('US');
      $shipping_address-&gt;setPostalCode('95132');
      $shipping_address-&gt;setLine1('My St');
      $shipping_address-&gt;setState('CA');
      $shipping_address-&gt;setRecipientName('Recipient1');
  
      $billing_address = new Address();
      $billing_address-&gt;setCity('San Jose');
      $billing_address-&gt;setCountryCode('US');
      $billing_address-&gt;setPostalCode('95132');
      $billing_address-&gt;setLine1('My St2');
      $billing_address-&gt;setState('CA');
  
      $payer_info = new PayerInfo();
      $payer_info-&gt;setBillingAddress($billing_address);
      $payer_info-&gt;setEmail('a@2.com');
      $payer-&gt;setPayerInfo($payer_info);
  
      $item_list = new ItemList();
      $item_list-&gt;setItems(array($item_1));
      $item_list-&gt;setShippingAddress($shipping_address);
  
      $amount = new Amount();
      $amount-&gt;setCurrency('USD')
          -&gt;setTotal($amountVal);
  
      $transaction = new Transaction();
      $transaction-&gt;setAmount($amount)
          -&gt;setItemList($item_list)
          -&gt;setDescription('Your transaction description');
  
      $payee_email = Input::get('payee');
      if ($payee_email) {
          $payee = new Payee();
          $payee-&gt;setEmail($payee_email);
          $transaction-&gt;setPayee($payee);
      }
  
      $redirect_urls = new RedirectUrls();
      $redirect_urls-&gt;setReturnUrl(url('paypal/status')) /** Specify return URL **/
          -&gt;setCancelUrl(url('paypal/status'));
  
      $payment = new Payment();
      $payment-&gt;setIntent('Sale')
          -&gt;setPayer($payer)
          -&gt;setRedirectUrls($redirect_urls)
          -&gt;setExperienceProfileId($profile_id)
          -&gt;setTransactions(array($transaction));
  
      try {
          $payment-&gt;create(PaypalController::$_api_context);
      } catch (\PayPal\Exception\PPConnectionException $ex) {
          return json_decode($ex-&gt;getData());
          return 'Error: ' . $ex-&gt;getMessage();
      }
  
      foreach ($payment-&gt;getLinks() as $link) {
          if ($link-&gt;getRel() == 'approval_url') {
              $redirect_url = $link-&gt;getHref();
                  break;
          }
      }
  
      /** add payment ID to session **/
      Session::put('paypal_payment_id', $payment-&gt;getId());
      if (isset($redirect_url)) {
      /** redirect to paypal **/
          return Redirect::away($redirect_url);
      }
  
      return 'Unknown error occurred';
  </code></pre>
  
  <p>It is working something, but after call this server side function, when I open new small window for paypal checkout, background is not faded like when click normal paypal button.</p>
  
  <p>Fading means fading backgrounds with string 'Don't see the secure PayPal browser? We'll help you re-launch the window to complete your purchase. ...'. Maybe you can know.</p>
  
  <p>So it seems not so secure.</p>
  
  <p>Finally so I want to know 2 things.</p>
  
  <ol>
  <li><p>If I want to do paypal payment when click non-paypal button, how can I do this?</p></li>
  <li><p>Is there any way to fade background with 'Don't see the secure PayPal browser? We'll help you re-launch the window to complete your purchase. ...' manually when open new paypal checkout page by clicking non-paypal button?</p></li>
  </ol>
  
  <p>Thanks much to anyone help!</p>