Git Product home page Git Product logo

combodopayumstripe's Introduction

Payum gateway : Combodo/StripeV3

This is an unofficial Payum gateway providing a stripe integration compatible with the Strong Customer Authentication also known as SCA. Official Payum's gateway are not compatible with this new european regulation.

As stated by Stripe:

Without SCA, many payments will be declined by your customers’ banks

Documentation

The documentation is available under the doc directory

Developed by Combodo

Combodo is the editor of iTop the open source ITSM solution.

For the needs of iTop Hub which offer free and commercial iTop extensions, a stripe integration compatible with the SCA was required.

With no doubt, we opened sourced our development. Please keep in mind that we are not the editor of Payum, thus this integration is probably far from perfect.

This code

Support

Combodo is affiliated with neither Payum and Stripe. You should contact them if you have a problem regarding your integration.

Nevertheless if you'd like iTop support we'd love to help you, do not hesitate to contact us!

Payum oriented resources

Many thanks to the payum community, please find here some relevant links:

License

Combodo/StripeV3 is released under the MIT License.

combodopayumstripe's People

Contributors

bruno-ds avatar dragosprotung avatar gabiudrescu avatar j0r1s avatar leobaillard avatar molkobain avatar pyrowman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

combodopayumstripe's Issues

Is it usefull to repeat the whole readme?

I was thinking the best thing to do where to define that there is two types of examples in the main readme, and then point to two others readme in each example that would explain their specifications.

Originally posted by @bruno-ds in #9

There is no need of a webhook

As I can see in the code you have given directly the 'done' route to stripe; by doing that, once the payment is done, he doesn't go back through your gateway.

Here is the original way :

// src/Action/Api/ObtainTokenAction.php
private function obtainSession(ObtainToken $request, ArrayObject $model): Session
{
    Stripe::setApiKey($this->keys->getSecretKey());
    $session = Session::create(
        [
            'success_url'           => $request->getToken()->getAfterUrl(),
            'cancel_url'            => $request->getToken()->getAfterUrl(),
            'payment_method_types'  => ['card'],
            'submit_type'           => Session::SUBMIT_TYPE_PAY,
            'line_items'            => $model['line_items'],
            'payment_intent_data'   => [
                'metadata'              => $model['metadata'] ?? ['payment_id' => $model['id']],
            ],
            'client_reference_id'   => $request->getToken()->getHash(),
        ]
    );

    return $session;
}

By using the $request->getToken()->getTargetUrl() method you can get the capture url in order to send the user to this route after the payment.

Here is how I propose to do :

// src/Action/Api/ObtainTokenAction.php
private function obtainSession(ObtainToken $request, ArrayObject $model): Session
{
    Stripe::setApiKey($this->keys->getSecretKey());
    $session = Session::create(
        [
            'success_url'           => $request->getToken()->getTargetUrl() . '?status=success',
            'cancel_url'            => $request->getToken()->getTargetUrl() . '?status=canceled',
            'payment_method_types'  => ['card'],
            'submit_type'           => Session::SUBMIT_TYPE_PAY,
            'line_items'            => $model['line_items'],
            'payment_intent_data'   => [
                'metadata'              => $model['metadata'] ?? ['payment_id' => $model['id']],
            ],
            'client_reference_id'   => $request->getToken()->getHash(),
        ]
    );

    return $session;
}
// src/Action/CaptureAction.php
public function execute($request)
{
    RequestNotSupportedException::assertSupports($this, $request);
    $model = ArrayObject::ensureArrayObject($request->getModel());
    $getHttpRequest = new GetHttpRequest();
    $this->gateway->execute($getHttpRequest);
    if ($getHttpRequest->method == 'GET' && isset($getHttpRequest->query['status'])) {
        // @TODO Check payment status
        return;
    }

    if ($model['status']) {
        return;
    }

    if ($model['customer']) {
        return;
    }

    $obtainToken = new ObtainToken($request->getToken());
    $obtainToken->setModel($model);

    $this->gateway->execute($obtainToken);
}

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.