Quickstart

This quickstart will show you how to quickly create and handle iDEAL payments with the PayPro API.

We will cover these steps:

  1. Create payment
  2. Handle payment

If you are not sure where to start. Check our Getting Started guide.


1. Create payment

In order to create a payment we need to call the create_payment command. To do this we need a few lines of code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# First we create a client object with our API key.
# This is an example key. Use your own API key here.
client = PayPro::Client.new('YOUR_API_KEY')

# Next we tell the client which command we want to execute.
client.command = 'create_payment'

# Then we set the parameters for this call.
client.params = {
  consumer_email: 'test@paypro.nl',
  amount: 500,
  pay_method: 'ideal/INGBNL2A'
}

# Execute the command and store the response.
response = client.execute
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
  // First we create a client object with our API key.
  // This is an example key. Use your own API key here.
  $client = new \PayPro\Client("YOUR_API_KEY");

  // Next we tell the client which command we want to execute.
  $client->setCommand("create_payment");

  // Then we set the parameters for this call.
  $client->setParams([
    "consumer_email" => "test@paypro.nl",
    "amount" => 500,
    "pay_method" => "ideal/INGBNL2A"
  ]);

  // Execute the command and store the response.
  $response = $client->execute();
?>

The API will respond with a JSON object. The client will automatically convert this to a hash that contains the following fields:

1
2
3
4
{
  "payment_hash": "d12a2cbaafab029f9c156282f3857bb056a40217",
  "payment_url": "https://www.paypro.nl/betalen/d12a2cbaafab029f9c156282f3857bb056a40218"
}

First, we have the payment_hash, this is the unique identifier of the payment. We can use the payment_hash to make calls to the API that require a payment.

Second, we have the payment_url. This URL serves two purposes. One, it will finalize the creation of the payment, and second, it will sent the customer to the the payment page. This can be the PayPro payment page or that of the payment method if all required information has been filled in.

In the example above, we set pay_method to ideal/INGBNL2A which means the customer will be redirected to the ING iDEAL page.


2. Handle payment

Now that we have created a payment, we can check its status through the API. We will use the get_sale command for this.

1
2
3
4
5
6
7
8
9
10
11
12
13
# First we create a client object with our API key.
client = PayPro::Client.new('YOUR_API_KEY')

# Next we tell the client we want to do a get_sale
client.command = 'get_sale'

# We can use the payment_hash from the create_payment command as the parameter.
client.params = {
  payment_hash: 'd12a2cbaafab029f9c156282f3857bb056a40217'
}

# Execute the command and store the response.
response = client.execute
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
  // First we create a client object with our API key.
  $client = new \PayPro\Client("YOUR_API_KEY");

  // Next we tell the client we want to do a get_sale.
  $client->setCommand("get_sale");

  // We can use the payment_hash from the create_payment command as the parameter.
  $client->setParams([
    "payment_hash" => "d12a2cbaafab029f9c156282f3857bb056a40217",
  ]);

  // Execute the command and store the response.
  $response = $client->execute();
?>

This command returns a JSON object with all the information about the created payment.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{
  "total_paused_days": 0,
  "last_successful_seq": 1,
  "custom": "",
  "city": "",
  "emailaddress": "test@paypro.nl",
  "country_code": "",
  "amount_total": 500,
  "id": 1234567,
  "description": "",
  "phone": "",
  "address": "",
  "lastname": "",
  "date": "01/01/2017 00:00",
  "order_quantity": 1,
  "number_of_periods": 1,
  "amount_total_affiliate": 0,
  "affiliate": null,
  "current_status": "completed",
  "total": "5,00",
  "remarks": "",
  "amount_affiliate_initial": 0,
  "product_id": 0,
  "price_recurring": 0,
  "vatnumber": "",
  "postal": "",
  "period_duration": "",
  "price_initial": 500,
  "company_name": "",
  "vat": 21,
  "current_number_of_periods": 1,
  "firstname": "",
  "amount_affiliate_recurring": 0,
  "invoicemethod": "instant"
}

For a more detailed list of all the different values, check out our API Reference.


What's next

You now should be able to create and check payments for your customers through the PayPro API. If you are interested in more detailed information about payments then feel free to check out our other guides.