npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cdif-paypal

v0.0.3

Published

Paypal support for common device interconnect framework

Downloads

4

Readme

Introduction

CDIF's PayPal support

Notes to PayPal support in CDIF

Based on official PayPal REST SDK, this module provides concept proof and basic PayPal payment and payouts API support to CDIF. For now all PayPal API calls done through CDIF framework are forced in sandbox mode so no real transactions will happen.

To use this feature, user may need to register PayPal sandbox account and use the related account or credit card information to complete a test payment.

CDIF's PayPal device model is created based on PayPal REST API interface

Example to create and execute a PayPal payment:

To list payment resources:

curl -H "Content-Type: application/json" -X POST -d '{"serviceID": "urn:paypal-com:serviceID:payment","actionName":"list", "argumentList":{"config":{"mode":"sandbox","client_id":"client_id","client_secret":"client_secret"}, "listArgs":{"count":2}, "result":{}}}' http://localhost:3049/device-control/9d0b29bd-b25f-4632-9a1a-d62e85d3ad4f/invoke-action

To create a immediate payment with credit card:

curl -H "Content-Type: application/json" -X POST -d '{"serviceID": "urn:paypal-com:serviceID:payment","actionName":"createWithCard", "argumentList":{"config":{"mode":"sandbox","client_id":"client_id","client_secret":"client_secret"},"intent":"sale","payer":{"payment_method":"credit_card","funding_instruments":[{"credit_card":{"type":"visa","number":"credit card number","expire_month":"03","expire_year":"2021","cvv2":"123","first_name":"Margaret","last_name":"Eva","billing_address":{"line1":"52 N Main ST","city":"Johnstown","state":"OH","postal_code":"43210","country_code":"US"}}}]},"transactions":[{"amount":{"total":"19","currency":"USD","details":{"subtotal":"15","tax":"3","shipping":"1"}},"description":"This is the payment transaction description."}], "result":{}}}' http://localhost:3049/device-control/9d0b29bd-b25f-4632-9a1a-d62e85d3ad4f/invoke-action

To create a payment with paypal:

curl -H "Content-Type: application/json" -X POST -d '{"serviceID": "urn:paypal-com:serviceID:payment","actionName":"createWithPayPal", "argumentList":{"config":{"mode":"sandbox","client_id":"client_id","client_secret":"client_secret"},"intent":"authorize","payer":{"payment_method":"paypal"},"redirect_urls":{"return_url":"http://return.url","cancel_url":"http://cancel.url"},"transactions":[{"item_list":{"items":[{"name":"item","sku":"item","price":"19.00","currency":"USD","quantity":1}]},"amount":{"currency":"USD","total":"19.00"},"description":"This is the payment description."}], "result":{}}}' http://localhost:3049/device-control/9d0b29bd-b25f-4632-9a1a-d62e85d3ad4f/invoke-action

Client web app would need to provide its own return or cancel URL endpoint so after user login to PayPal authorization page and approved this payment, paymentID and payer_id will be carried back in query string parameters on the return URL

To execute the above approved payment:

curl -H "Content-Type: application/json" -X POST -d '{"serviceID": "urn:paypal-com:serviceID:payment","actionName":"execute", "argumentList":{"config":{"mode":"sandbox","client_id":"client_id","client_secret":"client_secret"},"paymentID":"paymentID", "executeArgs":{"payer_id":"payer_id", "transactions":[{"amount":{"currency":"USD","total":"19.00"}}]}, "result":{}}}' http://localhost:3049/device-control/9d0b29bd-b25f-4632-9a1a-d62e85d3ad4f/invoke-action

To send a payout:

curl -H "Content-Type: application/json" -X POST -d '{"serviceID": "urn:paypal-com:serviceID:payouts","actionName":"create", "argumentList":{"config":{"mode":"sandbox","client_id":"client_id","client_secret":"client_secret"}, "sender_batch_header":{"sender_batch_id":"12332171","email_subject":"Youve got a payment"},"items":[{"recipient_type": "EMAIL","amount":{"value": 9.0,"currency": "USD"},"receiver":"[email protected]","note":"Thank you","sender_item_id": "item_3"}], "sync_mode":"true","result":{}}}' http://localhost:3049/device-control/9d0b29bd-b25f-4632-9a1a-d62e85d3ad4f/invoke-action

When received a specific event notification from CDIF or other sources, PayPal merchants may invoke these interfaces to create payment for buyers or issue payouts without need to integrate PayPal SDK in their apps.

Many of the schema files are copied and updated from PHP PayPal Client. Thanks!

See following links for more details:

Common device interconnect framework

PayPal Node SDK