承接 64robots/stripe 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

64robots/stripe

Composer 安装命令:

composer require 64robots/stripe

包简介

A package to add stripe integration 64 robots packages

README 文档

README

This package makes it easier to add stripe integrations to laravel applications

Installation and setup

To get the latest version, simply require the package using Composer:

$ composer require 64robots/stripe

Once installed, this package will automatically register its service provider.

To publish the config file to config/stripe.php run:

$ php artisan vendor:publish --provider="R64\Stripe\StripeServiceProvider" --tag="config"

Usage

The class you'd propably interact with the most is PaymentProcessor class. The processor class can be injected into other classes or can be resolved from the container.

use R64\Stripe\PaymentProcessor;
.
.
.

$processor = app(PaymentProcessor::class);

$charge = $processor->createCharge([
    'customer' => 'cus_GVIiC06JWCq1mo',
    'amount' => 100,
    'currency' => 'USD',
    'source' => 'tok_visa'
]);

Charges

  • To charge a credit or a debit card, you create a Charge object. You can create a charge using the createCharge method on the PaymentProcessor class. A R64\Stripe\Objects\Charge object would be returned.
$charge = $processor->createCharge([
    'customer' => 'cus_GVIiC06JWCq1mo',
    'amount' => 100,
    'currency' => 'USD',
    'source' => 'tok_visa'
]);

Customers

The processor allows you to create, update, list customers and get a single customer.

  • To create a customer, use the createCustomer method on the processor. A R64\Stripe\Objects\Customer object would be returned.
$customer = $processor->createCustomer([
    'description' => 'Customer for jenny.rosen@example.com',
    'source' => 'tok_visa',
    'email' => jenny.rosen@example.com,
    'metadata' => [
        'first_name' => Rosen,
        'last_name' => Gina,
    ]
]);
  • To update a customer, use the updateCustomer method on the processor. A R64\Stripe\Objects\Customer object would be returned.
$customer = $processor->updateCustomer([
    'id' => 1,
    'email' => jenny.rosen@example.com,
    'description' => Update jenny.rosen@example.com details,
    'source' => 'tok_visa'
]);
  • To get a single customer, use the getCustomer method on the processor. A R64\Stripe\Objects\Customer object would be returned.
$customer = $processor->getCustomer('cus_GVIiC06JWCq1mo');

Card

You can get a card, create and update a card using the processor.

  • To get a single card details, use the getCard method on the processor. A R64\Stripe\Objects\Card object would be returned.
$card = $processor->getCard('cus_GVIiC06JWCq1mo', 'card_1FyI6w2eZvKYlo2COseWzZAo');
  • To create a card, use the createCard method on the processor. A R64\Stripe\Objects\Card object would be returned.
$card = $processor->createCard([
    'source' => 'tok_visa'
]);
  • To update a card, use the updateCard method on the processor. A R64\Stripe\Objects\Card object would be returned.
$card = $processor->updateCard(
    'cus_GVIiC06JWCq1mo',
    'card_1FyI6w2eZvKYlo2COseWzZAo',
    [
        'name' => 'Jenny Rosen'
    ]
);

Plan and Subscription

Plans define the base price, currency, and billing cycle for subscriptions.

  • To create a product, use the createProduct method on the processor. A R64\Stripe\Objects\Product object would be returned.
$product = $processor->createProduct([
    'name' => 'Monthly membership base fee',
    'type' => 'service',
]);
  • To create a plan, use the createPlan method on the processor. A R64\Stripe\Objects\Plan object would be returned.
$plan = $processor->createPlan([
    'product' => ['name' => 'Gold special'],
    'nickname' => 'special,
    'interval' => 'month',
    'billing_scheme' => 'per_unit',
    'amount' => 100,
    'currency' => 'usd'
]);
  • To create a subscription, use the createSubscription method on the processor. A R64\Stripe\Objects\Subscription object would be returned.
$subscription = $processor->createSubscription([
    'customer' => 'cus_GVIiC06JWCq1mo',
    'items' => [
        [
            'object' => 'list',
            'plan' => plan_GVIh1z2696UJyR
        ]
    ]
]);
  • To create an invoice, use the createInvoice method on the processor. A R64\Stripe\Objects\Invoice object would be returned.
$invoice = $processor->createInvoice([
    'customer' => 'cus_GVIiC06JWCq1mo',
    'subscription' => 'sub_DUVhBH3LKxekhs',
]);
  • To create an invoice item, use the createInvoiceItem method on the processor. A R64\Stripe\Objects\InvoiceItem object would be returned.
$invoiceItem = $processor->createInvoiceItem([
    'customer' => 'cus_GVIiC06JWCq1mo',
    'subscription' => 'sub_DUVhBH3LKxekhs',
    'amount' => 100,
    'currency' => 'usd',
]);
  • To get an invoice details, use the getInvoice method. A R64\Stripe\Objects\Invoice object would be returned.
$invoice = $this->processor->getInvoice('in_1FJSdj2eZvKYlo2CCyOhyNxj');
  • To get a subscription details, use the getSubscription method. A R64\Stripe\Objects\Subscription object would be returned.
$subscription = $this->processor->getSubscription(sub_DUVhBH3LKxekhs);

Card Holder

You can create, update and get a card holder's details.

  • To create a card holder, use the createCardHolder method. A R64\Stripe\Objects\CardHolder object would be returned.
$cardHolder = $processor->createCardHolder([
    'type' => 'individual',
    'name' => 'Jenny Rosen',
    'email' => 'jenny.rosen@example.com',
    'phone_number' => '+18888675309',
    'billing' => [
        'name' => 'Jenny Rosen',
        'address' => [
        'line1' => '1234 Main Street',
        'city' => 'San Francisco',
        'state' => 'CA',
        'country' => 'US',
        'postal_code' => '94111',
        ],
    ],
]);
  • To update a card holders details, use the updateCardHolder method. A R64\Stripe\Objects\CardHolder object would be returned.
$cardHolder = $processor->updateCardHolder([
    'ich_1Ccy6F2eZvKYlo2ClnIm9bs4',
    [
        'metadata' => [
            'order_id' => '6735'
        ]
    ]
])
  • To retrieve a card holder, use the getCardHolder method. A R64\Stripe\Objects\CardHolder object would be returned.
$cardHolder = $processor->getCardHolder('ich_1Ccy6F2eZvKYlo2ClnIm9bs4');

64robots/stripe 适用场景与选型建议

64robots/stripe 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.02k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2020 年 01 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「stripe」 「64Robots」 「R64」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 64robots/stripe 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 64robots/stripe 我们能提供哪些服务?
定制开发 / 二次开发

基于 64robots/stripe 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-07