2017 © Pedro Peláez
 

library mc2p-php

PHP library for the MyChoice2Pay API.

image

mc2p/mc2p-php

PHP library for the MyChoice2Pay API.

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

MyChoice2Pay PHP

Overview

MyChoice2Pay PHP provides integration access to the MyChoice2Pay API., (*1)

Build Status, (*2)

Installation

You can install using composer:, (*3)

composer require mc2p/mc2p-php

or from source code:, (*4)

git clone https://github.com/mc2p/mc2p-php mc2p

Quick Start Example

require_once __DIR__ . '/vendor/autoload.php'; // If you install from composer

require_once('mc2p/src/MC2P/MC2PClient.php');  // If you install from source code

use MC2P\MC2PClient;

$mc2p = new MC2PClient('KEY', 'SECRET_KEY');

# Create transaction
$transaction = $mc2p->Transaction(
    array(
        "currency" => "EUR",
        "products" => array(
            array(
                "amount" => 1,
                "product_id" => "PRODUCT-ID"
            )
        )
    )
);
# or with product details
$transaction = $mc2p->Transaction(
    array(
        "currency" => "EUR",
        "products" => array(
            array(
                "amount" => 1,
                "product" => array(
                    "name" => "Product",
                    "price" => 5
                )
            )
        )
    )
);
$transaction->save();
$transaction->getPayUrl() # Send user to this url to pay
$transaction->getIframeUrl() # Use this url to show an iframe in your site

# Get plans
$plansPaginator = $mc2p->plan->itemList(null);
$count = $plansPaginator->count;
$results = $plansPaginator->results; # Application's plans
$nextList = $plansPaginator->getNextList();

# Get product, change and save
$product = $mc2p->Product(
    array(
        "id" => "PRODUCT-ID"
    )
);
$product->retrieve();
$product->price = 10;
$product->save();

# Create and delete tax
$tax = $mc2p->Tax(
    array(
        "name" => "Tax",
        "percent" => 5
    )
);
$tax->save();
$tax->delete();

# Check if transaction was paid
$transaction = $mc2p->Transaction(
    array(
        "id" => "c8325bb3-c24e-4c0c-b0ff-14fe89bf9f1f"
    )
);
$transaction->retrieve();
$transaction->status == 'D' # Paid

# Create subscription
$subscription = $mc2p->Subscription(
    array(
        "currency" => "EUR",
        "plan_id" => "PLAN-ID",
        "note" => "Note example"
    )
)
# or with plan details
$subscription = $mc2p->Subscription(
    array(
        "currency" => "EUR",
        "plan" => array(
            "name" => "Plan",
            "price" => 5,
            "duration" => 1,
            "unit" => "M",
            "recurring" => True
        ),
        "note" => "Note example"
    )
);
$subscription->save()
$subscription->getPayUrl() # Send user to this url to pay
$subscription->getIframeUrl() # Use this url to show an iframe in your site

# Receive a notification
$notificationData = $mc2p->NotificationData(JSON_DICT_RECEIVED_FROM_MYCHOICE2PAY, $mc2p);
$notificationData->getStatus() == 'D'; # Paid
$notificationData->getTransaction(); # Transaction Paid
$notificationData->getSale(); # Sale generated

Exceptions

require_once __DIR__ . '/vendor/autoload.php'; // Autoload files using Composer autoload

use MC2P\MC2PClient;

# Incorrect data
$shipping = $mc2p->Shipping(
    array(
        "name" => "Normal shipping",
        "price" => "text" # Price must be number
    )
);

try {
    $shipping->save();
} catch (MC2P\InvalidRequestMC2PError $e) {
    $e->getMessage(); # Status code
}

The Versions

22/09 2017

dev-master

9999999-dev https://github.com/mc2p/mc2p-php

PHP library for the MyChoice2Pay API.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-curl *
  • ext-json *

 

The Development Requires

api rest sdk payments mychoice2pay mc2p

13/09 2017

v1.0.1

1.0.1.0 https://github.com/mc2p/mc2p-php

PHP library for the MyChoice2Pay API.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-curl *
  • ext-json *

 

The Development Requires

api rest sdk payments mychoice2pay mc2p

12/09 2017

v0.1.0

0.1.0.0 https://github.com/mc2p/mc2p-php

PHP library for the MyChoice2Pay API.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-curl *
  • ext-json *

 

The Development Requires

api rest sdk payments mychoice2pay mc2p

12/09 2017

v0.0.2

0.0.2.0 https://github.com/mc2p/mc2p-php

PHP library for the MyChoice2Pay API.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-curl *
  • ext-json *

 

The Development Requires

api rest sdk payments mychoice2pay mc2p

12/09 2017

v0.0.1

0.0.1.0 https://github.com/mc2p/mc2p-php

PHP library for the MyChoice2Pay API.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-curl *
  • ext-json *

 

The Development Requires

api rest sdk payments mychoice2pay mc2p