Code Monkey home page Code Monkey logo

Comments (14)

hschiebold avatar hschiebold commented on July 22, 2024

same for me - and only with StripeJsGatewayFactory - with StripeCheckoutGatewayFactory it is the old stuff with obtain_checkout_token.html.twig and did not working

i am using a zend framework

first defining payum gateways:

'gateways' => array(
'paypal_ec' => (new Payum\Paypal\ExpressCheckout\Nvp\PaypalExpressCheckoutGatewayFactory())->create(array(
'username' => 'holger.schiebold...',
'password' => '...',
'signature' => '...',
'sandbox' => true
)),
'stripe' => (new Payum\Stripe\StripeCheckoutGatewayFactory())->create(array(
'publishable_key' => 'pk_test_...',
'secret_key' => 'sk_test_...',
'sca_flow' => true
))
),

second prepare in controller:

#payment checkout
$storage = $this->getServiceLocator()->get('payum')->getStorage('Application\Model\PaymentDetails');
$details = $storage->create();
$booking->setMeta('directpay', 'true');
$bookingManager->save($booking);
#paypal checkout
if ($payservice == 'paypal') {
$details['PAYMENTREQUEST_0_CURRENCYCODE'] = 'EUR';
$details['PAYMENTREQUEST_0_AMT'] = $total/100;
$details['PAYMENTREQUEST_0_BID'] = $booking->get('bid');
$storage->update($details);
$captureToken = $this->getServiceLocator()->get('payum.security.token_factory')->createCaptureToken(
'paypal_ec', $details, 'square/booking/payment_done');
return $this->redirect()->toUrl($captureToken->getTargetUrl());
}
#paypal checkout
#stripe checkout
if ($payservice == 'stripe') {
$details["amount"] = $total;
$details["currency"] = 'EUR';
$details["description"] = 'tvas booking-'.$booking->get('bid');
$storage->update($details);
$captureToken = $this->getServiceLocator()->get('payum.security.token_factory')->createCaptureToken(
'stripe', $details, 'square/booking/payment_done');
return $this->redirect()->toUrl($captureToken->getTargetUrl());
}
#stripe checkout
#payment checkout

last done action:

$token = $this->getServiceLocator()->get('payum.security.http_request_verifier')->verify($this);
\PaymentDetails');

    $gateway = $this->getServiceLocator()->get('payum')->getGateway($token->getGatewayName());

    $gateway->execute($status = new GetHumanStatus($token));

from stripe.

hschiebold avatar hschiebold commented on July 22, 2024

same for me - and only with StripeJsGatewayFactory - with StripeCheckoutGatewayFactory it is the old stuff with obtain_checkout_token.html.twig and did not working

i am using a zend framework

first defining payum gateways:

'gateways' => array(
'paypal_ec' => (new Payum\Paypal\ExpressCheckout\Nvp\PaypalExpressCheckoutGatewayFactory())->create(array(
'username' => 'holger.schiebold...',
'password' => '...',
'signature' => '...',
'sandbox' => true
)),
'stripe' => (new Payum\Stripe\StripeCheckoutGatewayFactory())->create(array(
'publishable_key' => 'pk_test_...',
'secret_key' => 'sk_test_...',
'sca_flow' => true
))
),

second prepare in controller:

#payment checkout
$storage = $this->getServiceLocator()->get('payum')->getStorage('Application\Model\PaymentDetails');
$details = $storage->create();
$booking->setMeta('directpay', 'true');
$bookingManager->save($booking);
#paypal checkout
if ($payservice == 'paypal') {
$details['PAYMENTREQUEST_0_CURRENCYCODE'] = 'EUR';
$details['PAYMENTREQUEST_0_AMT'] = $total/100;
$details['PAYMENTREQUEST_0_BID'] = $booking->get('bid');
$storage->update($details);
$captureToken = $this->getServiceLocator()->get('payum.security.token_factory')->createCaptureToken(
'paypal_ec', $details, 'square/booking/payment_done');
return $this->redirect()->toUrl($captureToken->getTargetUrl());
}
#paypal checkout
#stripe checkout
if ($payservice == 'stripe') {
$details["amount"] = $total;
$details["currency"] = 'EUR';
$details["description"] = 'tvas booking-'.$booking->get('bid');
$storage->update($details);
$captureToken = $this->getServiceLocator()->get('payum.security.token_factory')->createCaptureToken(
'stripe', $details, 'square/booking/payment_done');
return $this->redirect()->toUrl($captureToken->getTargetUrl());
}
#stripe checkout
#payment checkout

last done action:

$token = $this->getServiceLocator()->get('payum.security.http_request_verifier')->verify($this);
\PaymentDetails');

    $gateway = $this->getServiceLocator()->get('payum')->getGateway($token->getGatewayName());

    $gateway->execute($status = new GetHumanStatus($token));

from stripe.

hschiebold avatar hschiebold commented on July 22, 2024

additionally with sca_flow = 'false' all is working well with stripe checkout

from stripe.

lolmx avatar lolmx commented on July 22, 2024

Can you show me your js pls?

from stripe.

hschiebold avatar hschiebold commented on July 22, 2024

Hi Eric,

I do nothing else than the above code. The js should come from the used template in the Payum/Stripe module. When using above code with this lolmx/Stripe module and sca_flow = 'false' and the StripeCheckoutGatewayFactory than all works well. Only with sca_flow = 'true' it seems that the "old" template does not work together with the new PaymentIntent API.

regards Holger

from stripe.

hschiebold avatar hschiebold commented on July 22, 2024

Hi Eric,

i tried again using the JsFactory and got it working with a bit modifying my template - but never reached the ConfirmAction or the RequireConfirmationAction with sca test cards from stripe. Do i have to do anything else in my done action then $gateway->execute($status = new GetHumanStatus($token)); ?

thanks in advance Holger

from stripe.

hschiebold avatar hschiebold commented on July 22, 2024

@lolmx

got it working using js templates and extending my code with a confirm action.
Thanks for your work.

regards Holger

from stripe.

magedan avatar magedan commented on July 22, 2024

Hello,

I'm facing same issue as in the first post, Stripe responds with 400 status code with the following JSON body:

{
  "error": {
    "code": "parameter_unknown",
    "doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
    "message": "Received unknown parameters: 0, context, length",
    "param": "0",
    "type": "invalid_request_error"
  }
}

@hschiebold could you please share your updates? I'm on master branch btw.

from stripe.

magedan avatar magedan commented on July 22, 2024

I managed to get Stripe working on client side with these minor modifications to the obtain_js_token_for_strong_customer_authentication.html.twig:

        jQuery(function($) { 
           // This identifies your website in the call below
            var stripe = Stripe({{ publishable_key|json_encode|raw }});

            // Create an instance of the card Element.
            var elements = stripe.elements();
            var card = elements.create('card');

            // Add an instance of the card Element into the `card-element` <div>.
            card.mount('#card-element');

            $('#payment-form').submit(function(e) {
                var $form = $(this);

                // Disable the submit button to prevent repeated clicks
                $form.find('button').prop('disabled', true);

                stripe.createPaymentMethod({
                    type: 'card',
                    card: card
                }).then(stripeResponseHandler);

                // Prevent the form from submitting with the default action
                return false;
            });

            var stripeResponseHandler = function(response) {
                var $form = $('#payment-form');

                if (response.error) {
                    // Show the errors on the form
                    $form.find('.payment-errors').text(response.error.message);
                    $form.find('button').prop('disabled', false);
                } else {
                    // token is the created payment method's id
                    var token = response.paymentMethod.id;

                    // Insert the token into the form so it gets submitted to the server
                    $form.append($('<input type="hidden" name="stripeToken" />').val(token));
                    // and re-submit
                    $form.get(0).submit();
                }
            };
        });

However, when I try to use testing card with SCA enabled I always get "unknown" status here $gateway->execute($status = new GetHumanStatus($token));. Same for 3D secured cards. With "normal" cards everything seems fine.

@lolmx could you please give any suggestions how to proceed with the SCA card payment? Would be glad to share any additional information regarding my Payum config, but basically I just followed your guide here.

from stripe.

hschiebold avatar hschiebold commented on July 22, 2024

@magedan you will find my js template (vendor/payum/stripe/Payum/Stripe/Resources/views/Action/stripe_js.html.twig) in the fork of the booking system for our tennis indoor court at https://github.com/hschiebold/ep3-bs

the tempate is inspired by the stripe payments demo (https://github.com/stripe/stripe-payments-demo) and uses apple pay / google pay via stripe too

im am using payum module for the zend framwork and extended it with a confrim action so the sca workflow was working for me

from stripe.

magedan avatar magedan commented on July 22, 2024

@hschiebold thanks a lot!
Basically, the same modifications with "elements" as I have found so far.

@lolmx do you think this should lead to PR? I'm not really familiar with Stripe/Payum, just need to get it working..

from stripe.

jimiero avatar jimiero commented on July 22, 2024

@lolmx do you have some documentation on how to use your plugin, as I have the same error as reported here

from stripe.

jimiero avatar jimiero commented on July 22, 2024

A token may not be passed in as a PaymentMethod. Instead, use payment_method_data with type=card and card[token]=tok_1GcuFvHQU2xxxxxXWH2FMNje.

from stripe.

jimiero avatar jimiero commented on July 22, 2024

After some more play around, i get this error when click submit payment button:

You cannot create a charge with a PaymentMethod. Use the Payment Intents API instead

from stripe.

Related Issues (4)

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.