Coder Social home page Coder Social logo

konnco-payment's Introduction

Payment Tests

This repository is purposed for tests only.

Installation

  • Clone this repository to your local directory: [email protected]:yugo412/konnco-payment.git.
  • Change directory to application directory and copy default .env.example to .env.
  • Please change database config. It recommended to use driver other than SQLite.
  • Install required packages by running composer install.
  • Generate a new key by running command php artisan key:generate.
  • Migrate and seed database with command php artisan migrate --seed. Please be patient while running this command, it takes some times to finish the job.
  • Lastly, install Laravel Passport by running command php artisan passport:install.

Accessing the Endpoint

Before accessing any endpoint from payment service, we need to create Passport client. Please run this command to add a new one:

php artisan passport:client --password

Follow the wizard until a new client created successfully.

Now, you can use created client to access the payment endpoint with user credentials. For example, to fetch a token from user, we can pick a random email from database and use password as its password.

curl --location '{domain.com}/oauth/token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'client_id={client_id}' \
--data-urlencode 'client_secret={client_secret}' \
--data-urlencode 'username={user_email}' \
--data-urlencode 'password=password' \
--data-urlencode 'scope='

After the token successfully created, it can be used to authorize any payment endpoints. For example make a payment:

curl --location '{domain.com}/api/v1/payment' \
--header 'Accept: application/json' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Bearer {token}' \
--data-urlencode 'amount=12300'

Access transaction list (for authenticated user):

curl --location '{domain.com}/api/v1/payment' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {token}'

And, payment summary:

curl --location '{domain.com}/api/v1/payment/summary' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {token}'

Tests

php artisan test

Warning

When running test, it forces to use SQLite instead of driver from configured file (.env). So, if you're using SQLite as default driver for database configuration, the data will be wiped out every test ran.

konnco-payment's People

Contributors

yugo412 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.