thephpleague / omnipay-stripe

Stripe driver for the Omnipay PHP payment processing library
MIT License
185 stars 168 forks source link

How can I download payment methods? #195

Open trendak opened 3 years ago

trendak commented 3 years ago

I am doing a micro service.

How can i download payment methods?

I don't know if I understood correctly, but when I do authorization it should redirect to the payment gateway.

When i make: $response = $gateway->authorize([ 'amount' => '10.00', 'currency' => 'USD', 'description' => 'This is a test purchase transaction.', 'returnUrl' => 'http://test.test/web/gateway-return', 'confirm' => true, ])->send();

Then i have error: The source parameter is required

domis86 commented 3 years ago

https://github.com/thephpleague/omnipay-stripe#stripe-payment-intents

You are missing 'paymentMethod' parameter

trendak commented 3 years ago

With 'paymentMethod' I have this same.

How can i download payment methods?

domis86 commented 3 years ago

https://github.com/thephpleague/omnipay-stripe#stripe-payment-intents

$paymentMethod = $_POST['paymentMethodId'];

$response = $gateway->authorize([
     'amount'                   => '10.00',
     'currency'                 => 'USD',
     'description'              => 'This is a test purchase transaction.',
     'paymentMethod'            => $paymentMethod,
     'returnUrl'                => $completePaymentUrl,
     'confirm'                  => true,
 ])->send();

$_POST['paymentMethodId'] is sent from client side - see for example: https://stripe.com/docs/payments/accept-a-payment-synchronously#web-send-to-server - there it is named payment_method_id :

...
    // Otherwise send paymentMethod.id to your server (see Step 4)
    fetch('/pay', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        payment_method_id: result.paymentMethod.id,
      })
...
trendak commented 3 years ago

How can I download payment methods in php? I need to download payment methods in backend, This is a micro service, after downloading the payment methods it will be sent to the application. It can be done universally so that after changing the gateway, payment methods will be charged?

domis86 commented 3 years ago

@trendak i think you are confusing some concepts here. First you should read Stripe docs regarding overall payment flow and how PaymentIntents works (and what is "Stripe payment method")

It can be done universally so that after changing the gateway, payment methods will be charged?

If you ask if you will be able to reuse "Stripe payment method" in gateway other than Stripe then the answer is no :smiley:

trendak commented 3 years ago

@domis86 I think he misunderstood my questions.

I am doing a micro service based on another one and it must contain the same functionality.

Is it possible to download payment methods in backend?

After selecting the payment method, e.g. a bank, I would like the user to be redirected to his website, and in the case of a card like here: https://stripe.com/docs/payments/accept-a-payment?integration=elements

If you ask if you will be able to reuse "Stripe payment method" in gateway other than Stripe then the answer is no 😃

That's not what I meant, it would be weird. I am asking if omnipay has such a method.

So that I could download payment methods regardless of the gateway. I want to do a stripe now but want the code in backend to be the same for another gateway.

judgej commented 3 years ago

OmniPay has a limited set of functionality as standard - authorise, pay, void, fetch payment details, and a few helpers. That's just about it.

Any driver for a specific payment gateway can extend this with gateway-specific features. Be aware that those gateway features won't be portable across other gateway types.

trendak commented 3 years ago

I only have one question. Does omnipay have a payment method download function?

domis86 commented 3 years ago

can you define what you mean by "payment method download" ?

iantearle commented 3 years ago

@trendak It sounds like you want to get the payment method "card number and security details" and use it on another payment gateway?

So that I could download payment methods regardless of the gateway. I want to do a stripe now but want the code in backend to be the same for another gateway.

That's fraud. You're not going to be able to download the payment method, you can poll stripe for the type of card used and the last four digits, but no payment gateway is going to give you the whole details of the card used. #