<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[The PayPal Technology Blog - Medium]]></title>
        <description><![CDATA[Join our technology team at careers.pypl.com - Medium]]></description>
        <link>https://medium.com/paypal-tech?source=rss----6423323524ba---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>The PayPal Technology Blog - Medium</title>
            <link>https://medium.com/paypal-tech?source=rss----6423323524ba---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 05 Nov 2026 12:07:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/paypal-tech" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[We have moved to https://developer.paypal.com/community/blog]]></title>
            <link>https://medium.com/paypal-tech/we-have-moved-to-https-developer-paypal-com-community-blog-2acf7cb138a6?source=rss----6423323524ba---4</link>
            <guid isPermaLink="false">https://medium.com/p/2acf7cb138a6</guid>
            <dc:creator><![CDATA[PayPal Tech Blog Team]]></dc:creator>
            <pubDate>Mon, 15 Jun 2026 21:19:29 GMT</pubDate>
            <atom:updated>2026-08-28T18:19:38.235Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tb5CqOH2pyIs3Cdm-zpa_Q.png" /></figure><p>The PayPal Developer Blog has a new home.</p><p>You’ll continue to find the latest developer news, tutorials, product updates, and engineering insights here:</p><p><a href="https://developer.paypal.com/community/blog"><strong>https://developer.paypal.com/community/blog</strong></a></p><p>Thanks for being part of the PayPal developer community.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2acf7cb138a6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paypal-tech/we-have-moved-to-https-developer-paypal-com-community-blog-2acf7cb138a6">We have moved to https://developer.paypal.com/community/blog</a> was originally published in <a href="https://medium.com/paypal-tech">The PayPal Technology Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PayPal Releases Agentic Toolkit to Accelerate Commerce]]></title>
            <link>https://medium.com/paypal-tech/the-following-is-a-repost-from-the-paypal-developer-blog-a6d90e2b0f39?source=rss----6423323524ba---4</link>
            <guid isPermaLink="false">https://medium.com/p/a6d90e2b0f39</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[PayPal Tech Blog Team]]></dc:creator>
            <pubDate>Mon, 14 Apr 2025 20:27:50 GMT</pubDate>
            <atom:updated>2025-04-15T12:46:37.503Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*t19bJtF8YhcQGB9dufW2oQ.png" /></figure><p><em>The following is a repost from the </em><a href="https://developer.paypal.com/community/blog/paypal-agentic-ai-toolkit"><em>PayPal Developer Blog</em></a><em>.</em></p><p>Building on the release of PayPal’s <a href="https://developer.paypal.com/community/blog/paypal-model-context-protocol/">MCP servers</a>, PayPal is excited to introduce the <a href="https://github.com/paypal/agent-toolkit/">PayPal Agentic Toolkit</a>*. This toolkit empowers developers to seamlessly integrate PayPal’s comprehensive suite of APIs — including those for managing orders, invoices, disputes, shipment tracking, transaction search and subscriptions — into various AI frameworks. With PayPal Agentic Toolkit, developers can now build sophisticated agentic workflows that handle financial operations with intelligence and efficiency.</p><h3>Overview of PayPal Agent Toolkit</h3><p>The PayPal Agentic Toolkit is a library designed to simplify the integration of PayPal’s core commerce functionalities into AI agent workflows. By providing a structured and intuitive interface, the toolkit bridges the gap between PayPal’s powerful APIs and modern AI agent frameworks, allowing agents to perform tasks such as creating and managing orders, generating and sending invoices, and handling subscription lifecycles. It eliminates the need for developers to manually integrate with API calls and data formatting by offering pre-built tools and abstractions to streamline these interactions.</p><h3>Key Features of the Toolkit</h3><ul><li><strong>Easy integration with PayPal services</strong>, including functions that correspond to common actions within the orders, invoices, disputes, shipment tracking, transaction search and subscriptions APIs, eliminating the need to delve deep into the specifics of each API endpoint.</li><li><strong>Compatibility with popular frameworks and languages</strong>, including compatibility with leading AI agent frameworks, such as Model Context Protocol (MCP) servers and Vercel’s AI SDK, ensuring broad applicability. The toolkit currently supports the Typescript programming language with Python support coming soon.</li><li><strong>Extensibility</strong>, allowing developers to build upon core PayPal functionalities, and enable use with 3rd party toolkits that allows for complex, multi-step operations tailored to their specific agentic use cases.</li></ul><h3>Merchant Use Cases</h3><p>The integration of PayPal APIs with AI frameworks through the Agentic Toolkit enables developers to empower businesses with their own agents, facilitating seamless connections to PayPal services for process workflows and task generation for use cases. These include:</p><ul><li><strong>Order Management and Shipment tracking:</strong> AI agents can be designed to create orders based on user requests, handle payments and track their shipment status. Developers could design a customer service agent to leverage the PayPal toolkit to process an order and complete a payment via PayPal with buyer authentication. For example, an agent could create an order in PayPal when a user clearly confirms their purchase through a conversational interface, and the user authenticates the payment by logging in to their PayPal account.</li><li><strong>Intelligent Invoice Handling:</strong> Agents can generate invoices based on predefined templates or dynamically created parameters, send them to customers, track their payment status, and send reminders for overdue payments. Imagine an AI assistant that generates invoices upon completion of a service, using natural language instructions to define the invoice details. For example, an AI assistant could generate a PayPal invoice based on the details of a service provided and email it to the client.</li><li><strong>Streamlined Subscription Management:</strong> AI agents can manage the entire subscription lifecycle, from creating new products, subscription plans and processing recurring payments via PayPal supported payment. A membership management agent could use the toolkit to enroll new members (with their consent) in a PayPal subscription plan. For example, a membership agent could use the toolkit to set up a recurring PayPal payment when a new user signs up for a service and approves the payment.</li></ul><h3>Get Started</h3><p>Go to our public <a href="https://github.com/paypal/agent-toolkit/">GitHub repo</a> to try out all the use cases offered by PayPal toolkit, refer to the details for installation and usage <a href="https://github.com/paypal/agent-toolkit/blob/main/README.md">here</a>.</p><p><em>*Disclaimer: PayPal Agentic Toolkit provides access to AI-generated content that may be inaccurate or incomplete. Users are responsible for independently verifying any information before relying on it. PayPal makes no guarantees regarding output accuracy and is not liable for any decisions, actions, or consequences resulting from its use</em>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6d90e2b0f39" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paypal-tech/the-following-is-a-repost-from-the-paypal-developer-blog-a6d90e2b0f39">PayPal Releases Agentic Toolkit to Accelerate Commerce</a> was originally published in <a href="https://medium.com/paypal-tech">The PayPal Technology Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PayPal Begins Rollout of MCP Servers to Accelerate Agentic Commerce]]></title>
            <link>https://medium.com/paypal-tech/paypal-begins-rollout-of-mcp-servers-to-accelerate-agentic-commerce-ad560a1315ec?source=rss----6423323524ba---4</link>
            <guid isPermaLink="false">https://medium.com/p/ad560a1315ec</guid>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[PayPal Tech Blog Team]]></dc:creator>
            <pubDate>Fri, 04 Apr 2025 14:25:27 GMT</pubDate>
            <atom:updated>2025-04-15T12:47:16.026Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*DTLnf2D_dltY4ItlfFxxJQ.png" /></figure><p><em>The following is a repost from the </em><a href="https://developer.paypal.com/community/blog/paypal-model-context-protocol"><em>PayPal Developer Blog</em></a><em> by Prakhar Mehrotra, SVP of Artificial Intelligence, PayPal</em></p><p>At PayPal, we strive to make it easier for developers to access our services. Today, we are taking the first step to allow developers to embrace the new paradigm of agentic commerce by adopting the Model Context Protocol (MCP) and placing our services on an MCP server. This puts the power of generative AI at our merchants’ fingertips.</p><p>MCP is a standard put forward by Anthropic that is being adopted by the world’s leading AI companies to help standardize the way agents access data sources or third-party services, thereby enabling seamless integration–something that is paramount in AI-native, multi-agent systems. Starting today, developers can interact with PayPal’s official MCP server to begin enabling next-generation, AI-driven capabilities for merchants. This includes remote MCP servers available with auth integration on the cloud. With remote MCP support, users can seamlessly continue their tasks across devices with simple logins after the authentication process.</p><p>The availability of PayPal’s MCP server will enable a range of conversational AI capabilities for merchants, which we will roll out in the coming months. To illustrate the power of this new technology, we’re starting with PayPal Invoice feature, which is available today to eligible PayPal merchants.</p><h3>Our First MCP Feature: Invoicing</h3><p>Developers can now enable merchants who wish to utilize their preferred AI tools — including LLMs — to automatically generate invoices and shareable invoice links to send to their clients within their MCP host. This eliminates the need for merchants to visit the PayPal website or integrate using PayPal APIs for manual invoice creation, making the process of creating an invoice for a customer much faster, more intuitive, and easier to integrate into existing MCP clients.</p><p>Let’s say a PayPal merchant needs to create an invoice for a customer. Instead of creating one manually, they may decide to use an AI system that is integrated with PayPal’s MCP endpoint to create an invoice conversationally. The merchant simply should prompt the AI system with plain language, “Create a PayPal invoice link for painting a house with a cost of $450. Add 8% tax and apply 5% discount. Make sure it expires in 10 days.” With PayPal’s MCP, it will create an invoice based on this prompt, thanks to the power of AI.*</p><h3>How to Get Started</h3><p>There are two ways of connecting to PayPal’s MCP server:</p><ol><li><strong>Local PayPal MCP Server Using the Agentic Toolkit:</strong> This option enables developers to download, install, and run the PayPal MCP server locally on their own machines. It supports a wide range of MCP clients, including Claude Desktop and Cursor AI.</li><li><strong>Remote PayPal MCP Server:</strong> This option opens the door to a broader audience — particularly users who prefer not to install local MCP servers. With remote PayPal MCP support, users have an endpoint that any MCP client can connect to seamlessly, allowing continuity of work across clients with a simple PayPal login.</li></ol><p>Visit <a href="https://mcp.paypal.com/">https://mcp.paypal.com</a> to get started, which includes our <a href="https://github.com/paypal/agent-toolkit">MCP developer toolkit on GitHub</a>, to start setting up your local PayPal MCP server or connect to the remote MCP server.</p><h3>Where We Are Going</h3><p>With the introduction of the MCP, PayPal is setting the foundation upon which we can build a more intelligent and responsive digital commerce ecosystem. MCP represents our commitment to continuous improvement and innovation, ensuring our developers and merchants are well-equipped to meet the evolving demands of the digital marketplace. And we’re just getting started. We’ll share more soon as we add additional products.</p><p><em>*Disclaimer: PayPal’s MCP server provides access to AI-generated content that may be inaccurate or incomplete. Users are responsible for independently verifying any information before relying on it. PayPal makes no guarantees regarding output accuracy and is not liable for any decisions, actions, or consequences resulting from its use.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad560a1315ec" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paypal-tech/paypal-begins-rollout-of-mcp-servers-to-accelerate-agentic-commerce-ad560a1315ec">PayPal Begins Rollout of MCP Servers to Accelerate Agentic Commerce</a> was originally published in <a href="https://medium.com/paypal-tech">The PayPal Technology Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Estimating Incremental Lift in Customer Value (Delta CV) using Synthetic Control]]></title>
            <link>https://medium.com/paypal-tech/estimating-incremental-lift-in-customer-value-delta-cv-using-synthetic-control-522be5e3da3a?source=rss----6423323524ba---4</link>
            <guid isPermaLink="false">https://medium.com/p/522be5e3da3a</guid>
            <category><![CDATA[synthetic-control]]></category>
            <category><![CDATA[customer-value]]></category>
            <category><![CDATA[paypal]]></category>
            <category><![CDATA[causal-inference]]></category>
            <dc:creator><![CDATA[Mahshid Moha]]></dc:creator>
            <pubDate>Fri, 14 Feb 2025 20:41:49 GMT</pubDate>
            <atom:updated>2025-02-14T20:41:49.079Z</atom:updated>
            <content:encoded><![CDATA[<h4>How we measure the impact of user actions and product adoptions at PayPal</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UZrhlBsfZN--iZPYo_s0eQ.png" /></figure><p>In today’s competitive digital landscape, understanding user interactions with your products is essential for driving revenue and building lasting customer relationships. At PayPal, our Data Science teams use causal inference to evaluate the impact of key customer actions, such as adopting a new product or adding a credit card to their wallet, on engagement (measured by Transactions per Account, or TPA), revenue, and margin to help make data-driven strategic decisions.</p><p>The direct profit from a product adoption or a user action on the app could be $0 if viewed in isolation. However, that does not necessarily mean that these events are not driving engagement and monetization across the PayPal ecosystem; they can change the user engagement with other PayPal products in such a way that the user starts generating more profit.</p><p>To measure the overall impact of user actions or product adoption, we introduced <strong>Delta CV</strong> (delta in Customer Value), and we defined it as a customer’s incremental <strong>profit margin </strong>in the first year after adoption of a new product or completing an action. For example, if the average Delta CV for adoption of Crypto is $20, we expect customers who adopt Crypto for the first time to bring an additional $20 in margin on average in the next 12 months after the adoption. We define Delta Revenue (or TPA) in the same manner except we calculate the incremental lift in revenue (or TPA) instead of profit margin.</p><p>The concept of Delta CV is very different from customer life-time value (CLV) which estimates the total profit generated by a customer over the course of their relationship with PayPal. Delta CV gives us a wholistic view on how new adoptions affect the engagement and value of an existing PayPal user.</p><p>Adoption of a new product or completing an action can increase the customer’s value in a few ways:</p><ul><li><strong>The product itself may be a profit generating (Direct effect)</strong>. For example, paying with PayPal when checking out at a merchant’s online website drives direct margin for PayPal.</li><li><strong>Actions do not necessarily lead to profit directly, but they facilitate the usage of other products that generate profit (Halo effect)</strong>. For instance, a customer adding a credit card to PayPal’s digital wallet can reduce future frictions or result in a higher conversion rate for that user paying with PayPal in the future.</li><li><strong>Adoption of a product can increase the user engagement with PayPal, leading to adoption or increased usage of other products that generate profit (Halo effect)</strong>. With Delta CV, we measure the cumulative lift in customer value considering all PayPal transactions of a user.</li></ul><p>Today we estimate Delta CV for 40+ products (or actions) in multiple regions. Having Delta CV for different products helps us in a variety of areas such as strategic decision making, calculating the return on investment (ROI) of campaigns, opportunity sizing for new campaign efforts, in-app product ranking and placement, making trade-off between resource allocations, making ramp decisions on product launches, and so on.</p><h3>Methodology</h3><p>We measure Delta CV using causal inference and synthetic control. For each product, our treatment group are the adopters of the product for the first time in each quarter. To create a synthetic control group, we focus on users who never adopted the product of interest. Then we find matches for the treatment users inside the control group based on a set of transactional features calculated over 12month pre-adoption. Since we are building a synthetic control and our target variable is CV, we should always match on CV in pre-period. The remaining of our matching features are important covariates of CV. They capture user characteristics and are our best predictors of users’ CV response to external and internal changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7jWsCQnRXkL2nlAqjHte5g.png" /><figcaption>Measurement of treatment effect (lift) using synthetic control for a given cohort</figcaption></figure><p>The synthetic control group acts as a counterfactual, meaning that we assume in the absence of an intervention, control and treatment group would change similarly over time. Therefore, if we introduce a change to the treatment group but not to the control group, the difference in the profit margin of the two groups measures the impact of the intervention.</p><p>We select the synthetic control group by matching on our group of features using KNN (K nearest neighbors) algorithm. Every user in treatment will have a synthetic control that is the average of up to 10 users from control. We define a threshold for the Euclidean distance between the treatment and control units, and we remove the matches that exceed this threshold to ensure a high quality of matching. The validity of synthetic control group selection can be checked by a bias analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EmYilII3ztYMjAdhDYj3Kg.png" /><figcaption>Creating synthetic control using KNN algorithm</figcaption></figure><h3>Interpretation of Delta CV and Caveats</h3><ol><li>The incremental lift by adoption of a new product or completing an action can be a highly skewed metric. Some users may bring in significantly more value than others after adoption of new products. Median delta CV is more in line with the expected incremental CV from a typical user, while mean delta CV reflects the financial lift that is expected at scale on average per user.</li><li>Delta CV estimations are subject to variance and bias. It is important to consider the accuracy of estimations when making trade-off decisions based on the model’s output.</li><li>Delta CV model estimates the historical impact of adoptions, so there is always a lag. We generally measure the impact over 12 months after adoption, so there will be a 12-month lag between our estimation and the quarter in which adoption occurred. Sometimes we use delta CV to understand past behavior, and other times we use it as our best estimation for what happens in the future. We can reduce the measurement period from 12 months to say three months for quick readouts, but we know that the early lift can be skewed from novelty or immediate use cases of customers and the CV gap between the treatment and control groups reduces over time.</li><li>In an ideal causal inference scenario, the treatment group undergoes an intervention or change, while the control group does not. However, in our setup, both treatment and control groups may adopt other products during the post-period. It is tempting to assume that other adoptions in the treatment and control groups occur randomly and that their impacts cancel each other out. However, our data shows that in the treatment group, there is a phenomenon of chain adoptions, where certain products are adopted more frequently together than in the control group. Not every user in the treatment or control group adopts multiple products but certain product adoptions are more prevalent in the treatment group. Therefore, Delta CV measures the cumulative effect of a product adoption along with its frequent preceding and subsequent adoptions at scale within the same quarter. <br>Note that excluding users who adopt other products during adoption period or in the post-period results in very specific, unusual treatment and control groups who do not adopt any product or complete any action within 12 months and do not represent our user base. We have no interest in limiting the Delta CV estimation scope to these specific users.</li><li>Delta CV is not an additive metric meaning that adoptions of two products during the same period does not result in a total Delta CV that equals the sum of Delta CV of both. As mentioned earlier, Delta CV is not an immaculate metric; it captures the lift due to other frequent product adoptions by a portion of the treatment users during the same period as well. But more importantly, user engagement does not linearly increase with each new product adoption; therefore, Delta CV cannot be treated as an additive metric.</li><li>Sometimes we cannot find high quality matches for the treatment. The control condition of “never adopted the product” is very limiting for some of our products, especially in markets where we have many high-engaged users. This results in a small synthetic control group size and low quality of matching. We flag the reliability of Delta CV when the average difference between CV of treatment and synthetic control in pre period is larger than $1. This is an important piece of information that is provided along with Delta CV for every product.</li></ol><h3>End Note</h3><p>PayPal products are rapidly evolving to provide the best value and experience to customers. While checkout was PayPal’s first product, we now offer an extensive variety of financial products including peer-to-peer payments, debit card, credit card, rewarding shopping experiences with cashback, and much more, all within the PayPal App. Delta CV has been an integral part of strategic decision making in PayPal. Adding new products to the scope of Delta CV, as well as continuously adjusting the matching methodology, is an ongoing effort. Reducing the estimation biases by improving the selection of matching features is another area for improvement.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=522be5e3da3a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paypal-tech/estimating-incremental-lift-in-customer-value-delta-cv-using-synthetic-control-522be5e3da3a">Estimating Incremental Lift in Customer Value (Delta CV) using Synthetic Control</a> was originally published in <a href="https://medium.com/paypal-tech">The PayPal Technology Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scaling PayPal’s AI Capabilities with PayPal Cosmos.AI Platform]]></title>
            <link>https://medium.com/paypal-tech/scaling-paypals-ai-capabilities-with-paypal-cosmos-ai-platform-e67a48e04691?source=rss----6423323524ba---4</link>
            <guid isPermaLink="false">https://medium.com/p/e67a48e04691</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[enterprise-technology]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <dc:creator><![CDATA[Jun Yang]]></dc:creator>
            <pubDate>Thu, 02 May 2024 16:27:03 GMT</pubDate>
            <atom:updated>2024-05-02T16:29:39.464Z</atom:updated>
            <content:encoded><![CDATA[<p><em>By </em><a href="https://www.linkedin.com/in/jun-yang-625b37/"><em>Jun Yang</em></a><em>, </em><a href="https://www.linkedin.com/in/zhenyinyang/"><em>Zhenyin Yang</em></a><em>, and </em><a href="https://www.linkedin.com/in/srinivasanmanoharan/"><em>Srinivasan Manoharan</em></a><em>, based on the AI/ML modernization journey taken by the PayPal Cosmos.AI Platform team in the past three years.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZgczeW0TS9URMPsBUMoSVw.png" /><figcaption>Source: Dall-E 3</figcaption></figure><p>AI is a transformative technology that PayPal has been investing in as a company for over a decade. Across the enterprise, we leverage AI/ML <strong>responsibly</strong> to address a wide range of use cases — from fraud detection; improving operational efficiencies; providing personalized service and offers to customers; meeting regulatory obligations, and many more things.</p><p>To accelerate PayPal’s innovation and deliver incredible value to our customers through technology, we are working to put the innovative power of artificial intelligence into the hands of more employees across different disciplines and accelerate time-to-market for building and deploying AI/ML powered applications, in service of our customers and in alignment with our Responsible AI principles. The blog below details a key internal platform that is helping us do this: PayPal Cosmos.AI Platform.</p><p><strong>AI/ML Platform: The Enterprise Approach<br></strong>Over the years, many engineering systems and tools have been developed to facilitate this practice at PayPal, addressing various needs and demands individually as they emerged. Several years ago, as we began to expand AI/ML across all core business domains, it became increasingly evident that the prevailing approach of having a collection of bespoke tools, often built and operated in their own silos, would not meet the needs for large scale AI/ML adoptions across the enterprise.</p><p>Conceived around 2020, PayPal Cosmos.AI Platform aims at providing end-to-end <strong>Machine Learning Development Lifecycle</strong> (MLDLC) needs across the enterprise by modernizing and scaling AI/ML development, deployment and operation, with streamlined end-to-end Machine Learning operations (MLOps) capabilities and experiences, making it faster, easier, and more cost effective to enable businesses through AI/ML solutions.</p><p>Since its official GA in mid-2022, Cosmos.AI has been gradually adopted by business domains across the company and became the de-facto AI/ML platform for the enterprise. Every day, <strong>thousands of data scientists, analysts, and developers</strong> hop to Cosmos.AI Workbench (Notebooks) and other research environments to develop machine learning and other data science solutions. In production, <strong>hundreds of deployed ML models serve tens of billions of inferencing requests,</strong> real-time and batch, on-premises and in the cloud on daily basis, supporting a wide range of business needs across the company.</p><p>In this blog, we provide a comprehensive view of the PayPal Cosmos.AI platform, starting retrospectively with the conscious decisions made at its conception, the rationales behind them, followed by an overview of its high-level architecture and a more detailed breakdown of its major components with their respective functionality through the lens of end-to-end MLOps. We then showcase how we have enabled <strong>Generative AI </strong>(Gen AI) application development on the platform, before concluding the blog with future works on the platform.</p><p><strong>The Guiding Principles<br></strong>When we first started conceiving what an enterprise-level AI/ML platform could be for the company, we took our time to establish a set of guiding principles based on our on-the-ground experiences gained from many years of practices of MLDLC. These principles remain steadfast to this day.</p><p><strong>Responsible AI</strong><br>PayPal remains committed to using AI technology in a responsible manner, consistent with legal and regulatory requirements and guidance and our overall risk management framework. Our approach to AI use is guided by our five core Responsible AI principles and our Responsible AI Steering Committee, consisting of cross-functional representatives who oversee AI development, deployment, governance, and monitoring.</p><p>PayPal Cosmos.AI reflects our commitment to Responsible AI in a number of ways, including minimizing inherited undesirable biases through data governance processes and training data management, enhancing interpretability through explainable AI, ensuring reproducibility with simulation, and having human-in-the-loop reviews whenever necessary.</p><p><strong>Streamlined end-to-end MLDLC on one unified platform</strong><br>The concept of a platform as a one-stop shop covering the entire MLDLC was pioneered by AWS SageMaker and later adopted by all major public cloud providers such as Azure Machine Learning and GCP Vertex AI. We believe this approach inherently provides the advantages of a <strong>consistent</strong>, <strong>coherent, </strong>and <strong>connected </strong>set of capabilities and user experiences compared to the ‘bespoke tools’ approach where tools are created independently, driven by ad hoc demands. The latter can lead to proliferation of overlapping or duplicative capabilities, resulting in frustrating confusing user experiences and high maintenance costs.</p><p>Cosmos.AI aims to provide streamlined user experiences supporting all phase of MLDLC, including data wrangling, feature engineering, training data management, model training, tuning and evaluation, model testing &amp; CICD, model deployment &amp; serving, explainability and drift detection, model integration with domain products, as well as other cross-cutting MLOps concerns such as system and analytical logging, monitoring &amp; alerting, workflow automation, security and governance, workspace &amp; resource management, all in one unified platform, catered for PayPal’s specific context and scenarios for MLDLC.</p><p><strong>Best-of-breed with abstraction &amp; extensibility</strong><br>The AI/ML industry evolves extremely fast with new technologies emerging almost daily, and quantum leaps happen every now and then (just think about the debut of ChatGPT). How do we ensure the platform we build can stay current with the industry?</p><p>On Cosmos.AI, we decoupled platform capabilities from their actual embodiments. For example, distributed training as a capability can be implemented using an in-house built framework on Spark clusters on-premise, and as Vertex AI custom training jobs leveraging GCP. This best-of-breed approach with abstraction allows us to independently evolve components of our platform to leverage the most optimal technologies or solutions at each phase of MLDLC, be it in-house built, opensource adopted, or vendor provided. Abstractions have also been created among major components of the platform, for example, the Model Repo API ensures the compatibility of Model Repo with its upstream process (model development) and downstream process (model deployment), regardless of the underneath technology solution we choose for the component (e.g. MLFlow).</p><p>This approach lends itself well to greater extensibility of the platform. As shown in a later section, we were able to build a Gen AI horizontal platform on top of Cosmos.AI rather quickly, by extending capabilities in several phase of the MLDLC catered for Large Languages Models (LLM), including LLM fine-tuning, adapter hosting, LLM deployment, etc. and other LLMOps functionality.</p><p>In addition, this approach also mitigates potential vendor and/or technology lock-in, making the platform more future-proof given the constant changes of technology landscape and company policies.</p><p><strong>Multi-tenancy from ground up</strong><br>Multi-tenancy is essential to enterprise platforms such as Cosmos.AI. It creates the necessary boundaries among different scrum/working teams, so that they have the maximum autonomy over the projects or use cases they own, without being overloaded with information they don’t need, as we observed in the previous generation of tools. It also enables guardrails for fine-grained access control and permission management, so teams can work safely and at their own pace without stepping on each other’s toes, and maintain data protections.</p><p>Multi-tenancy is a prerequisite for self-service, another key principle embraced by the PayPal Cosmos.AI platform as discussed next.</p><p><strong>Self-service with governance</strong><br>We observed that when it comes to productionizing ML solutions developed by data scientists, dedicated engineering support is often needed to handle the operational aspects of the lifecycle. This poses a constraint for scaling AI/ML across the enterprise.</p><p>We firmly believe that the ability of self-service is key to the success of PayPal Cosmos.AI as an enterprise AI/ML platform, and we adhere to this principle throughout the platform from its foundational constructs, to user experiences, as we will discuss in later sections.</p><p><strong>Seamless integration with enterprise ecosystems</strong><br>At this point one might ask why we chose to build Cosmos.AI platform instead of adopting a vendor solution such as SageMaker or Vertex AI as is. For one, as we recognized through our evaluations, one-size-fits-all cookie cutter solutions did not, and most likely will not, meet all the functional requirements from a wide spectrum of use cases in a large enterprise — some of which are highly proprietary and advanced, and customizations can only go so far. In addition, requests for new features or enhancements to external vendors are highly unpredictable.</p><p>But the more fundamental challenges are the mandates for this platform to seamlessly integrate with the company’s ecosystems and policies, such as data security, data governance and other regulatory compliances for fintech companies like PayPal. From engineering perspectives, the platform needs to be an integral part of existing companywide ecosystems and infrastructures, such as centralized auth &amp; auth and credential management, role-based permission management, data center operations, change process, central logging, monitoring and alerting, and so on.</p><p><strong>Multi-cloud and hybrid-cloud support</strong><br>PayPal encompasses a multitude of business domains and adjacencies, each of which may require the deployment of applications and systems in diverse environments. Recognizing this intricate landscape, Cosmos.AI is designed to be both multi-cloud and hybrid cloud, ensuring robust support across these varied environments.</p><p>There are many factors to consider when we productionize customer use cases on Cosmos.AI, including:</p><ul><li>Data affinity: customer solutions need to be deployed close to their data sources as much as possible to avoid data movements and security risks.</li><li>Application affinity: customer application dependencies, downstream and upstream, on-Prem or cloud.</li><li>SLA: fulfill requirements on latency, throughput, availability, disaster recovery (DR), etc.</li><li>Cost: deploy workloads of different natures in the right environment for optimal cost-effectiveness. For example, research workloads requiring repetitive on-and-off, trial-and-error attempts may be more economically done on-Prem, while productionized workloads can leverage the scalability and elasticity provided by cloud more efficiently.</li></ul><p>The coverage provided by Cosmos.AI over various environments allows us to productionize customer use cases with the right balance among these factors.</p><p><strong>The Foundations<br></strong>We developed various constructs and frameworks within PayPal Cosmos.AI that are fundamental to the platform. Leveraging these foundational elements, we successfully constructed the Cosmos.AI platform, aligning with the guiding principles set forth.</p><p><strong>Project-based experience</strong><br>A fundamental construct within the Cosmos.AI platform is the AI Project. It serves as the cornerstone for enabling multi-tenancy, access control, resource management, cost tracking, and streamlining the end-to-end MLDLC process.</p><p>From a user interface and user experience (UIUX) perspective, it empowers users to operate within their dedicated workspaces, with role-based access controls seamlessly integrated with PayPal’s IAM system. Beneath each AI Project, resources are managed in isolation, encompassing storage, compute, and data. Artifacts imported and produced during the MLDLC journey, such as training datasets, experiments, models, endpoints, deployments, monitoring, and more, are all contained within their respective AI Projects. This design fosters genuine multi-tenancy and facilitates self-service. Project owners and members can independently work within their projects, including deployment, without concern for interfering with others (subject to predefined platform-level governance within Cosmos.AI). This approach enhances the scalability of ML solution development while reducing time to market.</p><p><strong>Dynamic resource allocation and management</strong><br>We built a framework capable of dynamically allocating and managing computing resources on Cosmos.AI for model deployment and serving. At its core is a sophisticated Kubernetes CRD (Custom Resources Definition) and Operator that creates model deployments, including advanced deployments as discusses later, as well as manages the orchestration, scaling, networking, tracing and logging, of pods and model services. This is a pivotal capability on Cosmos.AI platform, enabling self-service MLOps to productionize ML solutions with ease. Coupled with multi-tenancy and governance, this allows domain teams to develop, experiment, and go production with their ML solutions at their own pace, all within their allocated resource quota and proper governance policies set forth by the platform. This paradigm offers MLDLC at scale and greatly shortens their time-to-market (TTM).</p><p><strong>Workflow automation with pipelines</strong><br>Workflow automation is another framework foundational to the Cosmos.AI platform. It consists of several parts: an experience for users to compose pipelines using building blocks provided by the platform, such as data access, processing and movement, training, inferencing, or any custom logic loaded from container Artifactory. Resulted pipelines can be scheduled, or triggered by another system — for example, a detection of model drift by monitoring system can automatically trigger model refresh pipeline — training data generation, model training, evaluation, and deployment.</p><p><strong>User experiences through UI, API &amp; SDK</strong><br>Cosmos.AI created user experiences for customers across the entire spectrum of ML expertise, exposed mainly through two channels: the Cosmos.AI Hub, a web-based application with intuitive, interactive and coherent UI guides users of different levels going through all phases of MLDLC, leveraging advanced techniques such as drag-and-drop visual composers for pipelines and inferencing graphs, for example. For advanced uses preferring programatical access to the platform, they can choose to work on Cosmos.AI Workbench, a custom user experience built on top of Jupyter Notebook with accesses to platform capabilities through Cosmos.AI API &amp; SDK, in addition to the UI. Cosmos.AI Hub and Workbench play critical roles in delivering the user experiences enabling streamlined, end-to-end MLDLC with self-service.</p><p><strong>The Architecture<br></strong>The diagram below provides a high-level layered view of PayPal Cosmos.AI platform architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*_IiZ5MLZPeigmIX5.png" /></figure><p><strong>The MLOps Focus<br></strong>PayPal Cosmos.AI has been built with a strong focus on MLOps, particularly on the model development, deployment, serving and integration with business flows. In this section, we delve into the next level details on key components in Cosmos.AI that makes it stand out from a MLOps perspective.</p><p><strong>Model development: training dataset management, training &amp; tuning</strong><br>For any model development lifecycle, dataset management is a critical part of the lifecycle. PayPal Cosmos.AI supports preparation of training datasets integration with feature store and manage these datasets along with sanity checks and key metrics while seamlessly integrating with training frameworks and experiment tracking. Along with training datasets, it also helps manage and keep a system of record for other datasets crucial for advanced features like explainer, evaluation, drift detection and batch inferencing cases.</p><p>Cosmos.AI provides a very rich set of open source and proprietary model training frameworks like TensorFlow, PyTorch , Hugging Face, DGL, and so on, supporting many deep learning algorithms and graph training algorithms. It also provides a very easy way to run these massive training jobs locally or in distributed manner with use cases datasets in the scale of 200 million samples with 1,500 features in various modes like map reduce, Spark and Kubernetes, abstracting the underlying infrastructure and complexity from the data scientists and helping them to effortlessly switch with mere configuration changes. It also provides various templates of commonly used advanced deep learning modules like Logistic regression, DNN, Wide &amp; Deep, Deep FM, DCN, PNN, NFM, AFM, xDeepFM, networks &amp; training algorithms supporting a variety fraud, personalization, recommendations and NLP use cases. Cosmos.AI also provides seamless integration into cloud provider offerings for model training with ease and high security standards.</p><p><strong>Model repo: experiment &amp; model registry</strong><br>Cosmos.AI provides an advanced and comprehensive framework for capturing all aspects of the model training process, emphasizing reproducibility, traceability, and the meticulous linking of training and evaluation datasets to the model. This encompasses the inclusion of training code, hyperparameters, and configuration details, along with the thorough recording of all model performance metrics. The platform facilitates seamless collaboration among data scientists by allowing them to share their experiments with team members, enabling others to reproduce identical experiments.</p><p>In addition to robust experiment tracking, the model repository stands as a pivotal component within the platform. It houses the physical artifacts of the model and incorporates essential metadata required for inferencing. Crucially, every model is intricately linked to its corresponding experiment, ensuring a comprehensive lineage for all critical entities throughout the entire machine learning lifecycle.</p><p><strong>Model Deployment</strong><br>Cosmos.AI supports several model deployments approaches catered for PayPal’s hybrid cloud environments. However, our discussion is confined to the predominant Kubernetes-based approach, with the expectation that other methods will gradually phase out and converge towards this mainstream approach in the near future.</p><p>At the core of the model deployment component is a custom-built Deployment CRD (Custom Resource Definition) and Deployment Operator on Kubernetes. They work together to allocate resources like CPU, GPU, memory, storage, ingress etc. from underlying infrastructure and create a DAG (Directed Acyclic Graph) based deployment with orchestrations among models, pre/post processors, logger &amp; tracer, or any containerized custom logics (e.g. Gen AI components as discussed in a later section) based on the deployment specification generated by Cosmos.AI from user inputs through the deployment workflow.</p><p>This is an extremely powerful capability on Cosmos.AI platform, enabling simple and advanced model deployment schemes such as Inferencing Graph, Canary, Shadow, A/B testing, MAB testing, and so on. It is a key enabler for self-service, as technically a user can just pick one or more registered models from the model repo, specify a few parameters, and have a model endpoint running ready to service inferencing requests in a few clicks — all through a guided, UI based flow by herself.</p><p>However, in reality, it is necessary to build governance and security measures into the process. For example, we integrated with company-wide change process so that every action is trackable, and with operation command center to observe site wide events such as moratorium.</p><p><strong>Model inferencing</strong><br>Model inferencing capabilities on Cosmos.AI fall into two categories: batch and real-time.</p><p>Cosmos.AI offers batch inferencing on two infrastructure flavors: Spark native and Kubernetes, available both on-premises and cloud environments. These solutions are highly scalable and cost efficient, making them extensively utilized in use cases like offline model score generation, feature engineering, model simulation and evaluation, and so on. Typically, these processes are integrated as steps within workflows managed by workflow management services such as the Cosmos.AI pipeline.</p><p>Real-time inferencing on Cosmos.AI is implemented through various technology stacks, supporting all combinations of model aspects in the company: Java and Python runtime; PayPal proprietary and industry standard; conventional ML, Deep Learning, and LLM. On our mainstream Kubernetes based platform, we support complex DAG based model inferencing, GPU optimization such as GPU fragmentation, and multi-GPU for LLM serving, adaptive / predictive batching and other advanced model serving techniques.</p><p><strong>Model integration: rule lifecycle, domain product integration</strong><br>Rarely are model scores used in isolation to make decisions and drive business flows at PayPal. Instead, a Strategy Layer, typically comprised of rules — often numbering in the hundreds for a specific flow — is positioned on top. This layer synthesizes other ingredients at runtime, incorporating additional context or factors, with business rules applied as deemed necessary by the domain.</p><p>Cosmos.AI built a complete Decision Platform to support this need. At the core of its runtime is an in-house built lightweight Rule Engine capable of executing rules based on a Domain Specific Language (DSL), with end-to-end dependencies expressed as a DAG. User Defined Functions (UDF) as platform provided, built-once-use-many capabilities can be invoked anywhere in the execution flow. In design time, an interactive UI with drag-n-drop is used for developers to author rules with self-service and minimum coding. In addition, integrations with upstream domain products are facilitated by a UI based use case onboarding and API schema specification workflow. The entire rule lifecycle and use case management including authoring, testing, regression, deployment and monitoring are supported through the platform.</p><p><strong>Explainability and drift detection</strong><br>Explainability is supported on Cosmos.AI mainly through black-box models. Depending on the types, frameworks and input data formats of the models, a variety of algorithms, e.g., Tree SHAP, Integrated Gradients, Kernel SHAP, Anchors etc. are utilized to provide instance-specific explanations for predictions. We also built explainability into our end-to-end user experience where users can train explainers or surrogate models as well as main models, before deploying them together through a single deployment workflow.</p><p>Model drift detection is also supported on Cosmos.AI through monitoring and alerting of model metrics such as Population Stability Index (PSI) and KL Divergence. Integrated with automated model re-training pipeline on the platform, drift detection is used as an alerting and triggering mechanism to guard against model concept drifts in production.</p><p><strong>Gen AI Enablement<br></strong>Since Generative AI (Gen AI) has taken the world by storm with the groundbreaking debut of ChatGPT in late 2022, we embraced this transformative technology early on, by exploring, evaluating and onboarding various Gen AI technologies, particularly those centered around Large Language Models (LLM), anticipating a fresh wave of widespread Gen AI adoptions potentially reshaping every facet of customer experiences and applications throughout the company and the industry.</p><p>Thanks to the solid foundations we have in place for platform with its remarkable extensibility, we were able to develop a Gen AI horizontal platform on PayPal Cosmos.AI in the span of a few months, allowing PayPal to fully tap into this technology and rapidly scale Gen AI application development across the company, while reducing costs by minimizing duplicated efforts on Gen AI adoptions among different teams.</p><p>Below is an overview of the Gen AI capabilities we built on Cosmos.AI platform:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*27CEKZzDilhgeNVB.png" /></figure><p>We augmented our training platforms allowing users to fine-tune opensource LLMs through custom Notebook kernels with PEFT frameworks such as LoRA/QLoRA integrated, and enabled fine-tuning of vendor hosted LLMs through API with security measures such as <strong>Data Loss Prevention</strong> (DLP) in place. We extend our model repo to effortlessly onboard opensource LLMs from public model gardens such as Hugging Face, with legal and licensing checks in the process. We also extend the model repo to host LLM Adapters as outputs from fine-tuning processes, deployable with their coupling foundation models.</p><p>The needs for LLMOps are accommodated nicely by extending existing MLOps capabilities on Cosmos.AI, including the ability to deploy LLMs with high parameter sizes across multiple GPU cards; LLM optimizations (including quantization) leveraging cutting edge frameworks and solutions for better resource utilization and higher throughput; streaming inferencing optimized for multi-step, chatbot-like applications; logging/monitoring to include more context such as prompts which are specific to LLM serving. Cost and showback for budgeting purposes are supported out-of-the-box through AI Projects on Cosmos.AI. Of course, we also developed a suite of new capabilities and infrastructure components to enable Gen AI as a transformative technology on our platform, including:</p><ul><li>Adopted a purposely built <strong>Vector DB</strong> from a leading opensource solution as the foundation for embedding and semantic based computations.</li><li>A <strong>Retrieval-Augmented Generation</strong> (RAG) framework leveraging Vector DB (for indexing &amp; retrieval) and Cosmos.AI pipelines (for context and knowledge ingestions), enabling a whole category of chatbot and knowledge bot use cases across the enterprise.</li><li><strong>Semantic Caching</strong> for LLM inferencing, also built on top of Vector DB, to cut down operational costs for vendor and self-hosted LLM endpoints and reduce inferencing latency at the same time.</li><li>A <strong>Prompt Management</strong> framework to facilitate prompt engineering needs of our users, including template management, hinting, and evaluation.</li><li><strong>Platform Orchestration</strong> framework: the advent of Gen AI introduced a distinct need for complex orchestrations among components and workflows. For example, to enable in-context learning and minimize hallucination, a LLM inferencing flow may involve prompt management, embedding generation, context/knowledge retrieval, similarity-based search, semantic caching, and so on. The industry has come up with some popular frameworks such as LangChain, LlamaIndex aiming at streamlining such workflows, and Cosmos.AI has built an orchestration framework with in-house developed capabilities and opensource packages as a platform capability.</li><li><strong>LLM Evaluation</strong> supporting major industry benchmarking tools and metrics, as well as enabling custom PayPal internal datasets for domain / use case specific evaluations.</li><li><strong>Gen AI Application Hosting</strong> to bootstrap client applications on Cosmos.AI platform.</li></ul><p>Utilizing the Gen AI horizontal platform as a foundation, we have enabled an ecosystem of internal agents for cosmos specializing in code, internal knowledge, model document creation and other MLDLC tasks using multi-agent and orchestration framework. This enables us to enhance productivity and efficiency for our data scientists and ML engineers by offering a Gen AI-powered experience on the Cosmos platform.</p><p>An architecture overview of Gen AI horizontal platform on Cosmos.AI is shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*65RuqMvGI8fxOO04.png" /></figure><p><strong>Future Work<br></strong>As we advance further on the journey of modernizing AI/ML at PayPal that commenced three years ago, we are currently envisioning the future landscape three years from today. Here are some initial considerations.</p><ul><li>Evolve from an AI/ML platform into an expansive ecosystem tailored for enterprise use, including datasets, features, models, rules, agents and APIs as core competencies.</li><li>Transition from self-service/manual processes to autonomous workflows in SDLC/MDLC/Front Office/Back Office Operations, incorporating automation and leveraging multi-agent framework driven by Generative AI.</li><li>Delve further into the realm of AI and incorporate elements such as data provenance, lineage, explainability, feedback loop, RLHF, and more, moving beyond the confines of AI/ML to AGI.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e67a48e04691" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paypal-tech/scaling-paypals-ai-capabilities-with-paypal-cosmos-ai-platform-e67a48e04691">Scaling PayPal’s AI Capabilities with PayPal Cosmos.AI Platform</a> was originally published in <a href="https://medium.com/paypal-tech">The PayPal Technology Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leveraging Spark 3 and NVIDIA’s GPUs to Reduce Cloud Cost by up to 70% for Big Data Pipelines]]></title>
            <link>https://medium.com/paypal-tech/leveraging-spark-3-and-nvidias-gpus-to-reduce-cloud-cost-by-up-to-70-for-big-data-pipelines-e0bc02ec4f88?source=rss----6423323524ba---4</link>
            <guid isPermaLink="false">https://medium.com/p/e0bc02ec4f88</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[gpu]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[apache-spark]]></category>
            <dc:creator><![CDATA[Ilay Chen]]></dc:creator>
            <pubDate>Wed, 21 Feb 2024 16:42:14 GMT</pubDate>
            <atom:updated>2024-02-21T16:42:13.916Z</atom:updated>
            <content:encoded><![CDATA[<p><em>By </em><a href="https://www.linkedin.com/in/ilay-chen-6a0749178/"><em>Ilay Chen</em></a><em> </em>and<em> </em><a href="https://www.linkedin.com/in/tomer-akirav-9774ba184"><em>Tomer Akirav</em></a></p><p>At PayPal, hundreds of thousands of Apache Spark jobs run on an hourly basis, processing petabytes of data and requiring a high volume of resources. To handle the growth of machine learning solutions, PayPal requires scalable environments, cost awareness and constant innovation. This blog explains how Apache Spark 3 and GPUs can help enterprises potentially reduce Apache Spark’s jobs cloud costs by up to 70% for big data processing and AI applications.</p><p>Our journey will begin with a brief introduction of Spark RAPIDS — Apache Spark’s accelerator that leverages GPUs to accelerate processing via the RAPIDS libraries. We will then review PayPal’s CPU-based Spark 2 application, our upgrade to Spark 3 and its new capabilities, explore the migration of our Apache Spark application to a GPU cluster, and how we tuned Spark RAPIDS parameters. We will then discuss some challenges we encountered and the benefits of the updates.</p><figure><img alt="The “libra scales in the cloud” figure shows the computational resources equilibrium of a big CPU-cluster to a small GPU-cluster" src="https://cdn-images-1.medium.com/max/570/1*VsdfOOWxiWO6KCDeO2mZqw.jpeg" /><figcaption>Libra scales in the cloud, generated by AI</figcaption></figure><h4>Background</h4><p>GPUs are everywhere, and their parallelism characteristics are perfect for processing AI and graphics applications, among other things. For those unfamiliar: what makes GPUs different from CPUs, computation-wise, is that CPUs have a limited amount of <em>very strong cores</em>, whereas GPUs have thousands, or even tens of thousands or more, <em>relatively weak cores</em> that work together very well. PayPal has been leveraging GPUs to train models for some time now, and so we decided to evaluate if the parallelism of the GPU can be helpful with processing big data applications based on Apache Spark.</p><p>In our research, we encountered NVIDIA’s Spark RAPIDS open-source project. It has many purposes, however we focused on Spark RAPIDS’s cost reduction potential, because enterprises like PayPal spend lots of money on running Spark jobs in the cloud. Using Spark with GPUs isn’t common in the industry yet, but according to our findings as described in this blog, the potential benefits could be enormous.</p><h4>What is Spark RAPIDS?</h4><p>Spark RAPIDS is a project that enables the use of GPUs in a Spark application. NVIDIA’s team adapted Apache Spark’s design to harness the power of GPUs. It is beneficial for <strong>large joins, group by, sorts, and similar functions</strong>. Spark RAPIDS can boost the performance of certain workloads, which we’ll discuss later in the blog their identification process. You can review the <a href="https://docs.nvidia.com/spark-rapids/user-guide/latest/index.html">documentation</a> here for more details.</p><p>There are a few reasons to use Spark RAPIDS to accelerate big data processing with GPUs: GPUs have their own environment and programming languages, so we can’t easily run Python/Scala/Java/SQL code on them. You must translate the code to a GPU programming language, and Spark RAPIDS does this translation in a transparent way. Another cool design change that Spark RAPIDS has made is how Spark handles the tasks in each stage of the job’s Spark plan. In pure Spark, every task of a stage is sent to a single CPU core in the cluster. This means that the parallelism is at the task level. In Spark RAPIDS, the parallelism is intra-task, meaning the tasks are parallelized as well as the processing of the data within each task. The GPU is a strong computation processor, which gives us incentives to manipulate our job to be more compute-bound, hence to work with large partitions.</p><figure><img alt="Task level parallelism vs data level parallelism, provided by NVIDIA" src="https://cdn-images-1.medium.com/max/426/1*-THlh6f7o9Aw6RQ6LPfNTg.png" /><figcaption>Task level parallelism vs data level parallelism, provided by NVIDIA</figcaption></figure><p>For more information and thorough explanations, we recommend reading NVIDIA’s book, <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.nvidia.com%2Fen-us%2Fdeep-learning-ai%2Fsolutions%2Fdata-science%2Fapache-spark-3%2Febook-sign-up%2F%3Fncid%3Dcont-641612&amp;data=05%7C02%7Cilchen%40paypal.com%7C1781dd0d0f3d47f727e708dc13ab104f%7Cfb00791460204374977e21bac5f3f4c8%7C0%7C0%7C638406872671529440%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=QtrehUkkiaR3ntbXWtbuVLaqgAGfecM3Cc0IRpfkHNg%3D&amp;reserved=0">Accelerating Apache Spark 3</a>.</p><h4><strong><em>Getting Started</em></strong></h4><p>Our initial experiment with Spark RAPIDS was successful in the PayPal research environment, which is an open environment with access to the web but with limited resources and without production data. The next step was to take the accelerator to production in order to measure real production applications.</p><p>According to Spark RAPIDS documentation, not all jobs are a good fit for this accelerator, so we worked on finding the most relevant ones. We started with a Spark 2 (CPU cluster) job that handles large amounts of data (multiple of ~10TB inputs), executes SQL operations on exceptionally large datasets, uses intense shuffles, and requires a fair number of machines. The job was predicted to have high success rate based on <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.nvidia.com%2Fen-us%2Flp%2Fdeep-learning-ai%2Fsolutions%2Fdata-science%2Fspark-accelerator%2F%3Fncid%3Dcont-111420&amp;data=05%7C02%7Cilchen%40paypal.com%7C1781dd0d0f3d47f727e708dc13ab104f%7Cfb00791460204374977e21bac5f3f4c8%7C0%7C0%7C638406872671539469%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=SzBnNqTZJKcB53Q9mogKNtWDYhnoOOB%2BTv71MI9DV0c%3D&amp;reserved=0">NVIDIA’s Qualification Tool</a>, which analyzes Spark events from CPU based Spark applications to help quantify the expected acceleration of migrating a Spark application to a GPU cluster.</p><p>As explained above, we understood that in order for the GPU to be well-leveraged, we had to manipulate our Spark job to work with large partitions. Our objective of working with large partitions is to manipulate our queries and operations to be <strong>more computation-bound, rather than I/O or network-bound</strong>, thus utilizing the GPU in an effective way.</p><p>In order to manipulate our job to work with large partitions, we changed two parameters: The <em>AQE</em> (Adaptive Query Execution) parameter, which is a new optimization technique in Spark 3 that, among other things, adjusts the number of partitions in a shuffle stage such that each partition will be in a certain size. The second parameter is <em>spark.sql.files.maxPartitionBytes</em>, which handles the input partition’s size. The number of partitions in those shuffle/input stages affects many accompanying stages as well.</p><p>For the baseline run, we did not set the <em>spark.sql.files.maxPartitionBytes</em> parameter, so the Spark plan used the default value of 128MB. Now let us see how the original stage of reading the large input looks like in the Spark UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*Ir4JaZTEwsU8D3aWEC_7_g.png" /></figure><p>As you can see, we got 9.5TB of data as an input, Spark divides it into ~185,000 partitions(!) which means that every partition is around 9.5TB/185,000 = 50MB. The input files size is around 1GB, it does not make sense for us to divide each file into 20 different partitions in the Spark cluster. This separation causes many network communication overheads and results in a longer latency at this stage.</p><p>Now, after setting the <em>spark.sql.files.maxPartitionBytes</em> parameter to 2GB (where we manipulate Spark to read larger input partitions and thus work with larger partitions in the next stages), let us see how the stage was affected:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*eH0OjURKysQiaCE6be5mIg.png" /></figure><p>Our 9.5TB was distributed to 10,000 partitions, which is nearly 20 times fewer partitions than the baseline run, and it resulted in the decrease of the total time to 40 minutes, which is a 30% reduction in runtime.</p><p>Now, let us look at all the heaviest input stages of our baseline run, where <em>spark.sql.files.maxPartitionBytes</em> is set to default:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*bqmbcKGCYR4qKO5brc260w.png" /></figure><p>After setting <em>spark.sql.files.maxPartitionBytes</em> to 2GB:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*JMMTwZwYju5SfrYfl66y8Q.png" /></figure><p>As we can see, the change lowered the number of tasks in the input processing stages, this simple parameter change resulted in reducing the runtime of these stages by more than 20 minutes.</p><h4>Spark 3 and AQE</h4><p>To migrate our job to Apache Spark 3, a fair number of steps had to be taken. We had to update some syntax in our code, and each jar of our infrastructure and applications had to be compiled with an updated Scala version. You can review the <a href="https://spark.apache.org/docs/latest/sql-migration-guide.html">official migration guide</a>.</p><p>In Spark 3, the ability to use GPUs was added and the <em>AQE</em> optimization technique was enabled. As mentioned above, the goal is to manipulate Spark to work with large partitions which means applying <em>AQE</em> to at least 1GB (or reducing the <em>spark.shuffle.partitions</em> number). In order for Spark application to work with partitions of 1GB, these properties need to be configured:</p><pre>&quot;spark.sql.adaptive.enabled&quot; : &quot;true&quot;<br>&quot;spark.sql.adaptive.advisoryPartitionSizeInBytes&quot; : &quot;1GB&quot;</pre><p>As we can see below, in our use case, this kind of practice is beneficial in runtime terms:</p><p>A shuffle stage in our baseline run (no <em>AQE</em>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*LLC6r-LJr8aytmWA-5KVVg.png" /></figure><p>A shuffle stage with <em>AQE</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*FYLgyF1EWsCD4LiGDM_gSQ.png" /></figure><p>After tuning the candidate job to work with large partitions, we checked the cluster‘s utilization and saw it was not fully utilized, so we could try to reduce the amount of machines the application consumes. The baseline job is with 140 machines and after tuning Spark and the cluster nodes, we ended up with 100 machines that were fairly utilized. This change only slightly affected the runtime of the job, but dramatically reduced the cost!</p><p>The intermediate result:<br>We cut ~20% of our application runtime and ~30% of our resources, resulting in a ~45% cost reduction!</p><p>As an example, If the initial cloud usage cost was 1,000 <a href="https://www.paypal.com/us/digital-wallet/manage-money/crypto/pyusd"><em>PYUSD</em></a>, so right now we would potentially stand at around 550 <em>PYUSD</em>!<br>Chart of CPU runs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*OOixq9nGLxYRxHMUuTIzxA.png" /></figure><p>Overall, our first intention was to work with large partitions solely to benefit from the GPUs but as we can see, there is a significant performance boost even before using Spark RAPIDS, which is exciting!<br>(Disclaimer: This practice does not bring the same results for all jobs. It depends on the data and the operations you do with it.)</p><p>So far, we just prepared our job to be suitable for Spark RAPIDS and GPUs, now the new challenges began — migrating to GPU cluster, learning new tuning concepts, troubleshooting and optimizing GPU usages.</p><h4>Migration to GPU Cluster</h4><p>The GPU migration included enabling the Spark RAPIDS init scripts, copying all their dependencies into PayPal’s production, supporting GPU parameters in our internal infrastructure, learning the GPU cluster features of our cloud vendor and more. <br>(Disclaimer: These days, cloud vendors release new, custom images with a built-in instance of Spark RAPIDS, so this work can be saved.)</p><p>After running some simple jobs, making sure we created a stable and reliable infrastructure where the GPU clusters run Spark RAPIDS as expected, we deep-dived into running our candidate production application with it. Thanks to the Spark RAPIDS documentation, we triaged the few runtime errors we encountered while tuning it for our needs. Let us quickly cover two issues that helped us understand the Spark RAPIDS tuning better:</p><blockquote>Could not allocate native memory: std::bad_alloc: <br>RMM failure at: arena.hpp:382: Maximum pool size exceeded</blockquote><p>The meaning behind this error is that the GPU memory pool was exhausted. To resolve this issue, some pressure is needed to be released from the GPU’s memory. After reviewing the literature, it was clear that some configurations are critical for each job. for example:<br><em>spark.rapids.sql.concurrentGpuTasks</em> — meaning the number of tasks that the GPU handles concurrently.</p><p>Intending to maximize the performance of our execution, we aimed to run in parallel as many tasks as possible. We were over-ambitious at first and set this parameter too high, and immediately got the above error. It happened because we use Tesla T4 GPUs, that have only 16GB of memory. As a check, we set the <em>spark.rapids.sql.concurrentGpuTasks</em> parameter to 1, and noticed that there are no memory errors. In order to utilize our resources properly, we had to find the sweet spot of the GPU concurrency parameter. To find that, we looked at the GPU utilization metrics, which we will explain later in the blog, and aimed the utilization to be around 50% — advised to us by NVIDIA’s team in order to have a fair division between the GPU computation and its communication/data transfer with the main memory. In our case, after some trial and error, we settled with running 2 tasks at a time, meaning setting <em>spark.rapids.sql.concurrentGpuTasks</em> = 2.</p><p>Another interesting issue we encountered was with runtime performance and stability. After reducing the number of machines in our cluster, from 140 to 30 machines, our Spark job was slower than expected and occasionally failed with the following prompt:</p><blockquote>java.io.IOException: No space left on device</blockquote><p>We looked deeper into our nodes and noticed that when we added the GPUs to the machines, we were able to solve the computation bottleneck, but the “pressure” moved to the local SSDs. This is because our GPUs with low memory capacity tend to swap memory onto local disks. The fact that our Spark plan is using large partitions adds to the disk spill. Originally, when each node had 4 SSDs (of 375GBs), we found that our job was slower than we expected, and sometimes even failed. To overcome this issue, we doubled the amount of our SSDs to 8, got stable results and better performance. Adding local SSDs is relatively cheap in cloud vendors, so this solution didn’t really affect our overall cost.</p><p>All interactions with local SSDs are much slower than main memory access. A critical parameter for this case is:<br><em>spark.rapids.memory.host.spillStorageSize</em> — the amount of off-heap host memory to use for buffering spilled GPU data before spilling to local disks.</p><p>Increasing the spill storage parameter to 32GB decreased our job’s runtime.</p><h4>Spark RAPIDS Optimizations: Tips and Insights</h4><ul><li><em>Choosing NVIDIA’s Tesla T4 GPU</em>: Among NVIDIA’s GPUs, we found that the Tesla T4 generally has the best performance/price ratio for this kind of computation, recommended to us by NVIDIA’s team for the purpose of cost reduction. (Disclaimer: The new L4 GPU may give better results.)</li><li><em>Considering memory overhead</em>: Keep in mind that the GPU does not work with the executor’s memory, but with off-heap memory, hence we have to guarantee enough memory overhead for each executor. We set the memory overhead to 16GB.</li><li><em>Tuning</em> <em>spark.task.resource.gpu.amount</em>: This parameter limits the number of tasks that are allowed to run concurrently on an executor, whether those tasks are using the GPU or not. At first we were greedy and tried to assign a lot of tasks to each executor. It slowed the stage’s runtime because of excessive I/O and spilling. In our case, we found that 0.0625 (1/16) was a good spot.</li><li><em>Using</em> <em>spark.rapids.memory.pinnedPool.size</em>: Pinned memory refers to memory pages that the OS will keep in system RAM and will not relocate or swap to disk. Using pinned memory significantly improves performance of data transfers between the GPU and host memory. We set this parameter to 8GB.</li><li><em>Configuring NVME Local SSDs</em>: The disks in the Spark RAPIDS cluster were configured to use the NVME protocol, resulting in 10% speedup.</li></ul><p>With stronger compute power, we allowed ourselves to challenge the cluster and reduce the number of machines. After some trial and error, we settled the GPU cluster to run with 30 machines of 32 cores, 120GB RAM, 8 SSDs and 2 Tesla T4 GPUs each, lasting for 1.3 hours.</p><h4>Spark RAPIDS Final Tuning</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*WQdndjIKcHlNqt2xo3utMQ.png" /></figure><h4>GPU Utilization</h4><p>Our cloud vendor provided a tool/agent that extracts metrics such as GPU utilization and GPU memory from GPU VM instances. This allowed us to monitor the usage of our GPUs, which is crucial to identify underutilized GPUs and optimize our workloads.</p><figure><img alt="GPU utilization graph" src="https://cdn-images-1.medium.com/max/465/1*OceraZ-c6ov31b1eAeHNYA.png" /><figcaption><em>GPU utilization graph</em></figcaption></figure><h4>Final Cost Comparison</h4><p>Below we can find a summary of our research findings:<br>As an example, consider a job that costs 1,000 <em>PYUSD</em>, Spark 3 with GPUs reduces that cost to 300 <em>PYUSD</em>. Depending on the configuration, you can enjoy potential cost savings of up to <strong>70%</strong> for processing large amounts of data using GPU Clusters.</p><figure><img alt="Final Cost Comparison" src="https://cdn-images-1.medium.com/max/1024/1*COYHYMA_g0YK8-QXJn9zGQ.png" /><figcaption>The price of the machine’s hardware is factored into the cost calculation</figcaption></figure><h4>Key Learnings</h4><ul><li>GPUs can be effectively leveraged not only for training AI models, but for big data processing as well.</li><li>Spark jobs that consume large amounts of data to perform certain SQL operations on large datasets are good candidates to be accelerated with Spark RAPIDS. Their eligibility can be validated with NVIDIA’s Qualification Tool.</li><li>Certain workloads benefit from being compute-bound, which can be achieved by manipulating the Spark job to work with large partitions, via <em>spark.sql.files.maxPartitionBytes</em> and the <em>AQE</em> parameters.</li><li>Leveraging Spark 3 with GPUs and Spark RAPIDS can significantly reduce your cloud costs for eligible workloads.</li></ul><h4>Thoughts for the Future</h4><p>The potential of running Spark RAPIDS with an autoscaling GPU cluster is highly regarded by us. This practice may significantly reduce the costs of major GPU machines due to their lower spot prices compared to permanent instances.</p><h4>Acknowledgments</h4><p>Thanks to the significant contributions of <a href="https://www.linkedin.com/in/elena-polyak-91729b4a/"><em>Lena Polyak</em></a><em>, </em><a href="https://www.linkedin.com/in/neta-golan-086a0751/"><em>Neta Golan</em></a><em>, </em><a href="mailto:basharygr@gmail.com"><em>Roee Bashary</em></a><em>,</em> and <a href="https://www.linkedin.com/in/tomer-pinchasi-a0059b/"><em>Tomer Pinchasi</em></a> for the project’s success. Thanks so much to NVIDIA’s Spark RAPIDS team for supporting us.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0bc02ec4f88" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paypal-tech/leveraging-spark-3-and-nvidias-gpus-to-reduce-cloud-cost-by-up-to-70-for-big-data-pipelines-e0bc02ec4f88">Leveraging Spark 3 and NVIDIA’s GPUs to Reduce Cloud Cost by up to 70% for Big Data Pipelines</a> was originally published in <a href="https://medium.com/paypal-tech">The PayPal Technology Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Declarative Feature Engineering at PayPal]]></title>
            <link>https://medium.com/paypal-tech/declarative-feature-engineering-at-paypal-eddcae81c06d?source=rss----6423323524ba---4</link>
            <guid isPermaLink="false">https://medium.com/p/eddcae81c06d</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[declarative-programming]]></category>
            <category><![CDATA[feature-engineering]]></category>
            <category><![CDATA[paypal]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Marina Lyan]]></dc:creator>
            <pubDate>Mon, 11 Dec 2023 15:56:51 GMT</pubDate>
            <atom:updated>2023-12-11T15:56:51.090Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FrfgJTUCj9IcH9pKz-JMxg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@fabioha?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">fabio</a> on <a href="https://unsplash.com/photos/geometric-shape-digital-wallpaper-oyXis2kALVg?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>PayPal supports over 400 million active consumers and merchants worldwide. Every minute there are several thousand payment transactions. To prevent fraud in real-time at such a scale, we need to streamline our ML workflow and feature engineering processes to build strong predictors of behaviors and risk indicators. On top of that, it must be done with consistently predictable Time to Market (TTM) and sustainable Total Cost of Ownership (TCO).</p><h3>What is declarative feature engineering?</h3><p>While the <strong>declarative feature engineering</strong> term was first introduced by <a href="https://databricks.com/session_eu19/zipline-airbnbs-declarative-feature-engineering-framework">Zipline AirBnB</a> in 2019, we have successfully used this paradigm in PayPal for the last decade, though we know it as <strong>config-based feature engineering</strong>. The idea is to allow data scientists to write a <em>declaration</em> of <strong>what</strong> their features look like rather than explicitly specify <strong>how</strong> to construct them on top of different execution platforms. In this way, the concerns of feature construction and execution are abstracted away from scientists so that engineers can worry about those complexities.</p><p>This post is the first in a series of two posts that will outline how the declarative feature engineering approach helps our engineers to address scale, TTM, and TCO requirements.</p><p>Let’s start with the definitions of metrics that measure our success.</p><h3>TTM of the ML Feature</h3><p>TTM of the Machine Learning (ML) feature is the length of time from the feature concept until it is released to production. Predictable TTM is a paramount need for overall AI maturation and business-first AI strategies.</p><h3>Cost of the ML Feature</h3><p>To qualify and estimate TCO, we break down the cost of the feature as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nrDidJrHupkz274XXOCFmg.png" /><figcaption>Layers of feature cost</figcaption></figure><p>The main insight from the feature cost analysis is that we have to reuse existing features across the teams whenever possible. Otherwise, we just pay twice for every aspect.</p><p>To approach the above challenges, we separate features into three levels of complexity so we can define tailored strategies for scale, TTM, and TCO at every level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*rDXwPafzn73g1IrhK4IM_g.png" /></figure><p><strong>Simple features</strong></p><p>Simple features account for the majority of the features, e.g. — roll-up aggregations (sum, count, average), and categorical features (marital status). For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*RWpmcpnd7T5WlPNtj28r9g.png" /></figure><p>Benefits include easier:</p><ul><li>Detection of similar declarative features and automatically recommend data scientists to reuse existing ones for better TTM &amp; TCO</li><li>Customization — for example, change the aggregation function or aggregation time window</li><li>Estimation of upfront cost of features and evaluating return on the investment (ROI) even before it goes into production</li><li>Maintenance (TCO) due to standardized implementation</li></ul><p><strong>Code-based features</strong></p><p>For more complex analytics, we plan for side-by-side development to reduce the number of iterations between data scientists and software engineers. However, it’s more challenging to:</p><ul><li>Enforce standards and best practices</li><li>Interpret and customize to reuse these features for other use cases</li><li>Backfill historical data for the model training</li><li>Maintain these features in production</li></ul><p><strong>Analytical platforms for feature generation</strong></p><p>For state-of-the-art feature generation, we develop <a href="https://medium.com/paypal-tech/how-paypal-uses-real-time-graph-database-and-graph-analysis-to-fight-fraud-96a2b918619a">graph of customers</a>, Natural language processing (NLP), and anomaly detection analytical platforms.</p><p>These platforms, however, are the most difficult to customize and maintain due to their high complexity.</p><h3>Self Service tool for declarative feature engineering</h3><p>Simple features are the perfect fit for the declarative feature engineering paradigm. Data scientists can write a <em>declaration</em> of <em>what</em> their features look like rather than explicitly specify <em>how</em> to construct them on top of different execution platforms: batch/near-real-time or real-time, which are standard compute platforms in the industry</p><p>We provide data scientists with UI and APIs to specify logic in a declarative way, simulate (aka <a href="https://netflixtechblog.com/distributed-time-travel-for-feature-generation-389cccdd3907">Time Travel for feature</a>), and productize features without direct support from engineers. This drastically reduces project planning overhead by reducing timeline dependencies, thus improving TTM.</p><p>Behind the scenes, the system is responsible for:</p><ol><li>Generate and optimize all the underlying data pipelines to reduce TCO.</li><li>Enforce Time Travel style in feature implementation so that features can be computed for any Point in Time (PiT) of historical data. As a result, data scientists can run backfill for the feature on a self-service basis for any period of time.</li><li>Register features to the <a href="https://www.featurestore.org/what-is-a-feature-store#:~:text=The%20Feature%20Store%20is%20where,that%20have%20a%20trained%20model).">Feature Store</a> for re-use by other data scientists.</li><li>Track TTM metrics and identify potential areas of improvement.</li><li>Enforce engineering standards and best practices for easier support and maintenance.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*-lgQ4617fp9GnYvx631L0Q.png" /></figure><h3>Conclusion</h3><p>The declarative feature engineering paradigm has proven to be very effective in simple feature development at scale with a predictable Time to Market and sustainable Total Cost of Ownership. We put our focus on self-service and automation for declarative features which allow us to free up engineers’ precious time to concentrate on state-of-the-art next-generation AI projects.</p><p>In this post, we outlined our solution’s functionality, and in the subsequent post, we will do a deep dive into the technical aspects. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eddcae81c06d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paypal-tech/declarative-feature-engineering-at-paypal-eddcae81c06d">Declarative Feature Engineering at PayPal</a> was originally published in <a href="https://medium.com/paypal-tech">The PayPal Technology Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streamlining Developer Productivity with the PayPal Visual Studio Code Extension]]></title>
            <link>https://medium.com/paypal-tech/streamlining-developer-productivity-with-the-paypal-visual-studio-code-extension-7518aaeb2957?source=rss----6423323524ba---4</link>
            <guid isPermaLink="false">https://medium.com/p/7518aaeb2957</guid>
            <dc:creator><![CDATA[Asish Mohanty]]></dc:creator>
            <pubDate>Thu, 07 Dec 2023 20:51:45 GMT</pubDate>
            <atom:updated>2023-12-11T03:36:04.239Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47e5ihAu6WMf30UK9h7h0g.png" /></figure><p>In the ever-evolving landscape of software development, productivity and efficiency have become paramount to success. Developers are constantly juggling multiple tasks, from navigating complex codebases to integrating third-party services, all while maintaining the highest quality standards. To address these challenges, it is crucial to equip developers with the right tools and capabilities to optimize their workflows and enhance their overall experience.</p><h3><strong>How the PayPal Visual Studio Code Extension Simplifies Developer Experience</strong></h3><p>The PayPal Visual Studio (VS) Code extension offers a streamlined way for developers to integrate PayPal checkout solutions into their projects. This tool enhances productivity by allowing the management of PayPal features directly within the VS Code environment, making the integration process more efficient and seamless.</p><p>The extension includes pre-written code samples, code snippets, and quick links, significantly reducing the effort required to integrate PayPal payment solutions. These features enable developers to concentrate on their primary tasks, improving productivity, expediting development cycles, and shortening the time-to-market for their PayPal-enabled applications.</p><p>The PayPal VS Code extension is designed to empower developers with a collection of features to enhance efficiency. Its key features are listed below.</p><p><strong>List of Features</strong></p><ol><li><strong>PayPal Samples</strong>: Developers can access and clone sample application code for PayPal’s supported integrations within the VS Code environment.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P9jeB9E04AaeHq1sOVAKtw.gif" /></figure><p>2. <strong>Code Snippets</strong>: Developers can access a library of pre-configured code snippets for API resources to speed up the integration process. These snippets can be easily inserted into their code, reducing manual effort and ensuring correct implementation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xSJd8E1dKQ9RQg1Henw3RA.gif" /></figure><p>3. <strong>PayPal Quick Links</strong>: Access developer dashboard links directly from the extension to seamlessly manage apps configuration, Sandbox data, API call logs and Webhooks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fAeZKvM44Jo65eZoiBkX7Q.png" /></figure><p>4. <strong>Command Palette</strong>: The extension supports various commands to access PayPal features through the <a href="https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette">command palette</a> of Visual Studio Code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6HYZsTrCs3LOK9BSDQzeZw.png" /></figure><h3><strong>Benefits of the PayPal Visual Studio Code Extension for Developers</strong></h3><p>The PayPal VS Code extension offers numerous benefits to the developer that streamline payment integration, enhance code quality, and elevate the overall development experience.</p><p><strong>Simplified Integration</strong></p><p>The extension’s user-friendly and intuitive interface makes it accessible to developers of all skill levels. Whether you’re a seasoned developer or just starting, the extension provides a seamless and effortless way to integrate PayPal’s payment solutions into your projects.</p><p><strong>Reduced Development Time</strong></p><p>By eliminating manual processes and simplifying PayPal integration processes, the extension frees up developers’ time, enabling them to focus on core development activities. This streamlined approach leads to significant time and effort savings, boosting productivity and efficiency.</p><p><strong>Improved Code Quality</strong></p><p>The extension’s advanced features, such as code completion contribute to improved code quality. This feature helps developers write cleaner, more robust code, reducing the risk of bugs and maintaining high development standards.</p><h3><strong>Try Out the PayPal VS Code Extension</strong></h3><p>You can <a href="https://marketplace.visualstudio.com/items?itemName=PayPal.vscode-paypal">install the extension</a> from the Visual Studio Code Marketplace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k6dNFIqYbjzsC5P4rUe8mQ.png" /></figure><p>To learn more about the PayPal VS Code extension, refer to <a href="https://developer.paypal.com/api/rest/sandbox/vsc/">PayPal developer documentation</a>.</p><p><strong>Conclusion</strong></p><p>The PayPal Visual Studio Code extension is an essential toolkit for developers aiming to enhance their productivity and improve code quality while simplifying the development process. This extension bridges PayPal’s payment solutions and VS Code seamlessly, allowing developers to focus on building innovative solutions without being hindered by technical intricacies. In an era where efficiency and effectiveness in software development are paramount, this extension is set to be a key enabler for developers around the globe helping them realize their utmost potential.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7518aaeb2957" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paypal-tech/streamlining-developer-productivity-with-the-paypal-visual-studio-code-extension-7518aaeb2957">Streamlining Developer Productivity with the PayPal Visual Studio Code Extension</a> was originally published in <a href="https://medium.com/paypal-tech">The PayPal Technology Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing Recurring Payments with Apple Pay Using PayPal]]></title>
            <link>https://medium.com/paypal-tech/managing-recurring-payments-with-apple-pay-using-paypal-826881f1ffcb?source=rss----6423323524ba---4</link>
            <guid isPermaLink="false">https://medium.com/p/826881f1ffcb</guid>
            <dc:creator><![CDATA[PayPal Tech Blog Team]]></dc:creator>
            <pubDate>Mon, 20 Nov 2023 14:41:42 GMT</pubDate>
            <atom:updated>2023-11-20T14:41:42.267Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YHB3fejoIAowFu6V__CUHQ.png" /></figure><p>Recurring payments have become an integral part of the modern digital economy, offering convenience and predictability for both consumers and businesses. Our <a href="https://medium.com/paypal-tech/apple-pay-integration-options-with-paypal-75456ee61f25">previous post</a> highlighted different methods of integrating Apple Pay® with PayPal. This blog explores recurring payments using PayPal and Apple Pay, showing how using it can streamline transactions and benefits end users.</p><p><strong>How Recurring Payments with PayPal and Apple Pay Work</strong></p><p>A recurring payment is an agreement between a buyer and a merchant. It allows the merchant to charge the buyer’s chosen payment instrument (typically a credit card) for a pre-approved amount at pre-approved intervals, which can be either fixed or variable.</p><p>Consumers visiting a merchant’s mobile website integrated with PayPal JS SDK and V3 Vault experience will find Apple Pay as one of the available payment methods for recurring payments. Once the consumer taps the Apple Pay button on the mobile website, the Apple Pay payment sheet is presented. This process mirrors the one-time Apple Pay experience for mobile web transactions.</p><p>The merchant’s website plays a crucial role in detailing the billing frequency and other terms of service. These details can also be reiterated on the payment sheet for added clarity. Recurring fees can take two forms: fixed amounts, such as monthly movie ticket subscriptions, or variable amounts like weekly grocery orders. The variability is subject to local authorizations.</p><p>Depending on the specific merchant use case, customers may be presented with line items that reiterate billing frequency, discounts, and any additional upfront fees on the consent screen. To ensure transparency, the final payment amount is prominently outlined on the total line, making customers fully aware of the charge they are authorizing.</p><p>The consumer can review the transaction details on the Apple Pay payment sheet. Once the consumer is ready, they authenticate using Face ID® or Touch ID®. When the transaction is complete, the consumer is shown the outcome before the payment sheet is dismissed, returning it to the merchant’s website.</p><p><strong>Saving Token for Future Transactions</strong></p><p>Merchants receive a persistent token, offering the flexibility to use it for immediate purchases or store it securely for future transactions. The choice depends on the merchant’s integration preferences.</p><p>When the merchant initiates an authorization request during customer order placement, successful authorization results in the secure storage of the Apple Pay instrument in the vault system. Payment indicators are utilized to ensure that critical factors like buyer authentication and card-on-file information are managed effectively, reducing the risk of rejected transactions.</p><p><strong>Enhancing Transaction Security and Efficiency with Payment Indicators</strong></p><p>The payment indicators ensure that buyer authentication, card on file, and other factors are appropriately handled. The below tables show various use cases. Pass these payment indicators to avoid rejected transactions.</p><p><strong>Use case 1. </strong>One-time transaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*7t3uF4H6D4cYAuwu.png" /></figure><p><strong>Use case 2. </strong>Recurring plan or subscription.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*tDohGjLkZBOJCvIT.png" /></figure><p><strong>Use case 3. </strong>Unscheduled Payments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*w-G-0PipG5iigwtz.png" /></figure><p>Use case 3 is used for all recurring payments where the charges are not on a fixed interval. Additional documentation is available <a href="https://developer.paypal.com/docs/checkout/save-payment-methods/during-purchase/js-sdk/applepay/">here.</a></p><p><strong>Benefits of Recurring Payments with Apple Pay Using PayPal</strong></p><p><strong>Convenience:</strong> Customers can enjoy the ease of automated recurring payments, eliminating the need for manual transactions each time a payment is due.</p><p><strong>Flexibility:</strong> Whether it’s fixed or variable recurring fees, this payment method adapts to various business models, allowing merchants to cater to a broader range of customers.</p><p><strong>Transparency:</strong> Clear presentation of billing details on the consent screen ensures that customers know exactly what they’re paying for, promotes trust, and reduces disputes.</p><p><strong>Secure Tokenization:</strong> Storing tokens for future transactions enhances security and simplifies subsequent purchases, offering peace of mind to both consumers and merchants.</p><p><strong>Reduced Rejections</strong>: Effective management of payment indicators helps prevent transaction rejections, ensuring a seamless payment experience.</p><p><strong>Conclusion</strong></p><p>Handling recurring payments provides a win-win situation for both buyers and merchants. This payment method is poised to reshape the way we handle subscription services and recurring transactions.</p><p>Apple Pay, Face ID and Touch ID are registered trademarks of Apple Inc.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=826881f1ffcb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paypal-tech/managing-recurring-payments-with-apple-pay-using-paypal-826881f1ffcb">Managing Recurring Payments with Apple Pay Using PayPal</a> was originally published in <a href="https://medium.com/paypal-tech">The PayPal Technology Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Accept E-Commerce Payments Easily with PayPal’s Buttons Component]]></title>
            <link>https://medium.com/paypal-tech/accept-e-commerce-payments-easily-with-paypals-buttons-component-2b719529e035?source=rss----6423323524ba---4</link>
            <guid isPermaLink="false">https://medium.com/p/2b719529e035</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[payments-technology]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[payments]]></category>
            <dc:creator><![CDATA[Arit Developer]]></dc:creator>
            <pubDate>Tue, 24 Oct 2023 16:07:59 GMT</pubDate>
            <atom:updated>2023-10-25T21:38:34.920Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kE0u-JmLXCFmafqAt34Qtw.png" /></figure><p>Accepting online payments is now a universal must-have, catering to everyone from solo entrepreneurs to massive global corporations.</p><p>PayPal’s Standard Checkout allows for seamless integration of PayPal’s Payment Buttons component into your e-commerce app, granting you the power to accept online payments. In this guide, I am going to show how to add Standard Checkout to a simple shopping app, built with HTML and NodeJS.</p><h4>Guide Overview</h4><p><a href="https://medium.com/paypal-tech/accept-e-commerce-payments-easily-with-paypals-buttons-component-2b719529e035#42f2">Part 1. Prerequisites</a><br><a href="https://medium.com/paypal-tech/accept-e-commerce-payments-easily-with-paypals-buttons-component-2b719529e035#e6c1">Part 2a. Basic Integration — Code Setup</a><br><a href="https://medium.com/paypal-tech/accept-e-commerce-payments-easily-with-paypals-buttons-component-2b719529e035#b047">Part 2b. Basic Integration — Checkout Flow</a><br><a href="https://medium.com/paypal-tech/accept-e-commerce-payments-easily-with-paypals-buttons-component-2b719529e035#ef04">Part 3a. Custom Integration — Code Setup</a><br><a href="https://medium.com/paypal-tech/accept-e-commerce-payments-easily-with-paypals-buttons-component-2b719529e035#99cd">Part 3b. Custom Integration — Checkout Flow</a><br><a href="https://medium.com/paypal-tech/accept-e-commerce-payments-easily-with-paypals-buttons-component-2b719529e035#45fe">Part 4. Conclusion</a><br><a href="https://medium.com/paypal-tech/accept-e-commerce-payments-easily-with-paypals-buttons-component-2b719529e035#5a33">Part 5. Additional PayPal Payment Integrations</a></p><h4>Part 1. Prerequisites</h4><p>To complete this integration, you will need the following information:</p><ul><li>API Credentials (Client ID and Secret) for a PayPal REST app: paste these from your Developer Dashboard. Since we are working in a development environment in this demo, ensure that the Sandbox Toggle is on.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W6PHASBZspQ57sHLs69_dA.png" /><figcaption>Obtain Test API Credentials</figcaption></figure><ul><li>The username and password for a Personal Sandbox account: you will need this to complete the checkout process.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F1jcej001_a09RyKLW6IzA.png" /><figcaption>Navigate to Sandbox Accounts under Testing Tools</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fJb5kv9fSnla-aWW0u-3yQ.png" /><figcaption>Obtain Personal Sandbox Account login details</figcaption></figure><p>You can grab the code for our completed Checkout Integration demo from the PayPal Developer GitHub repository.</p><h4>Part 2a. Basic Integration — Code Setup</h4><p>Navigate to PayPal’s <a href="https://developer.paypal.com/docs/checkout/standard/integrate/">Integrate Checkout documentation</a>. The documentation shows you how to set your development environment up: installing <strong>npm</strong>, verifying your <strong>package.json</strong> file, and setting up your <strong>.env</strong> file.</p><p>Next, you will set up your back-end server and front-end code. The documentation presents the contents of three files: <strong>server.js</strong> (for the back-end server), <strong>app.js</strong> (for the client-side logic) and <strong>checkout.html</strong> (for the user interface).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c44bC2Tyk9N01rhTX2Jv4w.png" /><figcaption>Copy the Backend Code</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JZmtVZfrivEKV2W6jeLLfA.png" /><figcaption>Copy the Frontend Code</figcaption></figure><p>Grab these code snippets and paste them into your IDE (Integrated Development Environment). I strongly recommend that you implement the basic integration first, and ensure that you are able to complete the Standard Checkout Flow successfully, before adding your custom e-commerce code. I find that this approach reduces potential errors and associated frustrations. 😅</p><p>In the <strong>checkout.html</strong> file, replace the word “test” within the Software Development Kit (SDK) script tag with your Client ID.</p><pre>&lt;script src=”https://www.paypal.com/sdk/js?client-id=CLIENT_ID&amp;currency=USD&quot;&gt;&lt;/script&gt;</pre><p>In the <strong>app.js</strong> file, note that the “cart” object in the response body is hard-coded with one product’s SKU and quantity information. For important security reasons, we do not pass any transaction or price amounts from the front- end. Instead, we use the SKU/ID and quantity information to look up the product(s) in a datastore and use these product details to calculate the total cart price in our back-end.</p><pre>body: JSON.stringify({<br>  cart: [<br>    {<br>      id: “YOUR_PRODUCT_ID”,<br>      quantity: “YOUR_PRODUCT_QUANTITY”,<br>    },<br>  ],<br>})</pre><p>In the <strong>server.js</strong> file, note that the transaction quantity (“100.00”) is hardcoded into the createOrder call.</p><pre>const createOrder = async (cart) =&gt; {<br>  console.log(<br>    “shopping cart information passed from the frontend createOrder() callback:”,<br>    cart,<br>  );<br><br>  const accessToken = await generateAccessToken();<br>  const url = `${base}/v2/checkout/orders`;<br>  const payload = {<br>    intent: &quot;CAPTURE&quot;,<br>    purchase_units: [<br>      {<br>        amount: {<br>          currency_code: &quot;USD&quot;,<br>          value: &quot;100.00&quot;,<br>        },<br>      },<br>    ],<br>  };<br><br>... more code ...<br>}</pre><h4>Part 2b. Basic Integration — Checkout Flow</h4><p>Start your server; on the command line, run “<strong>node server/server.js</strong>” or whichever shortcut is defined in your <strong>package.json</strong> file. You should see the PayPal Buttons component displayed on the front- end.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*H6tTZLz-UHFUXGqGsGjs1A.png" /><figcaption>PayPal Button Component — Basic Integration</figcaption></figure><p>Click the first PayPal button, which displays the Checkout modal. Note that the URL in the modal shows that we are in a sandbox environment. Sign in using your Personal Sandbox account (if you haven’t already).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3lkqJ-iNYSRAyHQeNSmrMA.png" /><figcaption>The Checkout Modal starts the checkout process</figcaption></figure><p>You are then presented with the transaction amount (at this point, this should be $100.00) and several payment options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*keqmOna2B_7YZEOXvCe_Yg.png" /><figcaption>The transaction amount is hardcoded to $100</figcaption></figure><p>Complete the transaction with the PayPal Balance option. A confirmation message should appear in your browser; its location depends on where you place the element with the id “result-message” in your application.</p><pre>&lt;p id=”result-message”&gt;&lt;/p&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*M7KGXbSqauYCw7PxyiHTIw.png" /><figcaption>Status message after completed checkout process</figcaption></figure><h4>Part 3a. Custom Integration — Code Setup</h4><p>Now, let’s add our custom e-commerce code!</p><p>In the <strong>checkout.html</strong> file, I added the code for three products being sold at the LiftOff Shop. I styled the code with TailwindCSS:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>  &lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot; /&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;<br>    &lt;title&gt;PayPal JS SDK Standard Integration Demo&lt;/title&gt;<br>    &lt;script src=&quot;https://cdn.tailwindcss.com&quot;&gt;&lt;/script&gt;<br>  &lt;/head&gt;<br>  &lt;body class=&quot;p-6&quot;&gt;<br>    &lt;h1 class=&quot;text-center text-4xl font-medium&quot;&gt;LiftOff Shop&lt;/h1&gt;<br>    &lt;main class=&quot;products flex flex-wrap justify-center&quot;&gt;<br>      &lt;div<br>        class=&quot;product text-center m-3 p-3 border border-slate-400 rounded-md&quot;<br>      &gt;<br>        &lt;img src=&quot;https://picsum.photos/id/21/200&quot; class=&quot;rounded-md&quot; /&gt;<br>        &lt;h2 class=&quot;text-xl my-2&quot;&gt;Galaxy Shoes&lt;/h2&gt;<br>        &lt;p class=&quot;text-green-600 font-medium text-lg mb-2&quot;&gt;$100&lt;/p&gt;<br>        &lt;div class=&quot;mb-3&quot;&gt;<br>          &lt;label class=&quot;text-lg&quot; for=&quot;quantity1&quot;&gt;Quantity:&lt;/label&gt;<br>          &lt;select class=&quot;text-lg&quot; id=&quot;quantity1&quot;&gt;<br>            &lt;option value=&quot;0&quot;&gt;0&lt;/option&gt;<br>            &lt;option value=&quot;1&quot;&gt;1&lt;/option&gt;<br>            &lt;option value=&quot;2&quot;&gt;2&lt;/option&gt;<br>            &lt;option value=&quot;3&quot;&gt;3&lt;/option&gt;<br>          &lt;/select&gt;<br>        &lt;/div&gt;<br>        &lt;button<br>          class=&quot;product-btn py-1 px-3 rounded-md bg-indigo-200 hover:bg-indigo-300&quot;<br>          data-product-id=&quot;hdqgapq9&quot;<br>          data-quantity-id=&quot;quantity1&quot;<br>        &gt;<br>          Add to Cart<br>        &lt;/button&gt;<br>      &lt;/div&gt;<br><br>      &lt;div<br>        class=&quot;product text-center m-3 p-3 border border-slate-400 rounded-md&quot;<br>      &gt;<br>        &lt;img src=&quot;https://picsum.photos/id/104/200&quot; class=&quot;rounded-md&quot; /&gt;<br>        &lt;h2 class=&quot;text-xl my-2&quot;&gt;Spaceship Earrings&lt;/h2&gt;<br>        &lt;p class=&quot;text-green-600 font-medium text-lg mb-2&quot;&gt;$40&lt;/p&gt;<br>        &lt;div class=&quot;mb-3&quot;&gt;<br>          &lt;label class=&quot;text-lg&quot; for=&quot;quantity2&quot;&gt;Quantity:&lt;/label&gt;<br>          &lt;select class=&quot;text-lg&quot; id=&quot;quantity2&quot;&gt;<br>            &lt;option value=&quot;0&quot;&gt;0&lt;/option&gt;<br>            &lt;option value=&quot;1&quot;&gt;1&lt;/option&gt;<br>            &lt;option value=&quot;2&quot;&gt;2&lt;/option&gt;<br>            &lt;option value=&quot;3&quot;&gt;3&lt;/option&gt;<br>          &lt;/select&gt;<br>        &lt;/div&gt;<br>        &lt;button<br>          class=&quot;product-btn py-1 px-3 rounded-md bg-indigo-200 hover:bg-indigo-300&quot;<br>          data-product-id=&quot;rnfjwsy0&quot;<br>          data-quantity-id=&quot;quantity2&quot;<br>        &gt;<br>          Add to Cart<br>        &lt;/button&gt;<br>      &lt;/div&gt;<br><br>      &lt;div<br>        class=&quot;product text-center m-3 p-3 border border-slate-400 rounded-md&quot;<br>      &gt;<br>        &lt;img src=&quot;https://picsum.photos/id/342/200&quot; class=&quot;rounded-md&quot; /&gt;<br>        &lt;h2 class=&quot;text-xl my-2&quot;&gt;Martian Tote&lt;/h2&gt;<br>        &lt;p class=&quot;text-green-600 font-medium text-lg mb-2&quot;&gt;$75&lt;/p&gt;<br>        &lt;div class=&quot;mb-3&quot;&gt;<br>          &lt;label class=&quot;text-lg&quot; for=&quot;quantity3&quot;&gt;Quantity:&lt;/label&gt;<br>          &lt;select class=&quot;text-lg&quot; id=&quot;quantity3&quot;&gt;<br>            &lt;option value=&quot;0&quot;&gt;0&lt;/option&gt;<br>            &lt;option value=&quot;1&quot;&gt;1&lt;/option&gt;<br>            &lt;option value=&quot;2&quot;&gt;2&lt;/option&gt;<br>            &lt;option value=&quot;3&quot;&gt;3&lt;/option&gt;<br>          &lt;/select&gt;<br>        &lt;/div&gt;<br>        &lt;button<br>          class=&quot;product-btn py-1 px-3 rounded-md bg-indigo-200 hover:bg-indigo-300&quot;<br>          data-product-id=&quot;zytkddw5&quot;<br>          data-quantity-id=&quot;quantity3&quot;<br>        &gt;<br>          Add to Cart<br>        &lt;/button&gt;<br>      &lt;/div&gt;<br>    &lt;/main&gt;<br><br>    &lt;p id=&quot;result-message&quot; class=&quot;mx-auto text-center text-red-600 w-1/2&quot;&gt;&lt;/p&gt;<br><br>    &lt;section class=&quot;mt-8 mx-auto flex flex-wrap w-1/2&quot;&gt;<br>      &lt;div class=&quot;mb-3 w-1/2 text-center&quot; id=&quot;cart&quot;&gt;<br>        &lt;h2 class=&quot;text-xl font-medium&quot;&gt;Cart&lt;/h2&gt;<br>        &lt;ul id=&quot;cart-items&quot;&gt;&lt;/ul&gt;<br>        &lt;p&gt;TOTAL $&lt;span id=&quot;cart-total&quot;&gt;0&lt;/span&gt;&lt;/p&gt;<br>        &lt;button<br>          id=&quot;clear-cart&quot;<br>          class=&quot;py-1 px-3 mt-3 rounded-md bg-gray-200 hover:bg-gray-300&quot;<br>        &gt;<br>          Clear Cart<br>        &lt;/button&gt;<br>      &lt;/div&gt;<br>      &lt;div class=&quot;text-center&quot; id=&quot;paypal-button-container&quot;&gt;&lt;/div&gt;<br>    &lt;/section&gt;<br><br>    &lt;script src=&quot;https://www.paypal.com/sdk/js?client-id=AYCd0wKOWs9itZ23_2XEZUhZpbZdHT_c1qcMCjqTnb6fxFE7tQBnUQGSPh3_PVQkgoBamFV1KgPUI9B4&amp;currency=USD&quot;&gt;&lt;/script&gt;<br>    &lt;script type=&quot;module&quot; src=&quot;app.js&quot;&gt;&lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*J-6lpOXHwNav2j6B_URMCw.png" /><figcaption>E-Commerce App with PayPal Buttons Component</figcaption></figure><p>In the <strong>app.js</strong> file, I added code that brings the Add-To-Cart, Calculate-Cart-Total and Clear-Cart functionalities. To calculate my cart total, I imported my product information from the products.js file, which serves as my makeshift datastore. I also updated the cart object in the response body to the <strong>cartItems</strong> array (instead of the hard-coded product from earlier).</p><pre>import { PRODUCTS } from &quot;./products.js&quot;;<br><br>const cartItems = [];<br>let cartTotal = 0;<br><br>function addToCart(productId, quantityId) {<br>  const quantitySelect = document.getElementById(quantityId);<br>  const selectedQuantity = parseInt(quantitySelect.value, 10);<br><br>  if (selectedQuantity &gt; 0) {<br>    cartItems.push({<br>      id: productId,<br>      quantity: selectedQuantity,<br>    });<br>    cartTotal = calculateCartTotal(cartItems);<br>    updateCart(cartItems);<br>  }<br>}<br><br>function calculateCartTotal(cartItems) {<br>  let total = 0;<br>  cartItems.forEach((item) =&gt; {<br>    total += item.quantity * PRODUCTS[item.id].price;<br>  });<br><br>  return total;<br>}<br><br>function updateCart(cartItems) {<br>  const cartItemsList = document.getElementById(&quot;cart-items&quot;);<br>  const cartTotalElement = document.getElementById(&quot;cart-total&quot;);<br><br>  cartItemsList.innerHTML = &quot;&quot;;<br>  cartTotalElement.textContent = cartTotal;<br><br>  cartItems.forEach((item) =&gt; {<br>    const li = document.createElement(&quot;li&quot;);<br>    li.textContent = `${PRODUCTS[item.id].name}: ${item.quantity}`;<br>    cartItemsList.appendChild(li);<br>  });<br>}<br><br>window.paypal<br>  .Buttons({<br>    async createOrder() {<br>      try {<br>        const response = await fetch(&quot;/api/orders&quot;, {<br>          method: &quot;POST&quot;,<br>          headers: {<br>            &quot;Content-Type&quot;: &quot;application/json&quot;,<br>          },<br>          // use the &quot;body&quot; param to optionally pass additional order information<br>          // like product ids and quantities<br>          body: JSON.stringify({<br>            cart: cartItems,<br>          }),<br>        });<br><br>... more code ...<br><br>... more code ...<br>  })<br>  .render(&quot;#paypal-button-container&quot;);<br><br>// Example function to show a result to the user. Your site&#39;s UI library can be used instead.<br>function resultMessage(message) {<br>  const container = document.querySelector(&quot;#result-message&quot;);<br>  container.innerHTML = message;<br>}<br><br>// Event Listeners<br>const productBtns = document.querySelectorAll(&quot;.product-btn&quot;);<br>productBtns.forEach((btn) =&gt; {<br>  btn.addEventListener(&quot;click&quot;, (e) =&gt; {<br>    const productId = e.target.dataset.productId;<br>    const quantityId = e.target.dataset.quantityId;<br>    addToCart(productId, quantityId);<br>  });<br>});<br><br>// clear cart<br>document.getElementById(&quot;clear-cart&quot;).addEventListener(&quot;click&quot;, () =&gt; {<br>  // clear cart items, without reassigning the array<br>  cartItems.length = 0;<br>  cartTotal = 0;<br>  updateCart(cartItems);<br>});</pre><p>In the <strong>server.js</strong> file, I imported my products from <strong>products.js</strong> and added a function that calculates the transaction amount using the cart contents. In the <strong>createOrder</strong> call, I replaced the hardcoded transaction value with the calculated cart value.</p><pre>import express from &quot;express&quot;;<br>import fetch from &quot;node-fetch&quot;;<br>import &quot;dotenv/config&quot;;<br>import path from &quot;path&quot;;<br>import { PRODUCTS } from &quot;../client/products.js&quot;;<br><br>... more code ...<br>... more code ...<br><br>function calculateTotalPrice(cart) {<br>  let totalPrice = 0;<br>  for (let i = 0; i &lt; cart.length; i++) {<br>    totalPrice += PRODUCTS[cart[i].id].price * cart[i].quantity;<br>  }<br>  return totalPrice.toString();<br>}<br><br>/**<br> * Create an order to start the transaction.<br> * @see https://developer.paypal.com/docs/api/orders/v2/#orders_create<br> */<br>const createOrder = async (cart) =&gt; {<br>  // use the cart information passed from the front-end to calculate the purchase unit details<br>  console.log(<br>    &quot;shopping cart information passed from the frontend createOrder() callback:&quot;,<br>    cart<br>  );<br><br>  const accessToken = await generateAccessToken();<br>  const url = `${base}/v2/checkout/orders`;<br>  const payload = {<br>    intent: &quot;CAPTURE&quot;,<br>    purchase_units: [<br>      {<br>        amount: {<br>          currency_code: &quot;USD&quot;,<br>          value: calculateTotalPrice(cart),<br>        },<br>      },<br>    ],<br>  };<br><br>  ... more code ...<br>};<br><br>... more code ...</pre><h4>Part 3b. Custom Integration — Checkout Flow</h4><p>Restart the server and add some products to the cart; I chose one of each item, totaling $215.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BWjo5jzRfCVRtslfot9nRQ.png" /><figcaption>Cart total showing total amount of cart items</figcaption></figure><p>Click the gold PayPal button to activate Checkout (signing in with your Personal Sandbox account, if necessary). You should see that the transaction amount is the value of your cart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*HaKD4hIaF9YgG14VB2jzOw.png" /><figcaption>Transaction value in the Checkout modal is equal to the cart amount</figcaption></figure><p>Go ahead and complete the purchase. You should see a confirmation message in the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*LA8kQMJFsehGGdeQdC_aDw.png" /><figcaption>Confirmation of successful checkout in browser</figcaption></figure><h4>Part 4. Conclusion</h4><p>This demo introduced a straightforward integration of PayPal’s Standard Checkout, using the PayPal Buttons component. You may customize your further, to meet your use cases. Read our Checkout Documentation for <a href="https://developer.paypal.com/docs/checkout/standard/customize/">examples of these customizations</a>. The PayPal Developer <a href="https://github.com/paypaldev">GitHub repository</a> also has several examples of integrations within various code environments, such as React and Angular.</p><h4>Part 5. Additional PayPal Payment Integrations</h4><ul><li><a href="https://developer.paypal.com/docs/checkout/pay-later/us/">Pay Later</a></li><li>Custom Debit/Credit Card fields (<a href="https://developer.paypal.com/docs/checkout/advanced/integrate/">Advanced Checkout</a>)</li></ul><blockquote><strong><em>Join the PayPal Developer Community!<br></em></strong><em>Our Developer Community members support each other in integrating PayPal technologies, contributing to open source, expanding knowledge and networks, and improving PayPal’s products and documentation. We’d love to have you join us! 💙<br>- </em><a href="https://developer.paypal.com/"><em>Website</em></a><em><br>- </em><a href="https://twitter.com/paypaldev"><em>Twitter</em></a><em><br>- </em><a href="https://github.com/paypal"><em>GitHub</em></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b719529e035" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paypal-tech/accept-e-commerce-payments-easily-with-paypals-buttons-component-2b719529e035">Accept E-Commerce Payments Easily with PayPal’s Buttons Component</a> was originally published in <a href="https://medium.com/paypal-tech">The PayPal Technology Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>