Create a OkePay Gateway
**POST**
https://api.okepay.info/v1.0/Gateway
PHPPythonBash
// $instanceName is a part of the url where you access your okepay installation.
// https://{$instanceName}.okepay.info
$instanceName = 'YOUR_INSTANCE_NAME';
// $secret is the okepay secret for the communication between the applications
// if you think someone got your secret, just regenerate it in the okepay administration
$secret = 'YOUR_SECRET';
$okepay = new \Okepay\Okepay($instanceName, $secret);
$gateway = new \Okepay\Models\Request\Gateway();
// amount multiplied by 100
$gateway->setAmount(89.25 * 100);
// currency ISO code
$gateway->setCurrency('CHF');
//success and failed url in case that merchant redirects to payment site instead of using the modal view
$gateway->setSuccessRedirectUrl('https://www.merchant-website.com/success');
$gateway->setFailedRedirectUrl('https://www.merchant-website.com/failed');
// optional: payment service provider(s) to use (see http://developers.okepay.biz/docs/miscellaneous)
// empty array = all available psps
$gateway->setPsp(array());
//$gateway->setPm(array('mastercard'));
// optional: whether charge payment manually at a later date (type authorization)
$gateway->setPreAuthorization(false);
// optional: whether charge payment manually at a later date (type reservation)
$gateway->setReservation(false);
// optional: reference id of merchant (e. g. order number)
$gateway->setReferenceId(975382);
// optional: add contact information which should be stored along with payment
$gateway->addField($type = 'title', $value = 'mister');
$gateway->addField($type = 'forename', $value = 'Maximilian');
$gateway->addField($type = 'surname', $value = 'Pichler');
$gateway->addField($type = 'company', $value = 'Pichler Solutions');
$gateway->addField($type = 'street', $value = 'Seeweg 123');
$gateway->addField($type = 'postcode', $value = '1234');
$gateway->addField($type = 'place', $value = 'Englach');
$gateway->addField($type = 'country', $value = 'AT');
$gateway->addField($type = 'phone', $value = '+43123456789');
$gateway->addField($type = 'email', $value = 'info@pichler-solutions.com');
$gateway->addField($type = 'date_of_birth', $value = '03.06.1985');
$gateway->addField($type = 'custom_field_1', $value = '123456789', $name = array(
1 => 'Benutzerdefiniertes Feld (DE)',
2 => 'Benutzerdefiniertes Feld (EN)',
3 => 'Benutzerdefiniertes Feld (FR)',
4 => 'Benutzerdefiniertes Feld (IT)',
));
try {
$response = $okepay->create($gateway);
var_dump($response);
} catch (\Okepay\OkepayException $e) {
print $e->getMessage();
}
import urllib.request
import hmac
import hashlib
import base64
import json
post_data = {
"amount": 8925,
"currency": "CHF",
"preAuthorization": 0,
"reservation": 0,
"successRedirectUrl": "https://www.merchant-website.com/success",
"failedRedirectUrl": "https://www.merchant-website.com/failed"
}
data = urllib.parse.urlencode(post_data).encode('UTF-8')
dig = hmac.new(b'INSTANCE_API_SECRET', msg=data, digestmod=hashlib.sha256).digest()
post_data['ApiSignature'] = base64.b64encode(dig).decode()
data = urllib.parse.urlencode(post_data).encode('UTF-8')
result = urllib.request.urlopen('https://api.okepay.info/v1.0/Gateway/?instance=INSTANCE_NAME', data)
content = result.read().decode('UTF-8')
response = json.loads(content)
gateway = response['data'][0]
print(gateway)
apiSignature=`echo -n "amount=8925¤cy=CHF&preAuthorization=0&reservation=0&referenceId=975382&fields%5Bforename%5D%5Bvalue%5D=Max&fields%5Bsurname%5D%5Bvalue%5D=Mustermann&fields%5Bemail%5D%5Bvalue%5D=max.mustermann%40mysite.com&successRedirectUrl=https%3A%2F%2Fwww.merchant-website.com%2Fsuccess&failedRedirectUrl=https%3A%2F%2Fwww.merchant-website.com%2Ffailed" | openssl dgst -sha256 -hmac "INSTANCE_API_SECRET" -binary | openssl enc -base64`
curl --request POST "https://api.okepay.info/v1.0/Gateway/?instance=INSTANCE_NAME" \
--data-urlencode "amount=8925" \
--data-urlencode "currency=CHF" \
--data-urlencode "preAuthorization=0" \
--data-urlencode "reservation=0" \
--data-urlencode "referenceId=975382" \
--data-urlencode "fields[forename][value]=Max" \
--data-urlencode "fields[surname][value]=Mustermann" \
--data-urlencode "fields[email][value]=max.mustermann@mysite.com" \
--data-urlencode "successRedirectUrl=https://www.merchant-website.com/success" \
--data-urlencode "failedRedirectUrl=https://www.merchant-website.com/failed" \
--data-urlencode "ApiSignature=$apiSignature"
QUERY PARAMS | |
---|---|
instance string |
REQUIRED Your OkePay instance name |
BODY PARAMS | |
---|---|
amount int32 |
REQUIRED Amount of payment in cents. |
currency string |
REQUIRED Currency of payment (ISO Code) |
purpose string |
The purpose of the payment. |
successRedirectUrl string |
URL to redirect to after successful payment. |
failedRedirectUrl string |
URL to redirect to after failed payment. |
psp array of integers |
List of PSPs to provide for payment. If empty all available PSPs are provied. |
pm array of strings |
List of payment mean names to display |
preAuthorization boolean |
Whether charge payment manually at a later date (type authorization) |
reservation boolean |
Whether charge payment manually at a later date (type reservation) |
referenceId string |
An internal reference id used by your system. |
fields mixed type |
The contact data fields which should be stored along with payment. |
concardisOrderId string |
Only available for Concardis PSP and if the custom ODERID option is activated in PSP settings in AlltoBill administration. This ORDERID will be transferred to the Payengine. |
Using the PHP client library
If you are using our PHP client library, there are setter and getter methods to acces the PHP object properties.
Integration manual
For more information about the usage of OkePay Gateway, please visit following link:
https://okepay.biz/api-okepay-gateway
Next to read:
Delete a OkePay Gateway
Delete a OkePay Gateway