Skip to content

Instantly share code, notes, and snippets.

@kayslay
Last active July 22, 2019 16:18
Show Gist options
  • Save kayslay/903a6d25bd9f244f92b286b793409ffa to your computer and use it in GitHub Desktop.
Save kayslay/903a6d25bd9f244f92b286b793409ffa to your computer and use it in GitHub Desktop.
Busha Pays socket connection

BushaPay socket connection

Once a charge has been created, it status can be monitored by connecting the websocket client to https://api.pay.busha.co/charges/{chargeID}/status.

Replace chargeID in the route with id of created/existing charge.

The socket sends a Chargeon every update. whenever an event (payment,expire .e.t.c) occurs on the full charge object with the updates. check charge resource for more details.

// example of charge sent by the server
{
        "addresses": {
            "bitcoin": "35EZAktBdnkzJ1dT2QfDT4Gqhxco3UALSx",
            "ethereum": "0x019Ec4f8bE636cCc4692CC672918470a85787ECF"
        },
        "pricing": {
            "bitcoin": {
                "currency": "BTC",
                "value": "0.00111982"
            },
            "ethereum": {
                "currency": "ETH",
                "value": "0.03952834"
            },
            "local": {
                "currency": "NGN",
                "value": "2000"
            }
        },
        "payments": [],
        "id": "ff5eb3dd-12eb-4c41-b513-8f92f2e31970",
        "created_at": "2019-06-12T23:43:25.982566Z",
        "code": "OyRO1y2tJk",
        "hosted_url": "http://pay.busha.co/charges/OyRO1y2tJk",
        "redirect_url": "https://example.com",
        "cancel_url": "https://example.com",
        "expires_at": "2019-06-13T00:13:25.982216Z",
        "timeline": [
            {
                "time": "2019-06-12T23:43:25.985952Z",
                "status": "NEW",
                "context": null
            }
        ],
        "metadata": {
            "customer_id": "id_1005",
            "customer_name": "Jane Doe"
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment