Code Monkey home page Code Monkey logo

epay's Introduction

Build Status StyleCI Latest Stable Version Latest Unstable Version License

Epay PHP Libary

This is a PHP libary for Epay. It mimics the Stripe PHP Libary to allow for a cleaner and easier to use API.

Install the package by doing: composer require krve/epay

Work in progress

Current Todo

  • Better test coverage
  • Better Epay API Coverage
  • Rewrite base API Class

Documentation

You will probably notice that in the documentation there is several references to $customer_id. Customer ID references the subscriptionid you get back after having used the Epay Payment window. Don't worry about the mismatch in naming, it's simply called $customer_id so it fits the class Epay/Customer.

To set the your Merchant ID, Epay Webservice password and default currency make use of Epay/Epay. This needs to be done BEFORE making any calls to the api

Epay::setMerchantNumber($merchant_number);
Epay::setPassword('secret');
Epay::useCurrency('EUR', 978)

Epay/Customer

You can both retrieve and delete a Customer using the API. See examples below.

$customer = Customer::retrieve($customer_id);
$customer = Customer::retrieve($customer_id);
$customer->delete();

You can also get the customers subscriptions.

$subscriptions = $customer->subscriptions();

Epay/Charge

See example below.

$charge = Charge::create([
    'amount' => 1000,
    'customer' => $customer_id,
    'order' => uniqid(),
    'description' => 'Charge description'
]);

You also have the ability to specify a custom currency.

$charge = Charge::create([
    'amount' => 1000,
    'customer' => $customer_id,
    'order' => uniqid(),
    'description' => 'Charge description',
    'currency' => 840,
]);

Epay/Plan

For the moment you can only create a very basic plan using the API. If you want more options (You probably do) make use of Epays Plan manager.

$plan = Plan::create([
    'amount' => 2000,
    'interval' => 'yearly',
    'name' => 'Test Plan',
]);

You can also use the Epay\Plan to fetch the plans subscriptions.

$subscriptions = $plan->subscriptions();

Epay/Subscription

You can create a subscription to a plan by doing the following:

$subscription = Subscription::create([
    'customer' => $customer_id,
    'plan' => $plan_id,
    'email' => '[email protected]'
]);

This signs up the user to the plan. You also have the ability to retrieve and cancel a subscription

$subscription = Subscription::retrieve($subscription_id);
$subscription->cancel();

And fetch all subscriptions

$subscriptions = Subscription::all();

When you have a subscription you also have the ability to fetch the subscriptions customer. This will return a Epay\Customer instance.

$customer = $subscription->customer();

And the plan. This will return a Epay\Plan instance.

$plan = $subscription->plan();

Testing

Copy the .env.example to .env and fill out the values. Then run phpunit

Contributing

If you see anything you think could be improved, feel free to fork and create a PR with your changes. Just remember to keep the same code style. (PSR-2)

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.