Skip to main content

PayPal Community

  • Dashboard
  • Send and Request
  • Wallet
  • Business
  • Help
Log in
  • Welcome
    • Guidelines
    • News and Events
    • Suggestions for PayPal
    • General Discussions
  • PayPal Help Community
    • Managing Account
    • Transactions
    • Wallet
    • Security and Fraud
    • Products & Services
    • Reporting
  • MTS Community
    • PayPal Upgrade Community
    • PayPal Payments Standard
    • REST APIs
    • NVP/SOAP APIs
    • SDKs
    • Sandbox Environment
    • PayPal Reporting
    • Payflow
    • Ideas for MTS
    • Client-side Integration
    • Server-side Integration
  • The Archives
    • PayPal Help Community Archives
      • Managing Account Archives
      • Transactions Archives
      • Wallet Archives
      • Security and Fraud Archives
      • Products & Services Archives
      • Reporting Archives
    • Help Community
      • PayPal Basics Archives
      • Payments Archives
      • My Money Archives
      • My Account Archives
      • Disputes and Limitations Archives
      • Products and Services Archives
      • PayPal Credit Archives
    • Merchant Community
      • Merchant Products
      • Business Tools Archives
      • Reporting Archives
      • Managing Risk and Fraud Archives
    • Help Archives
      • About Business (Archive)
      • About Payments (Archive)
      • About Settings (Archive)
      • About eBay (Archive)
      • About Protections (Archive)
      • About Products (Archive)
    • Social and Your Voice Archives
      • Off Topic (Archive)
      • My Feedback for PayPal (Archive)
    • About PayPal Archives
      • Watercooler (Archive)
      • Tax Information (Archive)
      • Fees (Archive)
      • eBay and PayPal (Archive)
      • Coupons and promotions (Archive)
    • My Account Archives
      • My account settings (Archive)
      • Account limits and verification (Archive)
      • Account balance (Archive)
      • Bank accounts and credit cards (Archive)
    • Payments Archives
      • Sending money (Archive)
      • Receiving money (Archive)
      • Refunds (Archive)
      • Donations and Fundraising (Archive)
    • Disputes and Security Archives
      • Disputes and claims (Archive)
      • Fraud, phishing and spoof (Archive)
    • My Business Archives
      • Merchant services (Archive)
      • Reporting and tracking (Archive)
      • Shipping (Archive)
    • PayPal Products Archives
      • PayPal Debit Mastercard (Archive)
      • PayPal Extras MasterCard (Archive)
      • PayPal Mobile & Other Services (Archive)
      • Student Accounts (Archive)
      • Bill Me Later (Archive)
    • Getting to know PayPal
      • My PayPal account
      • Security and protection
    • Receiving and sending money
      • Buying with PayPal
      • Selling with PayPal
    • PayPal Here UK
      • PayPal Here News and Events
      • PayPal Here Community
      • Chip and Pin Card Reader
      • PayPal Here App

The Community Forum is not available for new posts or responses; previous posts remain available to review. For comprehensive support options, please visit PayPal.com/HelpCenter
Merchant Technical Support: For technical support and related questions, please visit our Technical Support Help Center or Developer Central

If you want to report illegal content under the EU Digital Services Act, please do so here

since ‎Sep-16-2021
Country: United States
Type: Personal
awf825
awf825 Contributor
Contributor
2
Posts
0
Kudos
0
Solutions
The Return
Active
View all
Topics awf825 has Participated In
  • Topics awf825 has Participated In
  • Latest Contributions by awf825

How do I know my Access Tokens are secure?

by awf825 Contributor in SDKs
‎Sep-16-2021 01:36 PM
‎Sep-16-2021 01:36 PM
Hello,     I am integrating PayPal buttons into an existing ecommerce service. I have successfully implemented a PayPal integration into my app: an AngularJS SPA (1.8.2) fronting a Joomla (PHP) backend, where here I need to process orders in my database. I was originally using a PHP SDK to try and capture orders (https://github.com/paypal/Checkout-PHP-SDK/tree/1.0.1), but I realized I didn't need this entire library and opted for a simpler solution. Here is where the order is created and approved, from my angular controller:       $scope.opts = { createOrder: function (data, actions) {return actions.order.create({...})}, onApprove: function (data, actions) { return $order.processPayPalOrder(data).then(function(res) { console.log('$order.processPayPalOrder(data): ', res) }) },       The angular service method that calls the PHP backend, where I'm appending sensitive PayPal information to the request:       this.processPayPalOrder = function(data) { this.order.payment.paypal = { facilitatorAccessToken: data.facilitatorAccessToken, orderID: data.orderID, payerID: data.payerID } return $http.post("/xxxxxxxxx.savePayPalOrder", this.order); }        And finally, the PHP, where I make a curl request to get the order that was just made from the sandbox api:       public function savePayPalOrder() { $app = JFactory::getApplication(); $this->order = $app->input->json->getArray(); $accessToken = $this->order['payment']['paypal']['facilitatorAccessToken']; $orderID = $this->order['payment']['paypal']['orderID']; $payPalRequestUri = "https://api-m.sandbox.paypal.com/v2/checkout/orders/" . $orderID; $curl = curl_init($payPalRequestUri); curl_setopt($curl, CURLOPT_URL, $payPalRequestUri); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $headers = array( "Content-Type: application/json", "Authorization: Bearer " . $accessToken, ); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $resp = curl_exec($curl); curl_close($curl); // THIS IS WHERE I'LL EVENTUALLY APPLY THE LOGIC TO STORE WHAT I NEED FROM THE ORDER OBJECT IN MY DATABASE echo $resp; }       This works like a charm in development: I'm able to get the payload back to the frontend by way of onApprove (in the first code snippet). However, I'm afraid this approach may be too naked. Is it unsafe to be sending the faciliatatorAccessToken variable unencrypted to my own backend? Should I even be using this variable for what I'm trying to do? Would it be a better approach to make a request for a PayPal access token in the PHP code? Should the curl request for the order be sanitized further, or is this fine as is? For what it may be worth, I verified that the angular $http service is making the request over https. Any help on this would be greatly appreciated; it works, but I'm a little worried about the security of this approach. Thank you! ... View more
Paypal Logo
  • Help
  • Contact Us
  • Security
  • Fees
  • © 1999-2025 PayPal, Inc. All rights reserved.
  • Privacy
  • Legal
  • Cookies
  • Policy Updates

The money in your balance is eligible for pass-through FDIC insurance.

The PayPal Cash Mastercard is issued by The Bancorp Bank pursuant to a license by Mastercard International Incorporated. The Bancorp Bank; Member FDIC.

Powered by Khoros
Welcome to the PayPal Community!