Laravel Cashier: newSubscription doesn't create Stripe user - laravel-cashier

It's not clear from the documentation but, from what I've gleaned anecdotally from others' comments and examples, the newSubscription function is supposed to:
a. take the token as created in createToken()
b. create customer in Stripe
c. associate a new subscription with that new customer
d. update Laravel databases accordingly
Is this correct? In my testing, I always get the same message:
"message": "No such customer: tok_********************",
"exception": "Stripe\Error\InvalidRequest",
because Cashier has not in fact created a Stripe user using my token.
Apologies if I'm missing something obvious. Are we supposed to use the Stripe PHP to create Customer and THEN use Cashier to associate a subscription to that customer?

Turns out that the term "stripe_id" in the documentation, Laravel means the Stripe Customer ID (cus_1234), although I don't see that that's explicitly defined anywhere. So I was mistakenly saving the Stripe token as stripe_id (tok_1234), and then trying to add the subscription to the user later, which doesn't work. Maybe this is intuitive to people who've used Laravel extensively.

Related

EXPO REACT-NATIVE STRIPE PAYMENT 'expo-payments-stripe': How to use a token created?

I can generate a token with the createTokenWithCardAsync function, but then I don't know how to use the token to go through with the payment process.
Would anyone know which functions are in the 'expo-payments-stripe'? The actual stripe functions like stripe.customers.create() or stripe.charges.create() do not work. So far I just know of 2 functions compatible with that package, the one I mentioned above and createTokenWithCardFormAsync...
Ultimately I would like to attach the token to a customer so that they don't need to put their card details everytime they want to purchase something.
Also at the moment of token creation I do not charge any money, just want to 'keep' their info just like uber does.
thanks!
Customer creation and Charge creation on Stripe is a secret-key only function, therefore cannot be done on your client-side (your mobile app which can only use your publishable key).
Therefore, the flow here is:
Create a Token on your app (as you are)
Post the token to your backend endpoint
Your backend endpoint (written in say, node using stripe-node) calls stripe.customers.create() with the Token ID, attaching the Token to the Customer
Charge creation later also has to happen server-side, not client-side.

How does one associate a website user with a Paypal subscription?

I am implementing subscriptions to a premium service on a website using Paypal as the payment service. I have successfully created a Catalog Product and Billing Plan through the API, and I am able to get to the payment page on Paypal, but it's not clear how I'm supposed to persist a user identifier through the purchase process.
I assumed it would be something along the lines of passing a user id somewhere, but there's nothing in the Paypal documentation about this. I need to be able to let the user make a purchase and have the Paypal webhook send the confirmation to an endpoint on my site, and that's where I'd expect to get their user id to toggle the subscription on their account on my end.
Is there something I'm missing? There has to be a way to do this cause I'd imagine it's a pretty common use case. If anyone has information or has done this before, I'd love to hear. Thanks.
The only truly secure way I've found when using javascript SDK, is to securely generate a unique custom_id on your server side associated with the user.
Then when you create the buttons, the 'createSubscription' function takes custom_id as a parameter.
Then use a webhook to receive events from your subscription and the custom_id will be present in the body of all BILLING.SUBSCRIPTION events under resource.custom_id.
I am able to get to the payment page on PayPal,
You are vague about what you are doing here. There are multiple ways (and some ways have multiple versions) of accepting subscriptions via PayPal, so it is important that you provide full details about the method you are using.
The time to associate a created subscription ID with a user ID is when it is approved, in the onApprove function if you are using a Smart Payment Button: https://developer.paypal.com/docs/subscriptions/integrate/#4-create-a-subscription

Paypal rest api express checkout with no shipping field (WebProfile handling)

I'm using Paypal rest api to make payment
the workflow is:
Create payment
Redirect to approval Url
User approved (return back to my site)
Execute payment
But there's one thing that I don't want users re-filling shipping address again because it was filled in my website.
So I change the workflow to:
Create web profile (set no shipping field)
Get web profile ID
Create payment with experienceProfileId given
Redirect to approval Url
User approved (return back to my site)
Execute payment
But I found this will create a lots WebProfile every time user request payment.
I think it is crazy to do:
create and delete it later again and again
attempt listing WebProfiles and check which is the one I want to use every time while creating payment
store experienceProfileId as a constant
What is the best practice for handling WebProfile or does there any solution just hiding shipping address while user approving payments?
Maybe this is not the answer regarding this "WebProfile". As a fact, I dont know what exactly "WebProfile" does or is.
I worked on the same Workflow these days. As you wrote I needed to predefine some address. For me it was obvious, that I have to do the database-stuff on my Website. Then I exactly define the order, shipping_address, etc. and send the users to Paypal.
If you predefine the new ShippingAddress() to your ´new ItemList()´ by
$itemlist->setShippingAddress($shippingaddress) the user cannot change it within the Process.
http://i.imgur.com/nAg8jxU.png
Maybe this helps you a little.

Not able to get User Transaction details from Yodlee API

I'm using the http://developer.yodlee.com/TestDrive developer Test API module and using one of the 5 dummy accounts provided by Yodlee, For a particular user I have managed to add a dummy DAG bank account and one real bank account which is visible in getAllSiteAccounts details Api so its obvious that site have been added.
But while using the getUserTransactions API I'm getting error
{
"errorOccurred": "true",
"exceptionType": "com.yodlee.core.transactionsearch.exceptions.InvalidSearchIdentifierException",
"referenceCode": "_567afa0b-9d5a-4fb4-9db1-afd4f43c39c2",
"message": "Invalid argument value: com.yodlee.core.transactionsearch.TransactionSearchIdentifier#2ad082d0"
}
I also tried using the executeUserSearchRequest still didn't get any transaction details
{
"searchIdentifier": {},
"numberOfHits": 0
}
Can you please guide me If I'm using the API's correctly ?
You should use executeUserSearchRequest API to get the transactions. You should check the date range you have provided while searching for transactions and also try to remove itemAccountId.identifier and then search, you should get the transactions.
I'm having the same issue the only difference though is that I don't have any issues on DAG accounts, but when I used our production account I can't get the user transactions. I was reading this post Get all user transactions with executeUserSearchRequest and I guess the solution is to make sure that your server/code have the same timezone configuration.

Are there no response codes for subscriptions?

Paymill:
I'm developing a website which sells subscriptions. Whenever a new customer signs up I do the following:
Create a new "client" at Paymill
Create a new "payment" (the customers credit card) at Paymill
Add a new subscription at Paymill for this "client" using this "payment"
There are no trial periods, so Paymill issues the first transaction immediately.
But sometimes the first transaction fails, I can see in the cockpit this is due to any of these errors: https://www.paymill.com/pt-pt/documentation-3/reference/api-reference/#document-statuscodes
But how can I know this? There are no response codes in the returning subscription object (the subscription is set up fine, but the first payment fails).
What have I missed?
there are no responsecodes for subscriptions you are right, but you should register webhooks for this. Than you'll be informed if a transaction of this subscription fails and also gets the errorcode. Please have a look for webhooks here https://www.paymill.com/en-gb/documentation-3/reference/api-reference/#webhooks.
We will also make a refactoring for subscription in the first quarter of 2014. Than we'll improve also the responses.
Best,
Christian