cryptonator/merchant-php-sdk

Cryptonator.com 商户API SDK for PHP

v1.0 2016-10-09 19:27 UTC

This package is auto-updated.

Last update: 2024-09-28 10:48:22 UTC


README

需求

PHP 5.3 或更高版本

链接

  1. Cryptonator 商户API 帮助中心: 俄语英语

入门指南

安装

  1. "cryptonator/merchant-php-sdk": "dev-master" 添加到您的应用程序的 composer.json 文件中,或将仓库克隆到您的项目中。
  2. 如果您正在使用 composer,请使用 require_once 'vendor/autoload.php';,否则粘贴以下行
    require_once '/path/to/cloned/repo/lib/MerchantAPI.php';

商户API

使用 Cryptonator 商户API SDK 需要以下步骤

  1. 粘贴以下代码。注意:您可以在 Cryptonator 账户设置中找到常量 merchant_idsecret,一旦您通过 创建商户账户

    use cryptonator\MerchantAPI;
    
    $cryptonator = new MerchantAPI(merchant_id, secret);
  2. 现在您可以使用 Cryptonator 商户API。

    // start payment
    $url = $cryptonator->startPayment(array(
       'item_name'               => 'Item Name',
       //'order_id'              => 'Order ID',
       //'item_description'      => 'Item Description',
       'invoice_amount'          => 'Invoice Amount',
       'invoice_currency'        => 'Invoice Currency',
       //'success_url'           => 'Success URL',
       //'failed_url'            => 'Failed URL',
       //'language'              => 'Language',
    ));
    
    // create invoice
    $invoice = $cryptonator->createInvoice(array(
        'item_name'               => 'Item Name',
        //'order_id'              => 'Order ID',
        //'item_description'      => 'Item Description',
        'checkout_currency'       => 'Checkout Amount',
        'invoice_amount'          => 'Invoice Amount',
        'invoice_currency'        => 'Invoice Currency',
        //'success_url'           => 'Success URL',
        //'failed_url'            => 'Failed URL',
        //'language'              => 'Language',
     ));
    
    // get invoice
    $invoice = $cryptonator->getInvoice('InvoiceID');
    
    // list invoices
    $invoices = $cryptonator->listInvoices(array(
        //'invoice_status'       => 'Invoice Status',
        //'invoice_currency'     => 'Invoice Currency',
        //'checkout_currency'    => 'Checkout Currency',
    ));
    
    // check annswer
    $check_server = $cryptonator->checkAnswer($_POST);