Giter VIP home page Giter VIP logo

integralces_consumer's Introduction

integralCES_consumer

Provides payment gateway API for http://integralces.net

Whats this for

A PHP API for IntegralCES_interop.

Visit its Drupal integralCES issue.

API & consumer

This consumer is just an example, you don't need to take it all, just the API icesSDKv0.

Procedure

  1. Wrap API entrypoint with your own singleton class and configure it; you will need to get in contact (www.integralces.net) to receive credentials.

  2. Get the singleton...

 $api = myAPI::get_instance();

...and check for a valid Client (representing your website) connection before start making querys:

 $myContextName = $api->check_client_connection();
  1. Get a login url to redirect your debited user for authentification:
 $redirect_url = $api->get_authorization_url( $my_callback_url );

What goes under: a) API will generate a request token by making curl request saving it on a cookie and then use it to return the login url on integralCES server.

b) After successfully login, CES Server will call your API providing an authorization token which will be saved in a cookie.

c) API will then request for an access_token and save it on a cookie.

d) Then, API will redirect to $my_callback_url param.

  1. Check for your loged user:
 $logged_user = $api->Users->get_logged_user();
  1. Make a payment:
 $payment = new integralCES\Payment();
 $payment->buyer = $api->Accounts->get( $_POST["txtBuyer"] );
 $payment->seller = $api->Accounts->get( $_POST["txtSeller"] );
 $payment->amount = $_POST["txtAmount"];
 $payment->concept = $_POST["txtConcept"];
 $payment = $api->Payments->create( $payment );

NOTICE: iCES Server will check that your buyer is the same that is logged in your site. You can check integralCES\Account created objects before sending payment if need to find errors.

5.1) You can check now for your payment id, state, and any errors notification:

 $str_payment = sprintf( "%s, with status %s %s", $payment->id, $payment->get_state(), $payment->result );
 $html = str_replace( '%%section_payment_id%%', "Payment id: " . $str_payment, $html );
  1. Retrieve a single payment by id:
 $payment = $api->Payments->get( $payment->id );
  1. Retrieves a user and render its name and accounts:
 $user = $api->Users->get( $my_user_id );
 $user->accounts_to_ul()

See on action

Testing development server

Doc

Documentation

Developer

Contribute

BTC @ 1DNxbBeExzv7JvXgL6Up5BSUvuY4gE8q4A

integralces_consumer's People

Stargazers

Dan avatar Tom Brown avatar

Watchers

James Cloos 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.