Rocket Systems 的 PHP SDK 模块

1.1 2015-04-13 19:36 UTC

This package is not auto-updated.

Last update: 2020-08-07 18:37:54 UTC


README

PHP SDK 到 Rocket API,使用此 SDK 可以创建发票并从我们的简单结账系统中检索发票状态,当您的计划支持时,您可以调用 API。

安装

不使用 Composer

下载此存储库,然后仅包含我们的自动加载

    require_once (__DIR__  . '/../src/autoload.php');

使用 Composer

安装 Composer

$ wget http://getcomposer.org/composer.phar
$ php composer.phar install

安装后

  1. 在您的 composer.json 中添加此项目

    "require": {
        "rocket-systems/php-sdk": "dev-master"
    }
  2. 现在运行以下命令,让 composer 下载 Rocket php-sdk

    $ php composer.phar update

如何使用

发送新订单

<?php

use Rocket\Checkout\Checkout;
use Rocket\Invoice\Invoice;
use Rocket\Invoice\InvoiceProduct;

    $checkout = new Checkout("INFORM YOU SIMPLE CHECKOUT KEY");
    
    $invoice = new Invoice();
    $invoice->setInvoiceNumber(0001);
    $invoice->setInvoiceDescription("Test Description");
    $invoice->setCancelUrl("http://example.com/cancel");
    $invoice->setSuccessUrl("http://example.com/success");
    $invoice->setCustomerEmail("john@doe.com");
    $invoice->setCustomerName("John Doe");

    $product = new InvoiceProduct();
    $product->setName("Test Product");
    $product->setDescription("Test Product Description");
    $product->setQuantity(10);
    $product->setUnityPrice(9.90);

    $product2 = new InvoiceProduct();
    $product2->setName("Test Product");
    $product2->setDescription("Test Product Description");
    $product2->setQuantity(1);
    $product2->setUnityPrice(1000.00);

    $invoice->addProducts($product);

    $invoice->addProducts($product2);

    $checkout->createInvoice($invoice);

    $returnUrl = $checkout->getPayInvoiceUrl();
    $invoiceUniqueCode = $checkout->getInvoiceToken();
    $status = $checkout->getInvoiceStatus();
    

查询订单

<?php

use Rocket\Checkout\Checkout;

    $checkout = new Checkout("INFORM YOU SIMPLE CHECKOUT KEY");
    $invoice = $checkout->checkInvoice("INVOICE UNIQUE ID");
    $status = $checkout->getInvoiceStatus();
    

检查用户是否存在

<?php

use Rocket\Payment\Transfer;

    $transfer = new Transfer("INFORM YOU SIMPLE CHECKOUT KEY");
    $send = $transfer->checkUser("user@email.com");
    $send->getStatus();

获取您的实际余额

您可以检查所有账户的实际余额

默认 = 您的默认货币账户,bitcoin = 您的比特币钱包,blocked = 您被冻结的资金钱包

<?php

use Rocket\Payment\Transfer;

    $transfer = new Transfer("INFORM YOU SIMPLE CHECKOUT KEY");
    $send = $transfer->checkBalance("default");
    $send->getStatus();

转账

<?php

use Rocket\Payment\Transfer;

    $transfer = new Transfer("INFORM YOU SIMPLE CHECKOUT KEY");
    $send = $transfer->sendTransfer("user@email.com",20.00,"USD","Your Custom Message");
    $send->getStatus();