Understanding Web Services Architecture with a Focus on PayPal

Slide Note
Embed
Share

This presentation delves into the intricate details of Web Services Architecture, particularly focusing on PayPal APIs such as NVP/SOAP. It explains the components of a PayPal API request, including API credentials and call formats, providing insights into the mechanisms behind service requests and validations. Through a detailed exploration, the content sheds light on the essential elements that enable seamless communication between service providers and requesters in the realm of e-commerce implementation.


Uploaded on Oct 04, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Web Services (with a Focus on Paypal) Francisco Rivera CYBI 6314 E-Commerce Implementation The University of Texas Rio Grande Valley Note: This presentation is for learning purposes. Actual Paypal policies supersede any information presented here.

  2. Web Service Architecture The service provider sends a WSDL file to UDDI. The service requester contacts UDDI to find out who is the provider for the data it needs, and then it contacts the service provider using the SOAP protocol. The service provider validates the service request and sends structured data in an XML file, using the SOAP protocol. This XML file would be validated again by the service requester using an XSD file. Source: https://en.wikipedia.org/wiki/Web_service

  3. Get Started with Paypal NVP/SOAP APIs: Components of a Paypal API Request Source: https://developer.paypal.com/docs/nvp-soap-api/gs-PayPalAPIs/ Call Element API Credentials Description Many API calls require a set of values to authenticate you as the owner of a PayPal account. The NVP/SOAP API credentials are assigned to your PayPal account and consist of an API Username, an API Password, and a Signature. Some API calls (such as those in the Adaptive APIs) also require an AppID value. An API request can be sent to either the sandbox endpoint or the Production endpoint. The endpoint you use depends on several conditions, such as the API operation you're calling, the environment you're addressing, and the format of your call. Each PayPal API call has both required and optional input fields that detail the specifics of the request. Together, these input fields are termed the call payload. PayPal supports calls made using both SOAP and non-SOAP formats. In addition, call payloads can be formatted in JSON and NVP. PayPal API operations require you provide specific HTTP headers with your requests. The headers specify authentication credentials, the call request and response formats, and other information. For example, when calling either the Adaptive Payments or Adaptive Accounts APIs, you need to specify your App ID in the X-PAYPAL-APPLICATION-ID header. You specify the format of the request and response using two separate headers, X-PAYPAL-REQUEST-DATA-FORMAT and X-PAYPAL-RESPONSE-DATA-FORMAT. Service Endpoint Call Payload Call Formats HTTP Headers

  4. 1. <?xml version="1.0" encoding="UTF-8"?> 2. <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 3. <SOAP-ENV:Header> 4. <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI"> 5. <Credentials xmlns="urn:ebay:apis:eBLBaseComponents"> 6. <Username>API-Username</Username> 7. <Password>API-Password</Password> 8. <Signature/> 9. <Subject/> 10. </Credentials> 11. </RequesterCredentials> 12. </SOAP-ENV:Header> 13. <SOAP-ENV:Body> 14. <Specific-API-Name-Req xmlns="urn:ebay:api:PayPalAPI"> 15. <Specific-API-Name-Request> 16. <Version xmlns="urn:ebay:apis:eBLBaseComponents">API-Version</Version> 17. <Required-Or-Optional-Fields xs:type="Type">Data</Required-Or-Optional-Fields> 18. </Specific-API-Name-Request> 19. </Specific-API-Name-Req> 20. </SOAP-ENV:Body> 21. </SOAP-ENV:Envelope> Get Started with Paypal NVP/SOAP APIs: Components of a Paypal API Request Source: https://developer.paypal.com/docs/nvp- soap-api/gs-PayPalAPIs/

  5. Technical Flow Source: https://developer.paypal.com/docs/business/checkout/set-up-standard-payments/integrate/

  6. Integrating Paypal Payment into Online Store IPN Instant Payment Notification Source: https://phppot.com/php/paypal-payment-gateway-integration-in-php/

  7. Files Needed to Integrate Paypal into Online Store cancel.php Send this URL to Paypal and Paypal directs buyers to this page when the buyer cancels the purchase. index.php This is the landing page where buyers select products to buy and fill in payment form. notify.php (ipn.php) This is a php file that does not display anything on web page but only updates the database tables depending upon message received from Paypal in (IPN) response. return.php (success.php)- Send this URL to Paypal and Paypal directs buyers to this URL when purchase is successful. The return.php file must (1) communicate to the buyer that the payment was made and the transaction was completed, and (2) explain that payment transaction details are emailed to the buyer. paypal_integration_ php/ config.php dbConnect.php index.php success.php cancel.php ipn.php css/ style.css images/ Source: https://www.codexworld.com/paypal-standard-payment-gateway-integration-php/

  8. Return URL Return URL Auto return for website payments Auto return for website payments brings your buyers back to your website immediately after completing a payment. Auto return applies to PayPal website payments, including buy now payments, donations, subscriptions, and shopping cart payments. Return URL requirements: Enter the URL that will be used to redirect your customers after a payment. This URL must meet the guidelines detailed below. According to our User Agreement, you must explain to the buyer on the page displayed by the return URL that the payment has been made and the transaction completed. You must explain on the page displayed by the return URL that payment transaction details will be emailed to the buyer. Example: Thank you for your payment. Your transaction has been completed, and a receipt for your purchase has been emailed to you. Log into your PayPal account to view transaction details. Source: https://www.paypal.com/us/smarthelp/article/how-do-i-use-paypal's-auto-return-feature-to-redirect-customers-back-to-my-website-faq3651

  9. Put a Paypal Button on Your Website (index.php) Sample JavaScript SDK Code to Add Paypal Button (Part 1 of 3) (source: https://developer.paypal.com/docs/business/checkout/set-up-standard-payments/integrate/ ) <!DOCTYPE html> <html> <head> </head> <body> <script src="https://www.paypal.com/sdk/js?client-id=test"></script> <div id="paypal-button-container"></div> <script> paypal.Buttons({ //set up button style style: { layout: 'vertical', color: 'white', shape: 'pill', label: 'pay' }, Replace test with your client-ID from your sandbox Business account.

  10. Sample JavaScript SDK Code to Add Paypal Button (Part 2 of 3) (source: https://developer.paypal.com/docs/business/checkout/set-up-standard-payments/integrate/ ) // Sets up the transaction when a payment button is clicked createOrder: function(data, actions) { return actions.order.create({ purchase_units: [{ amount: { value: document.getElementById("orderTotal").innerHTML //'0.03' //Can reference variables or functions. Example: `value: document.getElementById('...').value` } }] }); },

  11. Sample JavaScript SDK Code to Add Paypal Button (Part 3 of 3) (source: https://developer.paypal.com/docs/business/checkout/set-up-standard-payments/integrate/ ) See next slide for output from these yellow highlights. // Finalize the transaction after payer approval onApprove: function(data, actions) { return actions.order.capture().then(function(orderData) { // Successful capture! For dev/demo purposes: // console.log('Capture result', orderData, JSON.stringify(orderData, null, 2)); // var transaction = orderData.purchase_units[0].payments.captures[0]; // alert('Transaction '+ transaction.status + ': ' + transaction.id + '\n\nSee console for all available details'); // When ready to go live, remove the alert and show a success message within this page. For example: // var element = document.getElementById('paypal-button-container'); // element.innerHTML = ''; // element.innerHTML = '<h3>Thank you for your payment!</h3>'; // Or go to another URL: actions.redirect('thank_you.html'); actions.redirect('https://www.ahd-tx.com/paypalReturn.php'); }); } }).render('#paypal-button-container'); </script> </body> </html>

  12. "shipping": { "name": { "full_name": "John Doe" }, "address": { "address_line_1": "1 Main St", "admin_area_2": "San Jose", "admin_area_1": "CA", "postal_code": "95131", "country_code": "US" } }, "payments": { "captures": [ { "id": "30N14892T9551892U", "status": "COMPLETED", "amount": { "currency_code": "USD", "value": "0.10" }, "final_capture": true, "seller_protection": { "status": "ELIGIBLE", "dispute_categories": [ "ITEM_NOT_RECEIVED", "UNAUTHORIZED_TRANSACTION" ] }, "create_time": "2021-11-10T13:37:53Z", "update_time": "2021-11-10T13:37:53Z" } ] } } ], "payer": { "name": { "given_name": "John", "surname": "Doe" }, "email_address": "sb-irv9r7761794@personal.example.com", "payer_id": "D3LAD65YPUCSG", "address": { "country_code": "US" } }, "create_time": "2021-11-10T13:37:36Z", "update_time": "2021-11-10T13:37:53Z", "links": [ { "href": "https://api.sandbox.paypal.com/v2/checkout/orders/2A091397UU449 230C", "rel": "self", "method": "GET" } ] } Output for Development and Demo Purposes Capture result Object { "id": "2A091397UU449230C", "intent": "CAPTURE", "status": "COMPLETED", "purchase_units": [ { "reference_id": "default", "amount": { "currency_code": "USD", "value": "0.10" }, "payee": { "email_address": "sb- ek6ph7764078@business.example.com", "merchant_id": "Q7XH2L4AT78SS" },

  13. Error

  14. Screenshot of Recent Notifications on My Sandbox Business Account

  15. Screenshot of an Order that is Ready for Payment on my Website

  16. Screenshot after Clicking on Paypal Button and Login in to my Sandbox Personal Paypal Account

  17. Screenshot after Clicking on Make Payment in Paypal Screen.

  18. Screenshot of Updated Notifications on My Sandbox Business Paypal Account

  19. Fees for Using Paypal There are no setup costs, credit application fees, gateway fees, downgrade penalties, cancellation charges, or monthly fees. Transaction fees are calculated as follows. Standard Rate Merchant Rate The standard rate for receiving payments for goods and services is 2.9%. For more information, see PayPal's Merchant Fees. For details on the meanings of these codes, see AVS, CVV2, and payment advice response codes. If your transactions typically average less than $10.00, you could save money with our "5% plus 5 " rate. For more information, see MicroPayment Discounts on the PayPal Merchant Fees page. https://developer.paypal.com/docs/archive/button-manager/?_ga=2.251839817.1987520847.1636501709- 1495396839.1636501709&_gac=1.260186623.1636507997.CjwKCAjw-ZCKBhBkEiwAM4qfF3QoYTp4Onjr6y8LlGe- XcN7YZXPnR1RFp-JG9m_bK3Lil8vmTG7exoCTa0QAvD_BwE

  20. To Get This Done You may use the sample SDK code found on the Paypal website: https://developer.paypal.com/docs/business/checkout/set-up- standard-payments/integrate/ Steps that I followed to do this. 1. Establish a business account on Paypal (called a production account). Use that business account to establish a sandbox business account on Paypal and a sandbox personal account on Paypal. 2. Find the client-id that you will use to communicate as a business with Paypal in the sandbox. I found this by logging into my production Paypal account and clicking on Developer (top menu). Then clicking on My Accounts under my name (top right). This caused sandbox menu to appear on the left. Click on the Accounts under Sandbox (on the left). Your default sandbox accounts should be listed. Click on the dots under Manage Accounts for your sandbox business account. Click on API credentials. Click on the name of the default application. There, you will find your sandbox business Client ID. (If there is an easier way to get this, let me know.) 3. Copy the code from the paypal website as described above and enter your client-id in place of test . 4. I also set up index.php, return.php, notify.php, and cancel.php.

  21. Assignment for Web Services Assignment for Web Services Write code for your website, in whatever language you prefer, to complete a transaction of funds in the Paypal sandbox environment between a business account and a personal account. Questions? Send your code in a Word document to me at francisco.rivera02@utrgv.edu. Due date: ?

More Related Content