GithubHelp home page GithubHelp logo

payment's Introduction

Payment logo

Homzmart Payment

Build Status Docker Build Status License

Standalone Payment

Payment demo

How To Run The Project

$ git clone project-url
$ composer install
$ cp .env.example .env
$ php -S localhost:8080 -t public

List of available drivers

  • payfort ๐Ÿ˜‘
  • paymob ๐Ÿ’ƒ
  • tabby ๐Ÿ’ƒ Tabby is split in 4 payment method, Which means you can buy anything and pay it as a 4-month installment.
  • tamara ๐Ÿ’ƒ is a payment method that gives you the ability to split your order payment on several payments with zero interest.

How To Use

  • Add your payment in Payment\Enums\PaymentGateways Enum
  • Add your payment in Payment\Factories\PaymentFactory
  • Add your payment domain model in App\Http\Services\[payment-dir] with at minimum one class ex: {Payment}Startegy.php implementing App\Http\Contracts\PayFortStrategy
  • Add your payment config in config dir
Enums
Gatewa Name Payment Method order statuse
paymob visa created
payfort credit succeeded
tabby mada captured
tamara banktransfer voided
-------------- valu refunded
-------------- vfcash failed
-------------- cibinstallment not_secured
-------------- bminstallment --------------
-------------- ShahryPaymob --------------
-------------- SymplPaymob --------------
-------------- SouhoolaPaymob --------------
-------------- AudiPaymob --------------
-------------- BDCPaymob --------------
-------------- NBKPaymob --------------
-------------- NBDPaymob --------------
-------------- MashreqPaymob --------------
-------------- AllBanksPaymob --------------
-------------- PAY_BY_INSTALMENTS --------------

Pay Request

Note: We have two requests to send one in the local environment to make it easy to test and the second it has to be encrypted, and it works in any other environment.

The optimal request that will be accepted with all payments gateways in local environments:

GET /api/pay HTTP/1.1
Host: xxxx.xxxx
Accept: application/json
Content-Type: application/json

{
    "payment": {
        "gateway": "gateway_name", //see gateway name in enums table
        "method": "payment_method_name",//see gateway method in enums table
    },
    "order": {
        "reference_id": "123423-22Z",
        "amount": "1000",
        "currency": "SAR",
      "items": [
            {
                "reference_id": "5484-dd",
                "sku": "111-222abc",
                "title": "string",
                "quantity": 1,
                "price": "0.00",
                "category": "string"
            },
                        {
                "reference_id": "eed5",
                "sku": "111-222abc",
                "title": "string",
                "quantity": 1,
                "price": "0.00",
                "category": "string"
            }
        ]
    },
    "customer": {
        "id": 1,
        "ip": "127.0.0.1",
        "phone": "500000001",
        "name": "Mohamed Emad",
        "email": "[email protected]",
        "language": "en"
    },
    "shipping_address": {
        "country": "egypt",
        "city": "cairo",
        "address": "Maadi",
        "zip": "1234"
    }
}

An example of encrypted request that should work on any other environment except local

GET /api/pay HTTP/1.1
Host: xxxx.xxxx
Accept: application/json
Content-Type: application/json

{
    "data": "eyJpdiI6Im5uSGtMV1hXdmNXaGlQTTgiLCJ2YWx1ZSI6ImFtb0RwelJ0bXpsSW8vVWpCYTVRMEoxOUJjQ0N5Y0Zza05mTHZuRy9BQy9OS2NSUGZJdWFtbTRPWUxudk1PYzlVWjEycnRJbndmYUZyc1d5VVBOS0tLNGJWdzN6QkdJQk50d0hkRTVTU09tQ1RnRGowYjMzVW1kdmYrNi9Wd1NwWk9NTjdxTFlTZ1R1TGNaSWZ2a2pNUVJnVUM0d2M4TER6S2pkUWhrazFpVWw5Wi9vYitOc3NiTURuRDVsSS9XdDdJZzh3Y3RLWWZCNnhEbEx3K0lPc08vQUZlN2VtZ2xPRHUrTGNHNWJwbzFXTVovdHA2alBXYmtmNVFtUk1nTWFTa25zb1F1YlpQSU1NbXdCeURTUUtkRzNDL212T0VpSzJZZkNMaWNaTmFZZnREV25ySGNCZHA4WDMvU1lNMUJVTlZlWTB3TGJBREdydHhNOWN0cm1EY25CSWw1MGpxY05sZFFiSkMxKzRUNEJvZ1FRcmRZeGhCUFlsVDlQYk1sbmo4cU1qc2dHTk5pY1ptQXNIbjZJd0hmN3krbG8wZkh2NHdraEVEZFpIOVpRNGxOMkVLcG05WHZmMkM1NDNrcUpKZS9ScUFtTWh1cW16T1hTbXFIVjlMZCtsYnliQ1BUTWhwYjJIZVZqMGsrbUw5R2lmQytuWTFCaE84U3oxK1ZsdENlNHpOTm5nSGlVYnFYclJrOWo3UDFsQTdLUHlUcFptNzExeGFYek1rTndpMGZMSnlRUUpjd2lHQi9lVjlsYzJUd09Ndm50NC9scCsrOGFSd3Bkc1IrRkFlbEN6T3pxVXFBVG5lZTBON2kwUHdScDV1QStjamJ1aElkZ0p1Q0l3WlFDMmQ2RERSWXo5QXlIWTlVK01UUkQ1aHlIYzdCb3BhNWdIYzNiOS9FUnFLbkY4QWVWR2xUYWdvSXYyakVXUVJYUGVTZjBxVDVXbCs4SDVvZ1VvWEZMVlZpY1dNNW1jWmhPcVFjRnhYMVpGOWZ4QVgyVkpMQnQzSUhBZ0xGOHVaL0dXMlVmdTV6aWthVXNnNDlzTnVFMFBqNjRCRDBXQ1NzQkxQQzFZTW5xQklsNUp3MDl1bjBtQ1JONXdSYWpFckRRb2dub09mbC9USkxzSFFueFJBelhJT2lEMFVjN1I5STM2WkZTWk8wdWZUTG1pbzNmMmNiQXFCcWtMSUdmM09USkNnOElUUTBXbXUvQzNvall4RlRVNk5qaE9veGJWQ3ZBMHh4cS9Hb1hCb2xTZFRoZ3FtUVFaVS9MTDVPUjY2d0JWNENsN3RlYUFRaVZyZkhSajdvT3Y3VXJVcVowODBUK3IxVmMwaEg0cE91eFVydFFTOWR5SWV1dWxqcitZdjlPUTBaVUswRHZHZWc4MEViWDMrdjJZdHpOcVU2N1hQRUJ0K2w0dmo1ZWdyVms4a1NCbitOc1VjL3hIYzZOdWRkRzhINTRYYU16dWNBb3Z0WmtYa0s1MGw0Q3YwdVBKNks5dFgzZ3A4WG1YSGR6ckF0Z0ppMDZuaWd6OE1vL3RIV3NRZz09IiwibWFjIjoiIiwidGFnIjoibzdacnErTVdCdUxEN1VLYkp0dmU4dz09In0="
}

Callback Response 200

{
  "data": {
    "status": "payment_status", //see order status in enums table
    "reference_id": "123423-22Z",
    "order_id": "47ebdba5-4ae8-4a8f-acce-a04ff1467e63",
    "data": {}
    }
}

Error Responses

500: Something bad happened. We're notified.

{
   "message": "string."
}

400: failure.

{
   "message": "string."
}

422: validation error. One of the required fields is missing or request is not formatted correctly.

{
   "message": "The given data was invalid.",
   "errors": [
        "The xxxx field is required.",
        "The xxxx field is required.",
   ]
}

Request Encryption

If you want to call this service you should send the request encrypted, otherwise you will have an exception.

you have to use the same encrypter algorithm and the same key to be able to decrypt the data. Try to do these steps to have a successful encrypted request:

  • Implement this interface EncrypterInterface.php
  • Use this Encrypter.php ready implemented service to decrypt the data
  • Make an object from Encrypter class and pass the same algorithm and key in our service to be able to decrypt the encrypted request.
  • Finally, send the encrypted data by your http client.

Test

$ vendor/bin/phpunit

License

The Payment is open-sourced software licensed under the MIT license.

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.