checkoutfi / charge-api
This package is abandoned and no longer maintained.
No replacement package was suggested.
Charge API implementation
dev-master
2018-02-19 13:59 UTC
Requires
- php: >=5.4
Requires (Dev)
- phpspec/phpspec: ~2.0
This package is not auto-updated.
Last update: 2020-01-24 16:05:47 UTC
README
This library is deprecated.
Authorization
In order to create a charge for a merchant the merchant must first grant an authorization for the charges. You can request an authorization by:
POST: https://rpcapi.checkout.fi/charge/authorize
<?php $post_data = [ 'MERCHANT' => '123456', 'AUTHORIZER' => '654321', 'VALID' => '2016-01-01', // or '' 'MESSAGE' => 'By granting the authorization you accept monthly fees from xyz service', // max 1000 chars 'TIMESTAMP' => time(true), 'MAC' => $mac ]; .... $mac = hash_hmac('sha256', "{$merchant}&{$authorizer}&{$valid}&{$message}&{$timestamp}", $secret);
Response:
{
success: true || false,
response_code: <response code>,
message: Created
}
Listing authorizations
To get a list of pending and approved authorization requests:
POST: https://rpcapi.checkout.fi/charge/list
<?php $post_data = [ 'MERCHANT' => '123456', 'TIMESTAMP' => time(true), 'MAC' => $mac ]; ... $mac = hash_hmac('sha256', "{$merchant}&{$timestamp}", $this->secret);
Response:
{
success: true || false,
response_code: <response code>,
message: OK
data: [
{merchant_id: 654321, approved_at: '2016-01-23', valid_until: null || 'Y-m-d'}
]
}
Creating a charge
POST: https://rpcapi.checkout.fi/charge/debit
<?php $post_data = [ 'MERCHANT' => '123456', 'CHARGE_FROM' => '654321', 'DATE' => '2015-12-12', 'AMOUNT' => '1500', // amout is in cents 'REFERENCE' => '12344', 'STAMP' => '1234567890', // must be unique 'DESCRIPTION' => 'Description of the charge', 'MAC' => $mac ]; .... $mac = hash_hmac('sha256', "{merchant}&{$charge_from}&{$date}&{$amount}&{$reference}&{$stamp}&{$description}", $secret);
Response:
{
success: true || false,
response_code: <response code>,
message: Message,
data: {
STAMP: 1234567890,
AMOUNT: 1500,
ID: Checkout id
}
}
Response codes:
Response code | Description |
---|---|
0 | Success |
100 | Merchant id not valid |
110 | MAC mismatch error |
120 | Access to service denied |
130 | Authorizer id not valid |
140 | Authorization already exists |
150 | No valid authorization found |
160 | AMOUNT not integer |
170 | AMOUNT is 0 |
180 | Not enough balance |
190 | Credit failure, transaction cancelled |
200 | Debit failure |