Open Arvi89 opened 4 years ago
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' => 'pktest...', 'secret_key' => 'sktest...', 'sca_flow' => true )) ),
second prepare in controller:
$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
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));
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' => 'pktest...', 'secret_key' => 'sktest...', 'sca_flow' => true )) ),
second prepare in controller:
$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
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));
additionally with sca_flow = 'false' all is working well with stripe checkout
Can you show me your js pls?
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
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
@lolmx
got it working using js templates and extending my code with a confirm action. Thanks for your work.
regards Holger
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.
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.
@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
@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..
@lolmx do you have some documentation on how to use your plugin, as I have the same error as reported here
A token may not be passed in as a PaymentMethod. Instead, use payment_method_data with type=card and card[token]=tok_1GcuFvHQU2xxxxxXWH2FMNje.
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
Hello, I've used your last fix, but when I want to pay, somehow it get a 400 from stripe. In the logs from their console, I can see that "POST /v1/payment_methods" is being called, with weird parameters:
And stripe doesn't know what to do with that.