Skip to content

Recurring payments

Recurring payments allow businesses to charge customers automatically and are perfect for variable monthly costs, like usage-based services. If you have the customer’s mandate, you can manually create each payment and easily adjust the amount as needed.

We will now discuss how you can create a Payment with a Mandate with our Payments API.

Steps to create the payment with a mandate

  1. Create a Customer: Use the Customer API to create a new customer or use an existing customer.
  2. Create a Mandate: Use the Mandate API to create a new mandate or use an existing mandate.
  3. Create a Payment with a Mandate: Use the Payment API to create a payment.

Create a Customer

The first step is to create a Customer. This Customer object represents the entity (person or company) that will be billed. You can create a Customer using the Customer API.

php
$customer = $paypro->customers->create(
  [
    'email' => 'customer@example.com',
    'first_name' => 'First name',
    'last_name' => 'Last name'
  ]
);
ruby
client = PayPro::Client.new('pp_...')

customer = client.customers.create(
  email: 'customer@example.com',
  first_name: 'First name',
  last_name: 'Last name'
)

Once the Customer object is created, you can use it to create a mandate by referencing the customer's unique ID.

Create a Mandate

A Mandate symbolizes the permission the Customer gave you to charge their payment method. For example, if you already have the customer’s IBAN and account holder name, you can manually create a "direct-debit" mandate using the create Mandate API. Once created, this "direct-debit" mandate can be used to set up and process recurring payments.

IMPORTANT

To create mandates you still the need permission from the customer. When creating a mandate make sure to clearly state that the customer will agree to additional charges. Communicating this clearly will also lead to less chargebacks and costs.

php
$payment = $paypro->mandates->create(
  [
    'customer' => 'CUSTOMER_ID',
    'pay_method' => 'direct-debit',
    'iban' => 'IBAN',
    'account_holder_name' => 'Account Holder Name'
  ]
);
ruby
payment = client.mandates.create(
  customer: 'CUSTOMER_ID',
  pay_method: 'direct-debit',
  iban: 'IBAN',
  account_holder_name: 'Account Holder Name'
)

Create a Payment with a Mandate

After creating the mandate, you can move forward with creating the payment. As the mandate is already linked to a specific customer, there’s no need to include a separate CUSTOMER_ID. To create the payment, provide the amount, currency, description, and the mandate, which is the unique ID of the mandate.

php
$payment = $paypro->payments->create(
  [
    'amount' => 500,
    'currency' => 'EUR',
    'description' => 'Payment description',
    'mandate' => 'MANDATE_ID'
  ]
);
ruby
client = PayPro::Client.new('pp_...')

payment = client.payments.create(
  amount: 500,
  currency: 'EUR',
  description: 'Payment description',
  mandate: 'MANDATE_ID'
)

The payment will be processed immediately after creation. A Payment object enables you to track and manage your customer’s payment journey.