Consumption Subscription
It is the set of methods that will allow our users to create clients, plans, subscriptions and carry out consumer plan transactions.
The main use of these methods is to make one-time charges to a customer for a service or product, such as hiring a delivery service for a product or the purchase of a particular product.
https://app.payku.cl/ (Default server) · https://des.payku.cl/ (Sandbox server)Insert data to a Client
Section titled “Insert data to a Client”/api/suclient/This method allows the insertion of Client data.
Request body
| Parameter | Type | Description |
|---|---|---|
emailrequired |
string <email> | Client email. |
namerequired |
string | Client name |
rut |
string | Single Tax Registry of the client, the entry of this data with or without a hyphen will be allowed. |
phonerequired |
string | Client phone. |
address |
string | Client address. |
country |
string | Client country. |
region |
string | Client region. |
city |
string | Client city. |
postal_code |
string | Client Zip Code. |
additional_parameters |
object | Client additional parameters |
parameter_1 |
string | Client additional parameter |
parameter_2 |
string | Client additional parameter |
curl -X POST \https://BASE_URL/api/suclient \-H 'Accept: application/json, text/plain, */*' \-H 'Sign: SIGN' \-H 'Authorization: Bearer TOKEN_PUBLICO' \-H 'Content-Type: application/json' \-H 'Host: BASE_URL' \-d { "email": "[email protected]", "name": "Joe Doe", "rut": "111111111", "phone": "923122312", "address": "Moneda 101", "country": "Chile", "region": "Metropolitana", "city": "Santiago", "postal_code": "850000, "additional_parameters":{ "parameter_1": "example 1", "parameter_2": "example 2", } }'$client = new \GuzzleHttp\Client(); $body = $client->request('POST', 'https://BASE_URL/api/suclient', [ 'json' => [ 'name' => 'Joe Doe', 'rut' => '111111111', 'phone' => '923122312', 'address' => 'Moneda 101', 'country' => 'Chile', 'region' => 'Metropolitana', 'city' => 'Santiago', 'postal_code' => '850000', 'additional_parameters' => [ 'parameter_1' => 'example', 'parameter_2' => 'example 2' ] ], 'headers' => [ 'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN', 'Authorization' => 'Bearer PUBLIC-TOKEN' ] ])->getBody();$response = json_decode($body);const request = async (data) => { const response = await fetch('https://BASE_URL/api/suclient', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN', 'Authorization': 'Bearer PUBLIC-TOKEN' }, body: JSON.stringify(data) }); const result = await response.json(); console.log(result)}
let data = { name: "Joe Doe", rut: "111111111", phone: "923122312", address: "Moneda 101", country: "Chile", region: "Metropolitana", city: "Santiago", postal_code: "850000", additional_parameters:{ parameter_1: "example", parameter_2: "example 2", }};
request(data);Responses
{ "status": "active", "id": "cl0be4c8e623c167bc8b29", "rut": "11111111", "name": "Joe Doe", "phone": "923122312", "address": "Moneda 101", "country": "Chile", "region": "Metropolitana", "city": "Santiago", "postal_code": "850000", "create_at": "2020-09-29", "update_at": null, "subcriptions": null, "additional_parameters": { "parameter_1": "example", "parameter_2": "example" }}Response fields
| Parameter | Type | Description |
|---|---|---|
status |
string | Client status. |
id |
string | Identifier of the transaction created by payku. |
rut |
string | Single Tax Registry of the client. |
name |
string | Client name. |
phone |
string | Client phone. |
email |
string | Client email. |
address |
string | Client address. |
country |
string | Client country. |
region |
string | Client region. |
city |
string | Client city. |
postal_code |
string | Client Zip Code. |
create_at |
string <datetime> | Registration date. |
update_at |
string <datetime> | Update date. |
subcriptions |
object | Client subscriptions. |
additional_parameters |
object | Client additional parameters |
parameter_1 |
string | Client additional parameter |
parameter_2 |
string | Client additional parameter |
Request failed.
{ "status": "failed", "type": "Unprocessable Entity", "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"}Response fields
| Parameter | Type | Description |
|---|---|---|
status |
string | Request status. |
type |
string | Type of error. |
message_error |
string | Error message. |
Incorrect public token.
{ "type": "Unauthorized", "message_error": { "error": "waiting token public" }}Response fields
| Parameter | Type | Description |
|---|---|---|
type |
string | Request status. |
message_error |
object | |
error |
string | Error message. |
Insert the data of a plan.
Section titled “Insert the data of a plan.”/api/suplan/This method allows the insertion of data for the creation of a plan.
Request body
| Parameter | Type | Description |
|---|---|---|
namerequired |
string | Plan name. |
description |
string | Plan description. |
url_notify_suscription |
string <url> | URL where the subscription status will be notified. |
url_notify_payment |
string <url> | URL where the payment status will be notified. |
url_success_payment |
string <url> | URL where the user will be redirected if the payment is successful. |
url_failed_payment |
string <url> | URL where the user will be redirected if the payment is unsuccessful. |
curl -X POST \https://BASE_URL/api/suplan \-H 'Accept: application/json, text/plain, */*' \-H 'Sign: SIGN' \-H 'Authorization: Bearer TOKEN_PUBLICO' \-H 'Content-Type: application/json' \-H 'Host: BASE_URL' \-d { "name": "Test plan", "description": "Test Plan" }'$client = new \GuzzleHttp\Client(); $body = $client->request('POST', 'https://BASE_URL/api/suplan', [ 'json' => [ 'name' => 'Test plan', 'description' => 'Test Plan' ], 'headers' => [ 'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN', 'Authorization' => 'Bearer PUBLIC-TOKEN' ] ])->getBody(); $response = json_decode($body);const request = async (data) => { const response = await fetch('https://BASE_URL/api/suplan', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN', 'Authorization': 'Bearer PUBLIC-TOKEN' }, body: JSON.stringify(data) }); const result = await response.json(); console.log(result)}
let data = { name: "Test plan", description: "Test Plan"};
request(data);Responses
{ "status": "success", "id": "pl4293e97a87195bb9edcd"}Response fields
| Parameter | Type | Description |
|---|---|---|
status |
string | Status. |
id |
string | Unique plan identifier per payku. |
Request failed.
{ "status": "failed", "type": "Unprocessable Entity", "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"}Response fields
| Parameter | Type | Description |
|---|---|---|
status |
string | Request status. |
type |
string | Type of error. |
message_error |
string | Error message. |
Incorrect public token.
{ "type": "Unauthorized", "message_error": { "error": "waiting token public" }}Response fields
| Parameter | Type | Description |
|---|---|---|
type |
string | Request status. |
message_error |
object | |
error |
string | Error message. |
Insert data for subscription
Section titled “Insert data for subscription”/api/sususcription/This method allows the user of a Payku account to create a subscription to a fixed-amount subscription plan, a consumer plan subscription and a variable-amount subscription to one of its clients, for this last type of subscription it is necessary to send the amount that will be charged in the subscription, it is important to note that when making this request for the first time there will be a charge of $ 50 that allows verifying that the card is active and valid, in the case of a fixed subscription plan the service charge will be automatic From the month following the subscription date and in the event that the subscription is to a consumer plan, it will be necessary to use the api / sutransaction endpoint to generate the transaction.
Request body
| Parameter | Type | Description |
|---|---|---|
planrequired |
string | Plan id. |
clientrequired |
string | Client id. |
curl -X POST \https://BASE_URL/api/sususcription \-H 'Accept: application/json, text/plain, */*' \-H 'Sign: SIGN' \-H 'Authorization: Bearer TOKEN_PUBLICO' \-H 'Content-Type: application/json' \-H 'Host: BASE_URL' \-d { "plan": "pl9697fb170834ad42dd00", "client": "cl9b1e1dd988694f30fa30" }'$client = new \GuzzleHttp\Client(); $body = $client->request('POST', 'https://BASE_URL/api/sususcription, [ 'json' => [ 'plan' => 'pl9697fb170834ad42dd00', 'client' => 'cl9b1e1dd988694f30fa30', ], 'headers' => [ 'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN', 'Authorization' => 'Bearer PUBLIC-TOKEN' ] ])->getBody(); $response = json_decode($body);const request = async (data) => { const response = await fetch('https://BASE_URL/api/sususcription', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN', 'Authorization': 'Bearer PUBLIC-TOKEN' }, body: JSON.stringify(data) }); const result = await response.json(); console.log(result)}
let data = { plan: "pl9697fb170834ad42dd00", client: "cl9b1e1dd988694f30fa30"};
request(data);Responses
{ "status": "register", "id": "sucaab7865dceaff49d8b3", "url": "http://app.payku.cl/gateway/registrosuscripcion?tipoplan=2&plan=true&token=219&validacion=e6c50ba0e0"}Response fields
| Parameter | Type | Description |
|---|---|---|
status |
string | Status. |
id |
string | Unique subscription identifier for payku. |
url |
string | Url payment and subscription activation. |
Request failed.
{ "status": "failed", "type": "Unprocessable Entity", "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"}Response fields
| Parameter | Type | Description |
|---|---|---|
status |
string | Request status. |
type |
string | Type of error. |
message_error |
string | Error message. |
Incorrect public token.
{ "type": "Unauthorized", "message_error": { "error": "waiting token public" }}Response fields
| Parameter | Type | Description |
|---|---|---|
type |
string | Request status. |
message_error |
object | |
error |
string | Error message. |
Insert data for the transaction
Section titled “Insert data for the transaction”/api/sutransaction/This method allows the user of a Payku account to generate a unique transaction to one of his clients who are subscribed to a consumption plan.
Request body
| Parameter | Type | Description |
|---|---|---|
suscriptionrequired |
string | Unique subscription identifier for payku. |
amount |
string | Amount. |
order |
string | Order. |
description |
string | Description. |
marketplace |
string | ma0690b6451a7043d5. |
card |
string | With the identifier you can indicate which of the active cards will be charged (OPTIONAL). |
curl -X POST \https://BASE_URL/api/sutransaction \-H 'Accept: application/json, text/plain, */*' \-H 'Sign: SIGN' \-H 'Authorization: Bearer TOKEN_PUBLICO' \-H 'Content-Type: application/json' \-H 'Host: BASE_URL' \-d { "suscription": "sucaab7865dceaff49d8b3", "amount": "10000", "order": "001", "description": "Description", "marketplace": "ma0690b6451a7043d5" }'$client = new \GuzzleHttp\Client(); $body = $client->request('POST', 'https://BASE_URL/api/sutransaction, [ 'json' => [ 'suscription' => sucaab7865dceaff49d8b3, 'order' => '001', 'monto' => '10000', 'description' => 'Description', 'marketplace' => 'ma0690b6451a7043d5' ], 'headers' => [ 'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN', 'Authorization' => 'Bearer PUBLIC-TOKEN' ] ])->getBody(); $response = json_decode($body);const request = async (data) => { const response = await fetch('https://BASE_URL/api/sutransaction', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN', 'Authorization': 'Bearer PUBLIC-TOKEN' }, body: JSON.stringify(data) }); const result = await response.json(); console.log(result)}
let data = { suscription: "sucaab7865dceaff49d8b3", amount: "10000", order: "001", description: "Description", marketplace: "ma0690b6451a7043d5"};
request(data);Responses
{ "status": "success", "order": "001", "amount": "10000", "transaction_id": "204444", "verification_key": "025dcad37e071daa8bfc2df35189009db65692a4ff766856108be1675e870839"}Response fields
| Parameter | Type | Description |
|---|---|---|
status |
string | Transaction status. The possible statuses you can get are the following:
|
order |
string | Order. |
amount |
string | Amount. |
transaction_id |
string | Transaction number. |
verification_key |
string |
Request failed.
{ "status": "failed", "type": "Unprocessable Entity", "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"}Response fields
| Parameter | Type | Description |
|---|---|---|
status |
string | Request status. |
type |
string | Type of error. |
message_error |
string | Error message. |
Incorrect public token.
{ "type": "Unauthorized", "message_error": { "error": "waiting token public" }}Response fields
| Parameter | Type | Description |
|---|---|---|
type |
string | Request status. |
message_error |
object | |
error |
string | Error message. |
Remove card
Section titled “Remove card”/api/suscriptionsdeletecards/This method allows you to delete a card associated with the subscription.
Request body
| Parameter | Type | Description |
|---|---|---|
suscriptionrequired |
string | ID of the associated card. |
curl -X POST \https://BASE_URL/api/suscriptionsdeletecards \-H 'Accept: application/json, text/plain, */*' \-H 'Sign: SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN' \-H 'Authorization: Bearer PUBLIC_TOKEN' \-H 'Content-Type: application/json' \-H 'Host: BASE_URL' \-d { "card": "surec804a8ed60c0a8cb8839" }'$client = new \GuzzleHttp\Client(); $body = $client->request('POST', 'https://BASE_URL/api/suscriptionsdeletecards', [ 'json' => [ 'card' => surec804a8ed60c0a8cb8839, ], 'headers' => [ 'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN', 'Authorization' => 'Bearer PUBLIC_TOKEN' ] ])->getBody(); $response = json_decode($body);const request = async (data) => { const response = await fetch('https://BASE_URL/api/suscriptionsdeletecards', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN', 'Authorization': 'Bearer PUBLIC_TOKEN' }, body: JSON.stringify(data) }); const result = await response.json(); console.log(result)}
let data = { card: "surec804a8ed60c0a8cb8839"};
request(data);Responses
{ "status": "Delete", "card": "surec804a8ed60c0a8cb8839"}Response fields
| Parameter | Type | Description |
|---|---|---|
status |
string | Status. |
card |
string | Identificador único de La tarjeta asociada a la suscripción. |
Request failed.
{ "status": "failed", "type": "card", "message_error": "is not valid"}Response fields
| Parameter | Type | Description |
|---|---|---|
status |
string | Request status. |
type |
string | Type of error. |
message_error |
string | Mensaje de error |
Incorrect public token.
{ "type": "Unauthorized", "message_error": { "error": "waiting token public" }}Response fields
| Parameter | Type | Description |
|---|---|---|
type |
string | Request status. |
message_error |
object | |
error |
string | Error message. |