Collect customer credit card and start a subscription later with Laravel Cashier - laravel-5

For some business reasons, I need to collect customers credit card data and start the subscription at a later (unknown) date. The reason is because we need to proceed to some verification before actually starting the subscription. Thus I can not use the trialDays() method.
Any idea on how to achieve this?

That's actually the more common way to do this. Simply collect the payment details and create a token (or source) using your front-end. Then attach that token (or source) as a payment method on the customer record using the Create Card API Method.

Related

Laravel Cashier - Prevent duplicated Payment Methods

I'm trying to update the payment method of a subscription. I collect the card information using Stripe's js (using a provided setup intent). Then I send the payment method id, provided by Stripe's js, to Laravel to actually update the User's default payment method.
Now, the problem is I want to prevent the User to insert duplicated cards, and the only way to prevent that would be to retrieve all the user current payment methods ($user->paymentMethods();), and check if any of those has the same fingerprint of the one I'm adding as default.
To get the fingerprint of the new payment method I'd need to get the Stripe PaymentMethod object for the id provided by the Stripe's js. The Cashier method to do that would be $user->findPaymentMethod(id).
The problem is that the payment id is not yet added to the User payments methods, so $user->findPaymentMethod($request->payment_method); fails because that payment method does not belong to $user.
The only solution I can think of would be to first add the new payment method, then check for duplicates and remove them ?
It seems like you’ve already found the best approach of adding the method to the user and then looking to see if there are any duplicated fingerprints, even if it is a little inconvenient.
Reviewing the Cashier documentation doesn’t show any obvious way to access the PaymentMethod before it’s attached to the user. It may be worth reaching out to the Laravel devs to see if there is functionality that would make this flow easier to accomplish.

Should I call verifyBuyer for off-session payments

I'm integrating Square payment gateway into our system. And want it to support SCA.
In their dev docs it says that I should call verifyBuyer each time I want to charge CoF. Also, "If a challenge is required, Square automatically displays the challenge to the buyer". It's ok for on-session payments. But what about off-session payments, like cars rental service does - without customer online (automatically)?
In their dev docs it says nothing or I'm missing something.
Did anybody face with such case?
Our docs state:
Important
The SCA flow must not be initiated for a card on file transaction where the buyer is not present. In this scenario, do not call the verifyBuyer function. You can still charge the card but be prepared to handle the CARD_DECLINED_VERIFICATION_REQUIRED error.
Basically, don't call verifyBuyer, and don't pass a token to the payment endpoint. The payment could still technically fail, so you should build functionality to handle that.
https://developer.squareup.com/docs/payment-form/cookbook/verify-buyer-on-cof

Braintree hosted fields integration - edit existing card data

I'm using Braintree hosted fields to allow credit card payments, and users can use multiple cards.
How can I allow users to edit existing cards? For example, when a card is renewed by the bank, it keeps the same card number, but the expiration date and CVV change. I want users to be able to edit the expiration date and CVV to keep the card active. Is this possible, or does the user have to enter in a new card from scratch with the same card number?
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support
Once your customer has their payment method stored in a Vault record you can use their associated payment method token to run a PaymentMethod.update() call. Using the payment method update you can change most attributes of the stored method, and you can find a full list of those attributes here. When updating actual card information, such as CC number, expiration date, etc. it is recommended that you generate a nonce with the new information rather than entering it manually, but either will work just fine.

How to Implement credit card and paypal transactions like fiverr in laravel

I want to integrate transactions like in fiverr or upwork in my laravel website. I have tried braintree but that only helps in checkouts. I want to store the payments in my application and then send them to a bank account or paypal when the work is done just like fiverr or upwork
Your requirement is to perform the transaction (send the payment to a bank/paypal) and create a records for your system, that the particular transaction happend, isn't it ?
If it's the case, if you are to use Paypal, the best possible way is to read the paymentID and payerID from the session when the transaction is complete (using the payment gateway) and locally (in your application) perform an insert query to your table with the data been extracted with any other system specific additional details you may need to add to you record.
If you use the following,
https://github.com/net-shell/laravel-paypal
you can easily modify the getDone() for this insertion.

linking parse and stripe user

My app requires users to log in with Parse to make a purchase and uses parse cloud to process payments using Stripe. Payment works fine. I want to associate the card that just used to make the payment to the [PFUser currentUser] so I can load the cards for user to select next time. How can I achieve that? Is it possible to get the card information from the token?
P.S one user can have many card and one card can belong to many user.
I'm not sure exactly what you mean by "card information" but it should be possible to achieve what you want. You'll want to first create a Customer object in Stripe to represent each user. Each Stripe Customer has a list of payment sources associated with them, and you can read the brand and last4 if you need to display a list of these to the user to select one.
Once you create a customer in Stripe, you can create any number of Charges.
All of this can be done in a straightforward manner using the intuitive Stripe API. You can also manage Customers and Charges via the Stripe dashboard.

Resources