Skip to content

themisir/paytr-js

Repository files navigation

PAYTR - Node.js Integration

Simple javascript integration API for paytr payment gateway with TypeScript typings.

Getting started

  1. Install paytr package into your project using npm or yarn and import it
import { PayTRClient } from 'paytr';
  1. 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.

  1. 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',
});
  1. Render payment iframe using generated token or redirect user to that URL
const paytrUrl = 'https://www.paytr.com/odeme/guvenli/' + response.token;

Notice

This package is not affiliated with "PayTR Ödeme ve Elektronik Para Kuruluşu A.Ş" in any way.

About

PayTR javascript client with typings support

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published