# Schedule a Payment

### How it works

### 1. Store the payment data

Register the customer payment information could be done from [PrimeiroPay](https://developers.primeiropay.com/tokenization) or could be done through Server-To-Server in two methods: [Store the data during a payment](https://primeiropay.docs.oppwa.com/tutorials/server-to-server/tokenisation#during-payment) or [store it as stand alone.](https://primeiropay.docs.oppwa.com/tutorials/server-to-server/tokenisation#stand-alone)

Following is an example of stand alone registration.

```
curl https://test.oppwa.com/v1/registrations \
 -d "entityId=8a8294184e736012014e78a1b1da15d3" \
 -d "paymentBrand=VISA" \
 -d "card.number=4200000000000000" \
 -d "card.holder=Jane Jones" \
 -d "card.expiryMonth=05" \
 -d "card.expiryYear=2021" \
 -d "card.cvv=123" \
 -H "Authorization: Bearer OGE4Mjk0MTg0ZTczNjAxMjAxNGU3OGExN2E2YTE1YjB8ZjJGRUtacXRCUA=="
```

Try it Out

### 2. Schedule a payment

Send a request to /schedules end point with the registrationId, payment type and the job schedule which describes when and how often the transaction should be committed.

For complete reference of job parameters, check [API Parameters Reference:](https://primeiro-pay.gitbook.io/primeiro-pay/api-parameters-reference)

```
curl https://test.oppwa.com/scheduling/v1/schedules \
 -d "entityId=8a8294184e736012014e78a1b1da15d3" \
 -d "registrationId={registrationId}" \
 -d "amount=17.00" \
 -d "currency=EUR" \
 -d "paymentType=DB" \
 -d "job.month=*" \
 -d "job.dayOfMonth=1" \
 -H "Authorization: Bearer OGE4Mjk0MTg0ZTczNjAxMjAxNGU3OGExN2E2YTE1YjB8ZjJGRUtacXRCUA=="
```

Try it Out

### 3. We execute the transaction for you

As the scheduled transaction triggers, the system commits the payment transaction on time using the stored payment information and payment type specified.

The system will commit a payment transaction with the paymentType, amount and currency specified, and will use the payment information registered on the first step.

### 4. Cancel the schedule

As the case of canceling the scheduled transaction, merchant sends a deschedule request to cancel future transactions.

Send a request to the de-scheduling specifying the **referenceId** of the scheduled transaction as following:

```
Curl https://test.oppwa.com/scheduling/v1/schedules/{id}
 -X DELETE "https://test.oppwa.com/scheduling/v1/schedules/{id}\?entityId=8a8294184e736012014e78a1b1da15d3" \
 -H "Authorization: Bearer OGE4Mjk0MTg0ZTczNjAxMjAxNGU3OGExN2E2YTE1YjB8ZjJGRUtacXRCUA=="
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.primeiropay.com/getting-started/server-to-server-api/schedule-a-payment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
