<commit_before>---
layout: page
categories: ["API"]
title: Payment
---

# Payment

All API requests to `https://api.parku.ch/v4/payment` need a __private key__.

## List Credit Cards

Requests shows all credit cards the user used before.

```sh
$ curl {{ site.parku.api }}/payment/creditcards \
    -u 098f6bcd4621d373cade4e832627b4f6:parku
```

> Response

```nginx
Status: 200 OK
```
```json
[
    {
        "id": "gphsyb",
        "type": "Visa",
        "number": "400934******1881",
        "expiration_date": "05/2020",
        "image_url": "https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=sandbox&merchant_id=8fbxty8dhjmy8g4j"
    },
    {
        "id": "6tvts6",
        "type": "Visa",
        "number": "411111******1111",
        "expiration_date": "01/2014",
        "image_url": "https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=sandbox&merchant_id=8fbxty8dhjmy8g4j"
    }
]
```

### HTTP Request

`GET {{ site.parku.api }}/payment/creditcards`


## Get Credit

Request shows the credit of the current user.

```sh
$ curl {{ site.parku.api }}/payment/credit \
    -u 098f6bcd4621d373cade4e832627b4f6:parku
```

> Response

```nginx
Status: 200 OK
```
```json
{
  "credit": 32
}
```

### HTTP Request

`GET {{ site.parku.api }}/payment/credit`


## Update Credit

Top up the credit of the user.

```sh
$ curl {{ site.parku.api }}/payment/creditcards \
    -u 098f6bcd4621d373cade4e832627b4f6:parku \
    -X PUT \
    -d amount=10 \
    -d currency=EUR \
    -d provider=braintree \
    -d provider_info[id]=6tvts6
```
> Response

```nginx
Status: 200 OK
```
```json
{
  "credit": 42
}
```

### HTTP Request

`PUT {{ site.parku.api }}/payment/credit`

### Parameters

Parameter      | Description
---            | ---
`amount`       | The amount. __Required.__
`currency`     | The currency. __Required.__
`provider`     | The payment method. Available options are _paypal_ and _braintree_. __Required.__
`provider_info`| The information of the payment provider to perform a payment. __Required.__ [See how to make a booking for more information using Braintree or PayPal.][payment-info]


  [payment-info]: /api/bookings/#toc_4<commit_msg>Change the response of the credit topup endpoint.<commit_after>---
layout: page
categories: ["API"]
title: Payment
---

# Payment

All API requests to `https://api.parku.ch/v4/payment` need a __private key__.

## List Credit Cards

Requests shows all credit cards the user used before.

```sh
$ curl {{ site.parku.api }}/payment/creditcards \
    -u 098f6bcd4621d373cade4e832627b4f6:parku
```

> Response

```nginx
Status: 200 OK
```
```json
[
    {
        "id": "gphsyb",
        "type": "Visa",
        "number": "400934******1881",
        "expiration_date": "05/2020",
        "image_url": "https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=sandbox&merchant_id=8fbxty8dhjmy8g4j"
    },
    {
        "id": "6tvts6",
        "type": "Visa",
        "number": "411111******1111",
        "expiration_date": "01/2014",
        "image_url": "https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=sandbox&merchant_id=8fbxty8dhjmy8g4j"
    }
]
```

### HTTP Request

`GET {{ site.parku.api }}/payment/creditcards`


## Update Credit

Top up the credit of the user.

```sh
$ curl {{ site.parku.api }}/payment/creditcards \
    -u 098f6bcd4621d373cade4e832627b4f6:parku \
    -X PUT \
    -d amount=10 \
    -d currency=EUR \
    -d provider=braintree \
    -d provider_info[id]=6tvts6
```
> Response

```nginx
Status: 200 OK
```
```json
{
  "gender": "female",
  "email": "<EMAIL>",
  "firstname": "Test",
  "lastname": "Name",
  "credit": 10,
  "currency": "EUR",
  "country": "DE",
  "facebook_id": null,
  "token": "<KEY>"
}
```

### HTTP Request

`PUT {{ site.parku.api }}/payment/credit`

### Parameters

Parameter      | Description
---            | ---
`amount`       | The amount. __Required.__
`currency`     | The currency. __Required.__
`provider`     | The payment method. Available options are _paypal_ and _braintree_. __Required.__
`provider_info`| The information of the payment provider to perform a payment. __Required.__ [See how to make a booking for more information using Braintree or PayPal.][payment-info]


  [payment-info]: /api/bookings/#toc_4
{'fraction_non_alphanumeric': 0.15950069348127602, 'fraction_numerical': 0.05016181229773463, 'mean_word_length': 3.254670599803343, 'pattern_counts': {'":': 31, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3252453', 'n_tokens_mistral': 1719, 'n_tokens_neox': 1547, 'n_words': 357}