Pi Payments and Pi SDK & Sandbox | Pi Workshop | Pi Network Payments

Pi Payments is a new cryptocurrency payment service that uses Pi Wallets to securely store, manage and process payments, transactions, and other sensitive data. It can be used with any payment processor that supports blockchain transactions and allows payment amounts to be set to any value. Pi Payments is a Pi-based private cloud with built-in security and privacy features that gives users the freedom to run and manage their Pi payments businesses the way they want. With Pi Payments, you can run your business on your desktop or Pi.

The Pi Network is a new cryptocurrency that is designed to have several uses. One of them is to make digital payments with a Raspberry Pi. While it is an interesting project, it does not have enough people behind it to make it rise into the top of the cryptocurrency ranking. We hope to bring more resources and activities to this project in order to make it stronger and better.

Payment using Pis and Pi SDK & Sandbox | Pi Workshop | Pi Network Payments 9

Welcome to another Hackathon Workshop video :). This week our Core Team developer Hakkyung will show you how to utilize Pi Payments and Pi SDK & Sandbox when building your app. Tap the videos on the home screen above to learn more about how to #Buildpi2gether!

Building using the Raspberry Pi SDK

Developers may use the Pi SDK to create apps that work with the Pi money and Pi Platform. To install and utilize the Pi SDK, follow the instructions.

Pi Payment

We’re introducing the Pi App Engine today for developers who wish to use Pi Core Team’s scalable server infrastructure to create and distribute Pi applications, particularly Ecosystem apps. Check out our Hackathon workshop films, where two Core Team members will teach you how to use the Developer Portal and Pi App Engine, by tapping the Read More icon on the home screen.

Pi Payments and Pi SDK & Sandbox | Pi Workshop | Pi Network PaymentsPi Brainstorm | Pi Brainstorm Kya Hai | What is Pi Brainstorm?

The goal of this app is to include all Pioneers in the development of the Pi ecosystem. The app aims to channel the creativity, collective knowledge, skills, and support of our huge community of over 10 million active Pioneers into real-world apps, utilities, and ecosystem development, all of which are critical to Pi’s success. Brainstorming with Pi

Initialization

Add the following script tags to any sites where the Pi Apps SDK is needed:

The following keys are accepted by the config object provided to the init function:

  • version (string, needed) – this is necessary to guarantee that your program is compatible with subsequent SDK versions that may include breaking changes (in which case breaking changes will be implemented under a higher version number)
  • sandbox: (boolean, optional) – allows you to execute the SDK in a sandbox.

In sandbox mode, use the SDK:

If you’ve established a development URL in the developer portal, you may now execute your app in the sandbox environment (https://sandbox.minepi.com). To setup this and see your Sandbox URL, go to the developer portal by visiting develop.pi in the Pi Browser.

Typically, if you’re using a framework or a boilerplate that supports it, you should be able to set up your sandbox flag to match your development environment. For example, most good Node boilerplates will set up the value of process.env.NODE_ENV to either “development” or “production”, and you could do something like: Pi.init({ version: “2.0”, sandbox: <%= process.env.NODE_ENV !== ‘production’ %> }). This depends on your setup, but running the Pi SDK in sandbox mode will generally happen whenever your app is running in development.

Authentication

Promise: Pi.authenticate(scopes: Array, onIncompletePaymentFound: Function, onIncompletePaymentFound: Function)

Value returned:

type AuthResult = accessToken: string, user: uid: string, username: string, type AuthResult = type AuthResult = type AuthResult = type AuthResult = type AuthResult = type AuthResult = type AuthResult = type AuthResult = type AuthResult =

scopes

Usernames and payments are among the scopes that are available.

Currently unimplemented

Currently, all calls to the authenticate method are assumed to have requested all scopes — that is, all calls are treated as if the first parameter was [‘username’, ‘payments’]. When calling authenticate, however, you should only add the scopes that your app requires. Prior to the public release of the Pi platform, scopes support will be implemented.

The following is a list of the different keys accessible on the AuthResult[‘user’] object, as well as the scopes that must be present for those keys to be present:

Field Description Scope Requirement
uid The user’s app-local identification. This is unique to this person and this application. If the user revokes the rights they gave to your app, it will alter. (none)
username The Pi username of the user. username

onIncompletePaymentFound

Signature: (payment: PaymentDTO) => void

When a user is authorized and tries to start a new payment flow, the SDK checks to see whether the user has any outstanding payments. In this context, an unfinished payment is one that has been sent to the Pi blockchain but still has status.developer completed set to false (i.e. the developer has not called the /complete endpoint on this payment).

This callback will be called using the payment’s PaymentDTO if an incomplete payment is discovered.

It is your duty to fulfill the appropriate payment when this callback is triggered (you should most likely send the payment DTO to your server, and process it according to your business logic). You’ll need to accomplish this before you can ask the user for a fresh payment.

Payments

To make a new payment, follow these steps:

type PaymentData = { amount: number, memo: string, metadata: Object, }; type PaymentCallbacks = { onReadyForServerApproval: (paymentId: string) => void, onReadyForServerCompletion: (paymentId: string, txid: string) => void, onCancel: (paymentId: string) => void, onError: (error: Error, payment?: PaymentDTO) => void, }; Pi.createPayment(paymentData: PaymentData, callbacks: PaymentCallbacks): void;

The paymentData and callbacks arguments are sent to the createPayment method.

It will instantly begin the payment flow, which will appear on top of your app, allowing the user to evaluate the payment and either submit or reject the blockchain transaction.

Payments are being made at the same time.

If there is an open payment with your app for the current user while making a new payment:

  • The open payment will be revoked if the user has not yet completed the blockchain transaction.
  • The new payment will be denied (onError will be called) if the user has already completed the blockchain transaction, and the onIncompletePaymentFound callback that was provided to the authenticate function will be triggered with the current payment (use this callback to resolve the situation, e.g by sending the previous payment to your server for server-side completion).

paymentData keys:

amount

This is the amount the user will be charged by your app.

Example: 3.1415.

memo

For this payment, a note is required. The user will see this on the payment confirmation page. Use this to describe what the user is paying for in a few words.

Digital cat #1234, for example.

metadata

This payment may have any Javascript object attached to it. This is for your personal use only. This object should be used to connect this payment to your own business logic.

OrderId: 1234, itemIds: [11, 42, 314] as an example

callbacks keys:

onReadyForServerApproval

Signature: (paymentId: string) => void

When the payment identification (paymentId) is received from Pi Servers, this is called.

Send the paymentId to your backend for Server-Side Approval using this callback. On the dedicated Payments page, you can learn more about Server-Side Approval and the whole payment procedure.

onReadyForServerCompletion

Signature: (paymentId: string, txid: string) => void

When the user has submitted the transaction to the Pi blockchain, this is called.

Send the blockchain transaction identification (txid) and paymentId to your backend for Server-Side Completion using this callback. On the dedicated Payments page, you can learn more about Server-Side Completion and the whole payment procedure.

onCancel

Signature: (paymentId: string) => void

When a payment is canceled, this is referred to as (by a user action, or programmatically).

The payment may be canceled because the user refused it directly or because of another blocking situation: the user does not have sufficient money on their account to complete the payment, another payment has been made simultaneously…

onError

Signature: (error: Error, payment?: PaymentDTO) => void

This is what it’s called when there’s a problem with the payment and it can’t be completed. The second parameter will be available if the payment has been made, and you may utilize it to analyze the problem. Only the first argument will be supplied otherwise.

Type PaymentDTO

The parameters provided to onIncompletePaymentFound and onError are of this kind.

PaymentDTO = identifier: string, type PaymentDTO = identifier: string, type PaymentDTO = identifier: string, type PaymentDTO = identifier: / The user uid: string payment identification / The quantity of the user’s app-specific ID: number, / Payment amount memo: string, $$$$$$$$$$$$$$$$ / The following is a string supplied by the developer and shown to the user metadata: Object, to address: string, to address: string, to address: string, to address: string, to address: string, to address / The blockchain transaction’s recipient address created at: string, / The time when the payment was made. / The following are the status flags that reflect the current condition of this payment status: developer approved: boolean, / Server-Side Approval transaction verified: boolean, / Blockchain transaction verified developer completed: boolean, / Server-Side Completion cancelled: boolean, / Cancelled by the developer or by Pi Network user cancelled: boolean, / Cancelled by the user string, txid: / The transaction’s id on the blockchain verified: boolean, / True if the transaction matches the payment, false else _link: string, / A link to the operation on the Blockchain API,

Participate in the conversation

To open a native share dialog, do the following:

openShareDialog(title: string, message: string): void; Pi.openShareDialog(title: string, message: string): void;

This technique will launch a native Share dialog (supplied by the phone’s operating system), allowing your users to share material from your app with their peers.

The JS SDK is a frontend SDK that can be used in HTML pages and Single-Page Apps that are delivered in the Pi Browser.

You must declare your applications on the Developer Portal in order for the SDK to work properly (open develop.pi in the Pi Browser to access the Developer Portal).

This SDK isn’t intended for NodeJS apps that run on the server.

Installation

Add the following script tags to any sites where the Pi Apps SDK is needed:

The Pi Network JS SDK will be loaded as a global window as a result of this. Pi object.

Usage

Verify a user’s identity.

You can’t do anything with the user until you’ve properly authenticated them (such reading their information or requesting a payment from them). They will be prompted with a dialog asking for their permission to share their data with your app for the first time.

/ Verify the user’s identity and get authorization to request money from them: [‘payments’] const scopes = / ; In the SDK documentation, you may learn more about this callback: /*… */ function onIncompletePaymentFound(payment) authenticate.pi (scopes, onIncompletePaymentFound). then(function(auth) console.log(Hi there! You’re ready to pay! );). if(function(error) console.error(error); if(function(error) console.error(error); if(function(error) console.error(error); if

Make a payment request

The createPayment function allows you to request a payment to your app’s account from the current user.

The Pi Wallet will provide the user with a modal that allows them to sign the transaction and send it to the Pi blockchain.

Pi.createPayment( / Amount to be paid: amount: 3.14, / Amount to be paid: amount: 3.14, / Amount to be paid: amount: 3.14, / Amount to be paid: amount: 3.14 The user will be given an explanation of the payment: “…”, for example, “Digital kitten #1234”, / An arbitrary metadata object supplied by the developer – for your own use: metadata: /*… */, / for example: kittenId: 1234, / You’ll need to implement callbacks, which you can learn more about in the full documentation linked below: onReadyForServerApproval: function(paymentId) /*… */, onReadyForServerCompletion: function(paymentId, txid) /*… */, onCancel: function(paymentId) /*… */, onError: function(error, payment) /*… */, onError: function(error, payment) /*… */,);

This code block is a simplified version to show you how it works.

The payment must go through a Server-Side Approval flow and a Server-Side Completion flow to ensure that all parties involved (your app, your server, the Pi servers, and the Pi blockchain) are in sync.

Please refer to the following:

Demonstration Pi App

You may use the Pi Browser to check out the sample Pi App. Simply enter demo.pi into the Pi Browser’s address box.

Related Tags

This article broadly covered the following related topics:

  • stripe api
  • stripe api docs
  • stripe subscription
  • stripe payment methods
  • stripe subscription api

Get in Touch

Related Articles

Best Crypto Staking Yields: What’s Yielding the Most?

Crypto staking is a pretty simple concept. Think of it as an alternative to mining where you earn crypto without having to invest your...

Ether Sets Consecutive All-Time Highs in the First Week of November, Expect More – Ethereum Weekly

One of the hottest cryptocurrencies, ether (ETH) is trading at an all-time high. The price has increased over 300% in the last month and...

American payments firm Square logs over $1 billion in Bitcoin revenue |

Square, the payments company behind popular apps like Square Cash and Square Wallet, made $1 billion in Bitcoin revenue for 2018. The “chime bank crackdown”...

Latest Posts

Best Crypto Staking Yields: What’s Yielding the Most?

Crypto staking is a pretty simple concept. Think of it as an alternative to mining where you earn crypto without having to invest your...

Ether Sets Consecutive All-Time Highs in the First Week of November, Expect More – Ethereum Weekly

One of the hottest cryptocurrencies, ether (ETH) is trading at an all-time high. The price has increased over 300% in the last month and...

American payments firm Square logs over $1 billion in Bitcoin revenue |

Square, the payments company behind popular apps like Square Cash and Square Wallet, made $1 billion in Bitcoin revenue for 2018. The “chime bank crackdown”...

VanEck set to become second Bitcoin ETF in the U.S. |

The SEC has approved the Winklevoss Bitcoin ETF, which will be listed on NASDAQ under ticker symbol COIN. VanEck’s ETF is also expected to...

XRP Remains rather Stagnant as Bitcoin’s Market Dominance Increases

Bitcoin’s dominance is on the rise. XRP has yet to show any real signs of life, even though it remains one of the most...