Skip to content

aleph1888/integralCES_consumer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages