cloudswipe/cloudswipe-wp

CloudSwipe 库用于 WordPress 集成

0.1.2 2017-02-07 22:12 UTC

This package is not auto-updated.

Last update: 2024-09-29 02:23:49 UTC


README

此库可用于与 CloudSwipe API 交互。

要求

Composer

您可以通过 Composer 安装它。运行以下命令

composer require cloudswipe/cloudswipe-wp

要使用绑定,请使用 Composer 的 自动加载

require_once('vendor/autoload.php');

用法

身份验证

所有 API 身份验证都使用带有在您的 CloudSwipe 账户中可用的 密钥 的 HTTP 身份验证。

您可以像这样设置所有请求的 密钥

CloudSwipe_Wp::set_secret_key( "sk_store_12345" );

发票

创建新发票

// bare minimum invoice
$invoice = CloudSwipe_Wp_Invoice::create([
  "description" => "T-Shirt",
  "total" => 1995,
  "currency" => "USD"
]);

// more detailed invoice
$invoice = CloudSwipe_Wp_Invoice::create([
  "total" => 2705,
  "currency" => "USD",
  "customer" => [
    "name" => "Bud Abbott",
    "email" => "bud@abbott.com"
    "billing_address" => [
      "name" => "Bud Abbott",
      "company" => "Laugh Lines",
      "line1" => "123 Anystreet",
      "line2" => "Suite A",
      "city" => "Anytown",
      "state" => "VA",
      "zip" => "12345",
      "country" => "US",
      "phone" => "111-222-3333"
    ],
    "shipping_address" => [
      "name" => "Lou Costello",
      "company" => "Laugh Lines",
      "line1" => "456 Otherstreet",
      "line2" => "Suite Z",
      "city" => "Othertown",
      "state" => "VA",
      "zip" => "12345",
      "country" => "US",
      "phone" => "111-222-3333"
    ],
    "line_items" => [
      "header" => ["Item", "Description", "Quantity", "Total"],
      "rows" => [
        ["T-Shirt", "Small, Blue", 1, 1095],
        ["Mug", "Branded Coffee Mug", 2, 535]
      ]
    ],
    "line_totals" => [
      "rows" => [
        ["Discount" => 500],
        ["Tax" => 245],
        ["Shipping" => 795]
      ]
    ],
    "metadata" => [
      "some-custom-field" => "some-custom-value"
    ]
  ]
]);

获取单个发票

$invoice = CloudSwipe_Wp_Invoice::get_one( "in_12345" );

获取所有发票

$invoices = CloudSwipe_Wp_Invoice::get_all();