mc2p/mc2p-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mc2p/mc2p-php

最新稳定版本:v1.0.7

Composer 安装命令:

composer require mc2p/mc2p-php

包简介

PHP library for the MyChoice2Pay API.

README 文档

README

Overview

MyChoice2Pay PHP provides integration access to the MyChoice2Pay API.

Build Status

Installation

You can install using composer:

composer require mc2p/mc2p-php

or from source code:

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
}

统计信息

  • 总下载量: 30.19k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 未知

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固