Integraties - Webhooks

Geschreven door Wim - {$BlogTitle}
Geschreven door: Wim
Datum: Donderdag 19 januari 2023

Webhooks en PHP SDK

Je kan Peggy Pay koppelen met je eigen software middels webhooks en onze PHP SDK.

In dit artikel worden de webhooks kort beschreven. Informatie over de PHP SDK kan je vinden op de github pagina.

Deze pagina en webhooks is nog in ontwikkeling/uitbreiding.

Webhooks kan je instellen in de editor onder de tab [Instellingen] => [Webhooks]. Hiervoor moet je wel de ontwikkelaarsmodus aanzetten middels het tandwieltje bovenin de toolbar:

Welke webhooks zijn er

Peggy Pay biedt de volgende webhooks:

Eventnaam Eventomschrijving
newSubmission Nieuwe aanmelding
newUpsell Nieuwe 1-click-upsell aangeschaft
orderStatusChanged De order-status is aangepast
installmentPayment Een nieuwe incasso voor een order met gespreid betalen
installmentPaymentFailed Als een incasso voor gespreid betalen gefaald is
subscriptionPayment Een nieuwe incasso voor een abonnement
subscriptionPaymentFailed Een gefaalde incasso voor een abonnement
subscriptionCancelledByCustomer Een abonnement wordt gestopt door de klant
subscriptionCancelledByOwner Een abonnement wordt gestopt door de beheerder
Een abonnement wordt gestopt vanwege gefaalde incasso's
Een abonnement wordt gepauzeerd
subscriptionReactivated Een abonnement is opnieuw gestart

De ingestelde url wordt aangeroepen met een dataset. Hieronder kan je lezen welke dataset bij welk event wordt meegestuurd.

Response

Zorg ervoor dat de response altijd het volgende JSON-format heeft:

{
    "success" => true,
    "message" => "Custom message"
}

In "message" kan je een bericht zetten die je in de logs terug kan lezen.

Als er "success" iets anders is dan true, wordt de webhook opnieuw uitgevoerd met de volgende intervals:

2min, 2min, 5min, 10min, 20min, 30min, 1 uur, 2 uur, 4 uur, 8 uur en 24 uur.

Daarna stopt Peggy Pay met pogingen.

Nieuwe aanmelding

{
    "Id": string,
    "firstname-value": string,
    "lastname-value": string,
    "email-value": string,
    "payment-paymentStatus": "complete",
    "payment-paymentAmount": decimal (10, in euros),
    "payment-paymentAmountEx": decimal (8.26, in euros),
    "payment-paymentAmountVat": decimal (1.74, in euros),
    "dateAdded": string (YYYY-MM-DD HH:SS:ii),
    "orderNumber": string,
    "submissionStatus": "Nieuw",
    "formName": string,
    "formKey": string,
    "paymentType": string (subscription/installment/default),
    "paymentId": string (mollie payment Id)
    "submissionHash": string     
    "event": "newSubmission"
-- for subscription
    "subscriptionHash": string,
    "subscriptionInterval": string (daily/weekly/monthly etc),
    "subscriptionAmount": int (5000, in cents),
    "subscriptionAmountEx": int,
    "subscriptionCustomerId": string,
    "subscriptionSubscriptionId": string,
-- for installment
    "totalTerms": int,
}

Nieuwe upsell

{
    "userName": string,
    "email": string,
    "dateAdded": string (YYYY-MM-DD HH:SS:ii),
    "name": string,
    "title": string,
    "amount": int (5000, in cents),
    "amountEx": int,
    "vat": int (tax rate, 21 for 21%, 9 for 9% etc)
    "vatAmount": int,
    "orderNumber": string,
    "hash": string,
    "submissionHash": string
}

Orderstatus gewijzigd

{
    "status": {
        "name": string (new, incomplete, complete, reviewed, archived, pending, cancelled, shipped, authorized, refunded, processing, readyForShipment, cashback, refundedPartially)
        "title": string,
        "isActive": 1 or 0,
        "isComplete": 1 or 0,
        "isReviewed": 1 or 0
    },
    "submissions": [
        {
            "orderNr": string,
            "orderNrFormatted": string,
            "submissionHash": string,
        },
        ..
    ]
}

Gespreid betalen

Geldt voor zowel installmentPayment als voor installmentPaymentFailed

{
    "paymentId": string,
    "term": int,
    "submissionHash": string,
    "amount": int (5000, in cents),
    "amountEx": int,

    "installmentCustomerId": string (mollie customer id),
    "installmentSubscriptionId": string (mollie subscription id),

    "paymentType": string (installent / installentRetry),
-- in case of failed
    "reason": string
}

Abonnement incasso

Geldt voor subscriptionPayment en subscriptionPaymentFailed

{
    "formKey": string,
    "paymentId": string (mollie payment id),

    "userName": string,
    "userEmail": string,

    "subscriptionTrialAmount": int (5000, in cents),
    "subscriptionTrialPeriod": string (days, weeks etc),
    "subscriptionTrialInterval": int,

    "submissionHash": string,
    "dateAdded": string (YYYY-MM-DD HH:SS:ii),

    "subscriptionAmount": int (5000, in cents),
    "subscriptionAmountEx": int,
    "subscriptionCustomerId": string (mollie customer id),
    "subscriptionSubscriptionId": string (mollie subscription id),
    "subscriptionDescription": string,
    "subscriptionRecurringInterval": string (weekly, monthly etc),
    "subscriptionHash": string,

    "incVat": 1 or 0,
    "vatAmount": int (5000, in cents)

    "amount": int,
    "amountEx": int,
-- for failed
    "reason": string
}

Abonnement geannuleerd

Geldt voor subscriptionCancelledByCustomer en subscriptionCancelledByOwner

{
    "formKey": string,

    "userName": string,
    "userEmail": string,

    "subscriptionTrialAmount": int (5000, in cents),
    "subscriptionTrialPeriod": string (days, weeks etc),
    "subscriptionTrialInterval": int,

    "submissionHash": string,
    "dateAdded": string (YYYY-MM-DD HH:SS:ii),

    "subscriptionAmount": int (5000, in cents),
    "subscriptionAmountEx": int,
    "subscriptionCustomerId": string (mollie customer id),
    "subscriptionSubscriptionId": string (mollie subscription id),
    "subscriptionDescription": string,
    "subscriptionRecurringInterval": string (weekly, monthly etc),
    "subscriptionHash": string,

    "incVat": 1 or 0,
    "vatAmount": int (5000, in cents)

    "cancelType": string (cancelled, cancelledEndOfPeriod, finalEndOfPeriod*),
    "cancelledBy": string (customer, owner)
}

Cancel type

Property value Omschrijving
cancelled Als een abonnement per direct wordt geannuleerd, bijvoorbeeld na een gefaalde incasso of door de beheerder
cancelledEndOfPeriod Als een abonnement handmatig gestopt is door de beheerder met als keuze "Aan het einde van de periode"
finalEndOfPeriod Als een abonnement door de beheerder is gestopt met de keuze "aan het einde van de periode" en de periode voorbij is
pause Als een abonnement op pauze is gezet

 

Verder lezen? Verkoopfacturen downloaden