Handle subscription creation webhooks laravel - php

I installed Cashier following the official Laravel documentation.
Then, I created a price list with my products on Stripe that I integrated into my project.
When I click on a product in the price list, I am redirected to the Stripe checkout and then proceed to payment. In the Stripe dashboard, I can see that a new customer has been created and that the subscription has been started. Stripe then sends the following webhooks to my project:
Nevertheless, Cashier does not seem to update the database.
The stripe_id field is not updated and no subscriptions are added to the subscriptions table.

Related

How to get list of failed invoices of a customer in STRIPE API?

I am working in cakephp framework and have integrated stripe api for billing and payments. Now i need to get a list of failed invoices of a customer to retry those invoices payment. I have checked Stripe API documentation but could not find a solution.
Please help.

Store Stripe payment history

I have integrated stripe in to my application.
Now i want to store the payment history in to my database.
Using stripe APIs, i can create new subscription as well as update that subscription.
Now say i have one subscription for one month for $20 and after few days i am updating to sixmonth for $60. So as per stripe logs it will deduct $40 while updating plan.
I want to store all these payment process along with subscription periods in to my database.
How can i do that. Is that any API for it?
You can use webhooks to get notification from Stripe whenever any event happen.
So you need to create a webhook for charge.succeeded. So that you can get notification for all the successful charges happen. You can get amount, customer data inside the event data which you can store to your DB. I assume you are already storing subscription along with customer, so that you can map subscription from customer data from event data.

WooCommerce Subscription - PayPal Reference Transactions

I am using woo commerce subscription plugin and integrate pay-pal as a payment method. We are selling one subscription which is monthly based.
My issue is that, in Subscription Product, we received payment through pay-pal but Subscription from woo commerce did not activate.
After doing some research I integrate API Credentials, but now I am getting error about reference transaction.
I am getting below error.
PayPal Reference Transactions are not enabled on your account, some subscription management features are not enabled. Please contact
PayPal and request they enable PayPal Reference Transactions on your
account.
Now I am getting confused that how to set billing agreement, how to set pre-approval payment. where we need to set on pay-pay or on our website. When we called to pay-pay they are saying that Reference Transaction is active on your account.
Thanks in advance
I'm going to assume this is for PayPal Express Checkout; by default Reference Transactions is "not" enabled on any account. However it can be added by request if you call the business support line to get it added.
The steps are described by WooCommerce on how to get this feature added.
Hope this helps 8^)

Add subscription record to woocommerce

I have installed woo-commerce subscriptions on my word-press site, integrating a payment gateway for checkout. The gateway is not supported by woo-commerce directly.
I have the checkout page and the payment processing page with code provided by the gateway to process the online payment.
I need to update the subscription status for the customer once his payment has gone through successfully via the gateway and the confirmation is received back.
Any pointers on how to update the subscription record in woocommerce subscriptions using a php code snippet would be very helpful.
I have searched around and found links on how to add a product in woocommerce, but not much on how to update or add a subscription record using a custom php snippet.
The solution is to create an order, then create a subscription, link the order to the subscription using woocommerce classes. A very helpful link found on SO outlines the steps:
wordpress.stackexchange.com/questions/202873/
The response given by Jeremy Warne worked for my website's logical flow.

How to make monthly subscription payments with paypal php rest api

I want to make monthly subscription payment with paypal php rest api. Is it possible with rest api. If yes then please describe how can I achieve that. Also after successful subscription how can I cancel the subscription via Api. Also how can update the DB if subscription payment is failed.
It's possible to create a subscription payment with the Paypal API.
First of all you need to create a product with the catalogue api:
https://developer.paypal.com/docs/api/catalog-products/v1/#products_create
You have to create a product regardless what you are selling (physical goods or services)
The you will use the subscriptions api to create plans that are linked to the created product:
https://developer.paypal.com/docs/api/subscriptions/v1/#plans_create
Obviously a product can have multiple plans with different pricing or billing cycle
Finally you can integrate the Smart Payment buttons to your checkout form to allow users to subscribe to a plan:
https://developer.paypal.com/docs/subscriptions/integrate/#4-create-a-subscription
You can read the currently complete guide of paypal subscription integration here:
https://developer.paypal.com/docs/subscriptions/integrate/
After a subscription is created it can be canceled via the subscription api:
https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_cancel
I don't remember how to create the recurring payment with Paypal, but as far as I know, canceling it is not possible via their api.
On our website, we have to tell the users to cancel their subscription on paypal's website.

Categories