Skip to content

iohaneiro/epayco-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Epayco

PHP wrapper for Epayco API

Description

API to interact with Epayco https://epayco.co/docs/api/

Dependencias

* PHP 5.3+

Installation

{
  "require" : {
    "epayco/epayco-php" : "dev-master"
  }
}

Add autoload to composer

require 'vendor/autoload.php';

From GitHub

$ git clone https://github.com/epayco/epayco-php.git

Usage

$epayco = new Epayco\Epayco(array(
    "apiKey" => "YOU_PUBLIC_API_KEY",
    "privateKey" => "YOU_PRIVATE_API_KEY",
    "lenguage" => "ES",
    "test" => true
));

Create Token

$token = $epayco->token->create(array(
    "card[number]" => '4575623182290326',
    "card[exp_year]" => "2017",
    "card[exp_month]" => "07",
    "card[cvc]" => "123"
));

Customers

Create

$customer = $epayco->customer->create(array(
    "token_card" => $token->id,
    "name" => "Joe",
    "last_name" => "Doe", //This parameter is optional
    "email" => "[email protected]",
    "default" => true,
    //Optional parameters: These parameters are important when validating the credit card transaction
    "city" => "Bogota",
    "address" => "Cr 4 # 55 36",
    "phone" => "3005234321",
    "cell_phone"=> "3010000001",
));

Retrieve

$customer = $epayco->customer->get("id_client");

List

$customer = $epayco->customer->getList();

Update

$customer = $epayco->customer->update("id_client", array('name' => 'julianc'));

Delete Customer's token

$customer = $epayco->customer->delete(array(
    "franchise"  => "visa",
    "mask" => "457562******0326",
    "customer_id"=>"id_client"
    ));

Add new token default to card existed

  $customer = $epayco->customer->addDefaultCard(array(
     "customer_id"=>"id_client",
     "token" => "**********zL4gFB",
     "franchise"=> "american-express",
     "mask"=> "373118*****7642"
 ));

Add new token to customer existed

    $customer = $epayco->customer->addNewToken(array(
    "token_card" => "HyjnY3pBSjFtiQBRT",
    "customer_id"=>"id_client"
));

Plans

Create

$plan = $epayco->plan->create(array(
     "id_plan" => "coursereact",
     "name" => "Course react js",
     "description" => "Course react and redux",
     "amount" => 30000,
     "currency" => "cop",
     "interval" => "month",
     "interval_count" => 1,
     "trial_days" => 30
));

Retrieve

$plan = $epayco->plan->get("coursereact");

List

$plan = $epayco->plan->getList();

Remove

$plan = $epayco->plan->remove("coursereact");

Subscriptions

Create

$sub = $epayco->subscriptions->create(array(
  "id_plan" => "coursereact",
  "customer" => "id_client",
  "token_card" => "id_token",
  "doc_type" => "CC",
  "doc_number" => "5234567",
   //Optional parameter: if these parameter it's not send, system get ePayco dashboard's url_confirmation
   "url_confirmation" => "https://ejemplo.com/confirmacion",
   "method_confirmation" => "POST"
));

Retrieve

$sub = $epayco->subscriptions->get("id_subscription");

List

$sub = $epayco->subscriptions->getList();

Cancel

$sub = $epayco->subscriptions->cancel("id_subscription");

Pay Subscription

$sub = $epayco->subscriptions->charge(array(
  "id_plan" => "coursereact",
  "customer" => "id_client",
  "token_card" => "id_token",
  "doc_type" => "CC",
  "doc_number" => "5234567",
  "address" => "cr 44 55 66",
  "phone"=> "2550102",
  "cell_phone"=> "3010000001",
  "ip" => "190.000.000.000"  // This is the client's IP, it is required
));

PSE

Create

$pse = $epayco->bank->create(array(
        "bank" => "1022",
        "invoice" => "1472050778",
        "description" => "Pago pruebas",
        "value" => "10000",
        "tax" => "0",
        "tax_base" => "0",
        "currency" => "COP",
        "type_person" => "0",
        "doc_type" => "CC",
        "doc_number" => "numero_documento_cliente",
        "name" => "PRUEBAS",
        "last_name" => "PAYCO",
        "email" => "[email protected]",
        "country" => "CO",
        "cell_phone" => "3010000001",
        "ip" => "190.000.000.000",  // This is the client's IP, it is required
        "url_response" => "https://ejemplo.com/respuesta.html",
        "url_confirmation" => "https://ejemplo.com/confirmacion",
        "method_confirmation" => "GET",

        //Extra params: These params are optional and can be used by the commerce
        "extra1" => "",
        "extra2" => "",
        "extra3" => "",
        "extra4" => "",
        "extra5" => "",
        "extra6" => "",
        "extra7" => "",
));

Retrieve

$pse = $epayco->bank->get("transactionID");

Split Payments

Previous requirements: https://docs.epayco.co/tools/split-payment

$split_bank_pay = $epayco->bank->create(array(
    //Other customary parameters...
    "splitpayment" => "true",
    "split_app_id" => "P_CUST_ID_CLIENTE APPLICATION",
    "split_merchant_id" => "P_CUST_ID_CLIENTE COMMERCE",
    "split_type" => "02",
    "split_primary_receiver" => "P_CUST_ID_CLIENTE APPLICATION",
    "split_primary_receiver_fee" => "10",
    "split_receivers" => json_encode(array(array('id'=>'P_CUST_ID_CLIENTE 1ST RECEIVER','fee'=>'1000','fee_type' => '01')))
));

Cash

Create

$cash = $epayco->cash->create("efecty", array(
    "invoice" => "1472050778",
    "description" => "pay test",
    "value" => "20000",
    "tax" => "0",
    "tax_base" => "0",
    "currency" => "COP",
    "type_person" => "0",
    "doc_type" => "CC",
    "doc_number" => "numero_documento_cliente",
    "name" => "testing",
    "last_name" => "PAYCO",
    "email" => "[email protected]",
    "cell_phone" => "3010000001",
    "end_date" => "data_max_5_days", // dd-mm-year
    "ip" => "190.000.000.000",  // This is the client's IP, it is required
    "url_response" => "https://ejemplo.com/respuesta.html",
    "url_confirmation" => "https://ejemplo.com/confirmacion",
    "method_confirmation" => "GET",

    //Extra params: These params are optional and can be used by the commerce
    "extra1" => "",
    "extra2" => "",
    "extra3" => "",
    "extra4" => "",
    "extra5" => "",
    "extra6" => "",
    "extra7" => "",
));

list

$cash = $epayco->cash->create("efecty", array());
$cash = $epayco->cash->create("gana", array());
$cash = $epayco->cash->create("baloto", array());//expiration date can not be longer than 30 days
$cash = $epayco->cash->create("redservi", array());//expiration date can not be longer than 30 days
$cash = $epayco->cash->create("puntored", array());//expiration date can not be longer than 30 days

Retrieve

$cash = $epayco->cash->transaction("id_transaction");

Split Payments

Previous requirements: https://docs.epayco.co/tools/split-payment

$split_cash_pay = $epayco->cash->create("efecty", array(
    //Other customary parameters...
    "splitpayment" => "true",
    "split_app_id" => "P_CUST_ID_CLIENTE APPLICATION",
    "split_merchant_id" => "P_CUST_ID_CLIENTE COMMERCE",
    "split_type" => "02",
    "split_primary_receiver" => "P_CUST_ID_CLIENTE APPLICATION",
    "split_primary_receiver_fee" => "10",
    "split_receivers" => json_encode(array(array('id'=>'P_CUST_ID_CLIENTE 1ST RECEIVER','fee'=>'1000','fee_type' => '01')))
));

Payment

Create

$pay = $epayco->charge->create(array(
    "token_card" => $token->id,
    "customer_id" => $customer->data->customerId,
    "doc_type" => "CC",
    "doc_number" => "numero_documento_cliente",
    "name" => "John",
    "last_name" => "Doe",
    "email" => "[email protected]",
    "bill" => "OR-1234",
    "description" => "Test Payment",
    "value" => "116000",
    "tax" => "16000",
    "tax_base" => "100000",
    "currency" => "COP",
    "dues" => "12",
    "address" => "cr 44 55 66",
    "phone"=> "2550102",
    "cell_phone"=> "3010000001",
    "ip" => "190.000.000.000",  // This is the client's IP, it is required
    "url_response" => "https://tudominio.com/respuesta.php",
    "url_confirmation" => "https://tudominio.com/confirmacion.php",

    //Extra params: These params are optional and can be used by the commerce
    "use_default_card_customer" => true,/*if the user wants to be charged with the card that the customer currently has as default = true*/
    "extras"=> array(
        "extra1" => "data 1",
        "extra2" => "data 2",
        "extra3" => "data 3",
    )
));

Retrieve

$pay = $epayco->charge->transaction("id_transaction");

Split Payments

Previous requirements: https://docs.epayco.co/tools/split-payment

$split_pay = $epayco->charge->create(array(
    //Other customary parameters...
    "splitpayment" => "true",
    "split_app_id" => "P_CUST_ID_CLIENTE APPLICATION",
    "split_merchant_id" => "P_CUST_ID_CLIENTE COMMERCE",
    "split_type" => "02",
    "split_primary_receiver" => "P_CUST_ID_CLIENTE APPLICATION",
    "split_primary_receiver_fee"=>"10",
    "split_receivers" => array(array('id'=>'P_CUST_ID_CLIENTE 1ST RECEIVER','fee'=>'1000','fee_type' => '01'))
));

About

PHP wrapper for Epayco API

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%