#miran-testing

1 messages · Page 1 of 1 (latest)

toxic grotto
ocean roost
#

Hi, will I get the payment method by using this id like 'pm_card_visa' ?;

#

$paymentMethod = \Stripe\PaymentMethod::retrieve($request->get('paymentMethod'));

#

here's the code

toxic grotto
#

what are you trying to test though?

ocean roost
#

I want to create subscription

#

manually we can do that, but now we want to automate the test

#

or should I pass the 'pm_card_visa' in the subscription create function?

toxic grotto
#

you need to pass in a Customer when creating a subscription. The customer also needs to have a payment method attached

#

so what you'd need to do is to have an existing customer with pm_card_visa attached (and set the default payment method). Then create a subscription with that same customer

ocean roost
#

What if I reuse a payment method id from another test customer?

#

Like, I'll grab a id from the dashboard payments tab?

#

Will that work?

toxic grotto
#

if you're intending to explicitly pass the payment method id in the subscription's default_payment_method, yes that would work. As long as you remember to pass in that particular test customer when creating the subscription too

ocean roost
#

Can several customers have same payment method attached to them?

toxic grotto
#

each PaymentMethod id is unique. Even if you use the same credit card details e.g. 4242 test card, the generated PaymentMethod id would be different

#

so you can have the same credit card attached to several different customers

#

but not the same PaymentMethod attached to several different customers

ocean roost
#

So, how can I generate unique PaymentMethod, each time I want to attach it to a customer?

#

that we get inside handleCardSetup method using test card numbers like 4242424?

ocean roost
#

thanks.