Page MenuHomeSealhub

README.md
No OneTemporary

README.md

# Przelewy24 Integrator
## Usage
1. Add the P24SessionsCollection to your app:
```
lang=js, name=src/back/collections/p24-sessions.ts
import { P24SessionsCollection } from "@sealcode/przelewy24";
export default class P24Sessions extends P24SessionsCollection {}
```
2. Create an instance of the P24 class somewhere in your code:
```
lang=js
import {
P24Flow,
P24SealiousStorage,
Przelewy24,
P24Session,
P24NotifBody,
} from "@sealcode/przelewy24";
import _locreq from "locreq";
import { P24Sessions } from "./collections/collections";
import { P24StatusCallbackURL } from "./routes/urls";
const locreq = _locreq(__dirname);
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const secrets = locreq("secrets.json") as Record<
"przelewy24",
{ base_url: string; posid: number; api_key: string; crc: string }
>;
const P24 = new Przelewy24(
secrets.przelewy24.base_url,
process.env.SEALIOUS_BASE_URL || "http://localhost:8080",
P24StatusCallbackURL,
{
posid: secrets.przelewy24.posid,
apiKey: secrets.przelewy24.api_key,
crc: secrets.przelewy24.crc,
},
new P24SealiousStorage(P24Sessions),
{
testFlow: new P24Flow(
(session: P24Session) => `/status/${session.id}`,
async (session: P24Session, notif: P24NotifBody) => {
console.log("PAID!", session, notif);
}
),
}
);
export default P24;
```
3. Mount the status handler URL to your routes:
```
import { Context } from "koa";
import { Page } from "@sealcode/sealgen";
import P24 from "../../przelewy24";
export const actionName = "P24Status";
export default new (class P24StatusPage extends Page {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async canAccess(_: Context) {
return { canAccess: true, message: "" };
}
async render(ctx: Context) {
await P24.handleStatusRequest(ctx.query);
return "OK";
}
})();
```

File Metadata

Mime Type
text/x-java
Expires
Sat, Nov 23, 08:06 (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
547934
Default Alt Text
README.md (1 KB)

Event Timeline