Skip to content

Billwerk+

Link to their website: https://www.billwerk.plus/pay-payment-gateway

If you haven't already, please follow the getting started guide.

The Billwerk+ integration requires a bit more clientside work to fully incorporate their feature set of saved payment methods, which this article will help highlight.

Features

Besides the standard checkout process, the Billwerk+ integration also supports charging from previously saved payment methods.

Configuration

Two keys are expected:

  • API private key
  • Webhooks secret key

Both can be generated from Billwerk's admin portal.

Furthermore, you can configure which payment methods you would like to support (but not exceeding the plan you have with Billwerk+).

Webhooks

In order to authorize payments, you must configure webhooks from Billwerk's admin portal. You should set up a URL pointing to the callback endpoint you created and make sure you have invoice_authorized set as an event type you listen to.

How to create a payment with Billwerk and save the payment method

Our Billwerk integration expects the normal PaymentCreationRequest to be of a specific type, either:

  1. BillwerkCheckoutPaymentCreationRequest or
  2. BillwerkChargePaymentCreationRequest

The first type is used when creating the typical payment flow, and you can configure the request to save the payment method.

Because of the possibility of saving a payment method, this integration also has its own PaymentUpdateRequest, BillwerkPaymentUpdateRequest which has the propertiesPaymentMethod and CardInformation you can use to persist for later use. Note, PaymentMethod is only populated if you configured the Creation request to save the payment method.

In your IPaymentStorageService implementation, you could implement a simple check like this:

public async Task UpdateAsync(PaymentUpdateRequest update)
{
    // ...

    if (update is BillwerkPaymentUpdateRequest billwerkUpdate)
    {
        if (billwerkUpdate.CardInformation != null && 
            !string.IsNullOrEmpty(billwerkUpdate.PaymentMethod))
        {
            _yourOwnPaymentMethodService.SavePaymentMethod(
                paymentMethod: billwerkUpdate.PaymentMethod,
                cardNumberMask: billwerkUpdate.CardInformation.CardNumberMask,
                cardType: billwerkUpdate.CardInformation.CardType,
                customerId: ...,
                ...
            );
        }
    }

    // ...
}

If you want to create a simple charge payment, you need to reference the customerId and paymentMethod that you persisted from above in a BillwerkChargePaymentCreationRequest in your payment controller (see here for the getting started guide on how to setup creation of payments).

Lastly, if you wish to delete the payment method, you can use the interface IBillwerkPaymentMethodService.