Giter VIP home page Giter VIP logo

stripe-endpoint's Introduction

Stripeエンドポイント for EC-CUBE4

EC-CUBE4でStripeのWebhookに登録するエンドポイントを構築するためのプラグインです。

Stripeライブラリをインストール

Stripeのライブラリが必須なのでcomposerでインストールしてください。

composer require stripe/stripe-php

Webhookの署名シークレットを設定

.envにWebhookの署名シークレットを設定してください。

STRIPE_SIGNING_SECRET=whsec_t6KFvU8...

プラグインをインストール

StripeEndpointプラグインをEC-CUBE4にインストール・有効化してください。

git clone [email protected]:kurozumi/StripeEndpoint.git app/Plugin
bin/console e:p:i --code StripeEndpoint
bin/console e:p:e --code StripeEndpoint

エンドポイント

下記のエンドポイントをStripeのWebhookに登録してください。

https://my-domain/stripe/webhook/endpoint

定期支払いが成功したり失敗した場合に何かする処理の実装方法

<?php
namespace Customize\EventListener;


use Plugin\StripeEndpoint\Event\StripeEvent;
use Stripe\Checkout\Session;
use Stripe\Event;
use Stripe\Invoice;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class StripeEventListener implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return [
            Event::CHECKOUT_SESSION_COMPLETED => ['onCheckoutSessionCompleted'],
            Event::INVOICE_PAID => ['onInvoicePaid'],
            Event::INVOICE_PAYMENT_FAILED => ['onInvoicePaymentFailed']
        ];
    }

    /**
     * 顧客が「支払う」または「登録」ボタンをクリックしたときに何かする
     *
     * @param StripeEvent $event
     */
    public function onCheckoutSessionCompleted(StripeEvent $event)
    {
        /** @var Session $session */
        $session = $event->getResource();
    }

    /**
     * 支払いが成功した場合に何かする
     *
     * @param StripeEvent $event
     */
    public function onInvoicePaid(StripeEvent $event)
    {
        /** @var Invoice $invoice */
        $invoice = $event->getResource();
    }

    /**
     * 顧客の支払い方法に問題があった場合に何かする
     *
     * @param StripeEvent $event
     */
    public function onInvoicePaymentFailed(StripeEvent $event)
    {
        /** @var Invoice $invoice */
        $invoice = $event->getResource();
    }
}

ご注意

カスタマイズ、または他社プラグインとの競合による動作不良つきましてはサポート対象外です。

本プラグインを導入したことによる不具合や被った不利益につきましては一切責任を負いません。 ご理解の程よろしくお願いいたします。

stripe-endpoint's People

Contributors

kurozumi avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.