Simple javascript integration API for paytr payment gateway with TypeScript typings.
- Install paytr package into your project using
npm
oryarn
and import it
import { PayTRClient } from 'paytr';
- Create paytr payment client using your merchant parameters
const paytr = new PayTRClient({
merchant_id: '000000',
merchant_key: 'key provided by paytr',
merchant_salt: 'salt provided by paytr',
debug_on: true,
no_installment: true,
max_installment: 0,
timeout_limit: 0,
test_mode: false,
});
Please check documentation provided by PayTR for detailed information about the following parameters.
- Create payment token
const response = await paytr.getToken({
merchant_oid: 'unique id',
payment_amount: 10.99,
currency: 'TRY',
email: '[email protected]',
user_ip: '127.0.0.1',
user_name: 'John Doe',
user_phone: '+123456789',
user_address: 'customer billing address',
user_basket: [
{
name: 'Product name',
price: '10.99',
quantity: 1,
}
],
merchant_ok_url: 'https://example.local/success',
merchant_fail_url: 'https://example.local/fail',
});
- Render payment iframe using generated token or redirect user to that URL
const paytrUrl = 'https://www.paytr.com/odeme/guvenli/' + response.token;
This package is not affiliated with "PayTR Ödeme ve Elektronik Para Kuruluşu A.Ş" in any way.