Skip to content

Instantly share code, notes, and snippets.

View zalun's full-sized avatar

Piotr Zalewa zalun

View GitHub Profile
sequenceDiagram
  participant Frontend
  participant PayU
  actor User
  participant Plugin

  Frontend ->> PayU: PaymentLink is requested
  User ->> PayU: Authorization
 PayU ->> Plugin: PENDING status webhook
{
"id":46,
"customerIp":"127.0.0.1",
"description":"test",
"currencyCode":"PLN",
"totalAmount":"1000",
"buyer":null,
"products":null,
"status":"PENDING",
"redirectUri":"https://merch-prod.snd.payu.com/pay/?orderId=TFJBNPX6ZS220409GUEST000P01&token=eyJhbGciOiJIUzI1NiJ9.eyJvcmRlcklkIjoiVEZKQk5QWDZaUzIyMDQwOUdVRVNUMDAwUDAxIiwicG9zSWQiOiJvZzVIeTU5ZSIsImF1dGhvcml0aWVzIjpbIlJPTEVfQ0xJRU5UIl0sImV4cCI6MTY0OTU4MjQ1OSwiaXNzIjoiUEFZVSIsImF1ZCI6ImFwaS1nYXRld2F5Iiwic3ViIjoiUGF5VSBzdWJqZWN0IiwianRpIjoiNWZhYjVmYTAtNzA5Mi00NDdkLTlmOGEtZTUzMGM0NjlmZjQ4In0.d2MrRjcOTWF_H5DvQJbzBcnI8-hbi8VZ6NN1AdF3JP0",
{
"transaction": {
"id":23,
"uid":"24c6d9b2-c707-4d2a-8887-3991b903b3f6",
"customerIp":"127.0.0.1",
"description":"test",
"currencyCode":"PLN",
"totalAmount":"1000",
"buyer":null,
"products":null,
{
"order": {
"orderId": "TFJBNPX6ZS220409GUEST000P01",
"extOrderId": "24c6d9b2-c707-4d2a-8887-3991b903b3f6",
"orderCreateDate": "2022-04-09T11:20:59.521+02:00",
"notifyUrl": "https://webhook.site/5e25fb1d-a0cb-47ef-b8f7-f71ca7f7d5cc",
"customerIp": "127.0.0.1",
"merchantPosId": "300746",
"validityTime": "86400",
"description": "test",
{
"order": {
"orderId": "TFJBNPX6ZS220409GUEST000P01",
"extOrderId": "24c6d9b2-c707-4d2a-8887-3991b903b3f6",
"orderCreateDate": "2022-04-09T11:20:59.521+02:00",
"notifyUrl": "https://webhook.site/5e25fb1d-a0cb-47ef-b8f7-f71ca7f7d5cc",
"customerIp": "127.0.0.1",
"merchantPosId": "300746",
"validityTime": "86400",
"description": "test",
@zalun
zalun / index.js
Last active April 14, 2022 17:36
// server/routes/index.js
module.exports = [
{
method: 'POST',
path: '/transactions',
handler: 'paymentLink.createTransaction',
config: {
auth: false,
policies: [],
},
// ...
createOrder: async function(settings, token, transaction) {
const { payuApiUrl, merchantPosId, notifyUrl } = settings
const validityTime = 24 * 60 * 60
const headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + token
}
const options = { headers, "maxRedirects": 0 }
const {