Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pay with pi README.md #202

Open
wants to merge 12 commits into
base: PI-6743-a-user-can-refund-an-order
Choose a base branch
from
71 changes: 71 additions & 0 deletions Payment
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"_links": {
"self": {
"href": "https://api.mainnet.minepi.com/accounts/GBBB3DGTFM5AGPCJIIBH5QGSBLVEBB4GKQ7AV2JDT2ITMU7ZQKKOA2N7"
},
"transactions": {
"href": "https://api.mainnet.minepi.com/accounts/GBBB3DGTFM5AGPCJIIBH5QGSBLVEBB4GKQ7AV2JDT2ITMU7ZQKKOA2N7/transactions{?cursor,limit,order}",
"templated": true
},
"operations": {
"href": "https://api.mainnet.minepi.com/accounts/GBBB3DGTFM5AGPCJIIBH5QGSBLVEBB4GKQ7AV2JDT2ITMU7ZQKKOA2N7/operations{?cursor,limit,order}",
"templated": true
},
"payments": {
"href": "https://api.mainnet.minepi.com/accounts/GBBB3DGTFM5AGPCJIIBH5QGSBLVEBB4GKQ7AV2JDT2ITMU7ZQKKOA2N7/payments{?cursor,limit,order}",
"templated": true
},
"effects": {
"href": "https://api.mainnet.minepi.com/accounts/GBBB3DGTFM5AGPCJIIBH5QGSBLVEBB4GKQ7AV2JDT2ITMU7ZQKKOA2N7/effects{?cursor,limit,order}",
"templated": true
},
"offers": {
"href": "https://api.mainnet.minepi.com/accounts/GBBB3DGTFM5AGPCJIIBH5QGSBLVEBB4GKQ7AV2JDT2ITMU7ZQKKOA2N7/offers{?cursor,limit,order}",
"templated": true
},
"trades": {
"href": "https://api.mainnet.minepi.com/accounts/GBBB3DGTFM5AGPCJIIBH5QGSBLVEBB4GKQ7AV2JDT2ITMU7ZQKKOA2N7/trades{?cursor,limit,order}",
"templated": true
},
"data": {
"href": "https://api.mainnet.minepi.com/accounts/GBBB3DGTFM5AGPCJIIBH5QGSBLVEBB4GKQ7AV2JDT2ITMU7ZQKKOA2N7/data/{key}",
"templated": true
}
},
"id": "GBBB3DGTFM5AGPCJIIBH5QGSBLVEBB4GKQ7AV2JDT2ITMU7ZQKKOA2N7",
"account_id": "GBBB3DGTFM5AGPCJIIBH5QGSBLVEBB4GKQ7AV2JDT2ITMU7ZQKKOA2N7",
"sequence": "14441973562198312",
"subentry_count": 0,
"last_modified_ledger": 17326236,
"last_modified_time": "2024-10-21T15:49:58Z",
"thresholds": {
"low_threshold": 0,
"med_threshold": 0,
"high_threshold": 0
},
"flags": {
"auth_required": false,
"auth_revocable": false,
"auth_immutable": false,
"auth_clawback_enabled": false
},
"balances": [
{
"balance": "58583234.9568162",
"buying_liabilities": "0.0000000",
"selling_liabilities": "0.0000000",
"asset_type": "native"
}
],
"signers": [
{
"weight": 1,
"key": "GBBB3DGTFM5AGPCJIIBH5QGSBLVEBB4GKQ7AV2JDT2ITMU7ZQKKOA2N7",
"type": "ed25519_public_key"
}
],
"data": {},
"num_sponsoring": 14421790,
"num_sponsored": 0,
"paging_token": "GBBB3DGTFM5AGPCJIIBH5QGSBLVEBB4GKQ7AV2JDT2ITMU7ZQKKOA2N7"
}
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Pi Demo App
# Pay with Pi App

Pi Demo App is an example of how you can implement the various required flows in your app's code.
It aims to show you how to use Pi Platform API on the backend side and Pi SDK on the frontend side of your app.
Pay with Pi App is an example of how you can implement the various required flows in your app's code.
It aims to show you how to use Pi Platform API on the backend side and Pay with Pi SDK on the frontend side of your app.


It is composed of two major parts:
Expand All @@ -16,8 +16,9 @@ Read [`doc/development.md`](./doc/development.md) to get started and learn how t

> **WARNING**
>
> The demo app uses express session cookies which, in the Sandbox environment, are not correctly saved on the client on some browsers.
> To properly test all of the features of the Demo App, we recommend you to open the sandbox app using Mozilla Firefox.
> The Pay with Pi App uses express session cookies which, in the Sandbox environment, are not correctly saved on the client on some browsers.
> To properly test all of the features of the Pay with Pi App
, we recommend you to open the sandbox app using Mozilla Firefox.


## Deployment
Expand All @@ -27,5 +28,5 @@ Read [`doc/deployment.md`](./doc/deployment.md) to learn how to deploy this app

## Flows

To dive into the implementation of the flows that support the demo app features, please refer to
[Pi Demo App Flows](./FLOWS.md).
To dive into the implementation of the flows that support the Pay with Pi app features, please refer to
[Pay with Pi App Flows](./FLOWS.md).
2 changes: 2 additions & 0 deletions Secreto
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- blocks.push({block: 2, chain: chain, nonce: 314159, coinbasevalue: '314159.00', coinbaseto: '04fe1be031bc7a54d900ff062911bc4f7ba0edb39e4280268e490b79e347e3b8b0019c252aad7536ef7caeb061d558cac2eaec43ff670d76a521bec77c35751310', txs: [{value: '314159.00', from: '04fe1be031bc7a54d900ff062911bc4f7ba0edb39e4280268e490b79e347e3b8b0019c252aad7536ef7caeb061d558cac2eaec43ff670d76a521bec77c35751310', to: '04cc17dc129331c1cbb9c32cf4dc2dde4a5144e26c09b7430685c227176aeed05c74cf9d581da9d872cff53e67a8b28c53dfcf197dc4148e476eff4c3abfb3eebd', sig: '3046022100bcfe74e2ee8972367dda52a8f90008800ad10fb14b30431cd58f057c418b37a10221009765c92497bf989f7c89e95d6e1a3f72a39dfdae13b4fb091f0f181195e6189e'},{value: '314159.00', from: '04fe1be031bc7a54d900ff062911bc4f7ba0edb39e4280268e490b79e347e3b8b0019c252aad7536ef7caeb061d558cac2eaec43ff670d76a521bec77c35751310', to: '04997ac426a5c3c0ec9b51732435f90ebb4cf06aca4bfdb778865af0110f3931660d8b85297d59382c81eb6c7ae7c100af55800f15dad1fc72122139ba02e5d740', sig: '304502210089cbf8f4bc854fb010c3bb7747f8c4c010fd02934d7c3b6d901cae60d05c13fb02203efa6dc2f0741aed03435f0f54e41faf946face98071f05b8078b4ea6b1b3ba3'},{value: '314159.00', from: '04fe1be031bc7a54d900ff062911bc4f7ba0edb39e4280268e490b79e347e3b8b0019c252aad7536ef7caeb061d558cac2eaec43ff670d76a521bec77c35751310', to: '042222d7af343abd780add9dd7a0f554a1d6b127bc6f7ec28c5eef97d25af83028e89011559daa71dfcc7e2175433a1a6ef605715eba07a8a942c7088f8050a714', sig: '3045022036cfd31dbdc400993a612bf9ba9c897a75b4578c8eff5221ccd6de9e506d739c022100d23fcfc19e57a8ea6fad1d698b86c5e4818dde55781d001f7e81ea9b9949cbe1'},{value: '314159.00', from: '04fe1be031bc7a54d900ff062911bc4f7ba0edb39e4280268e490b79e347e3b8b0019c252aad7536ef7caeb061d558cac2eaec43ff670d76a521bec77c35751310', to: '041c377677bb697329b8dbeb5811b026d532730ad90ad7357fd812183ec01b766d7a4ee33c6a85b84d44fa1c3c59377c660f0076c39c563d9a19005a56ee1d1336', sig: '3045022036cfd31dbdc400993a612bf9ba9c897a75b4578c8eff5221ccd6de9e506d739c022100d23fcfc19e57a8ea6fad1d698b86c5e4818dde55781d001f7e81ea9b9949cbe1'}], previous: '00006908f507a101e89544498978e9bd2e35462b91d86ef13510685227912e77', txCount: 4})

59 changes: 59 additions & 0 deletions Url validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from urllib.parse import urlparse

def is_valid_url(url):
parsed_url = urlparse(url)
return bool(parsed_url.scheme and parsed_url.netloc)

# Example usage
url = "https://www.paywithpi.com/path?query=value"
print("Valid URL!" if is_valid_url(url) else "Invalid URL!")

npm install validator

const validator = require('validator');

function isValidUrl(url) {
return validator.isURL(url);
}

// Example usage
const url = "https://www.paywithpi.com/path?query=value";
console.log(isValidUrl(url) ? "Valid URL!" : "Invalid URL!");

<input type="text" id="urlInput" placeholder="Enter URL">
<button onclick="validateUrl()">Validate URL</button>
<p id="result"></p>

<script>
function validateUrl() {
const url = document.getElementById('urlInput').value;
fetch('/validate-url', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ url })
})
.then(response => response.json())
.then(data => {
document.getElementById('result').innerText = data.isValid ? "Valid URL!" : "Invalid URL!";
});
}
</script>

const express = require('express');
const bodyParser = require('body-parser');
const validator = require('validator');

const app = express();
app.use(bodyParser.json());

app.post('/validate-url', (req, res) => {
const { url } = req.body;
const isValid = validator.isURL(url);
res.json({ isValid });
});

app.listen(3000, () => {
console.log('Server is running on port 3000');
});
6 changes: 3 additions & 3 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
"@types/connect-mongo": "^3.1.3",
"@types/cookie-parser": "^1.4.2",
"@types/express-session": "^1.17.5",
"axios": "^0.21.1",
"axios": "^0.28.0",
"connect-mongo": "^4.4.1",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"express": "^4.20.0",
"express-session": "^1.17.2",
"mongodb": "^4.0.0",
"mongodb": "^4.17.0",
"morgan": "^1.10.0"
},
"devDependencies": {
Expand Down
Loading