Stripe API PHP. Get all payments of subscription by subscription_id - php

I receive a hook from Clickfunnels that contains a "subscription_id": "sub_AnDOcr3inf0Qfx". How can I get all payments of this subscription using this data? Will be very appreciated for any help.

You can list all Invoices for the given Customer and Subscription and each of those will have a charge property that you can then retrieve (or you could just expand itĀ for your 'list Invoices' API call).

Related

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.

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.

Stripe- Send Payment to Customers

I want to use STRIPE PHP API for creating payments to customers and for that i have found the code to create the customers but not for to create payment for them.
Code to create customers:
https://stripe.com/docs/api#create_customer
require_once('./lib/Stripe.php');
Stripe::setApiKey("sk_test_k9NE13Q2LjsIvYTNQHiP5C5H");
Stripe_Customer::create(
array( "description" => "Customer for test#example.com",
"card" => "tok_1509ycG2gfbJDdl3oYWMe6yq" // obtained with Stripe.js
));
My Scenario is : I have some products and customers comes to my site and purchase the product but some of the customers will come from the affiliate banner and we need to pay some commission amount to the affiliate customers.
So, for such scenario i have to create customers and create payment for them and i have found PHP API code for creating the customers but not for the creating payment to that customers.
As I understand, you should use Stripe managed accounts for your customers to make Payouts.
https://stripe.com/docs/connect/managed-accounts
https://stripe.com/docs/connect/payouts
You'll need to collect additional customer verification data to make payouts to managed accounts:
https://stripe.com/docs/connect/identity-verification
https://stripe.com/docs/connect/updating-accounts#account-verification
https://stripe.com/docs/connect/required-verification-information
https://stripe.com/docs/connect/testing-verification
I think your problem here is that you're misunderstanding the customer option in the stripe dashboard.
A typical use would be you register a customer and once you've done that you can charge their card as required, i.e., they are still sending you money, which I believe isn't what you want.
Two options I can see for you.
It's possible to transfer money from your Stipe account to a 3rd party bank account or credit card. See stripe transfers and also this FAQ
Alternatively there is a now Stripe Connect which might just be the ticket for you.
Good luck!

How to get "Non-Amazon" sales channel order through "Amazon MWS Order API"

I'm using amazon MWS api to get the complete amazon order list. It's pretty good to have such api which returns Fulfilled by Amazon (AFN) and Fulfilled by the seller (MFN) orders.
I can see all Sales Channels (Amazon, Non-Amazon) orders once i logged in to amazon seller central. But problem is, this api does not return "Non-Amazon" Sales Channel orders.
Note : i'm sending only CreatedAfter parameter with other required parameters.
Is there a any way to get "Non-Amazon" Channel orders through MWS Order API?
Or
Amazon does not provide Non-Amazon sales channel order information through api and if it's true, then it means i have to logged in to seller central and manually note down "Non-Amazon" Channel orders details.
I would appreciate any help!
Non-Amazon sales channel order is either created through merchant or using Fulfillment Outbound Shipment API Action "CreateFulfillmentOrder". To get those orders information back we need to use Fulfillment Outbound Shipment API Action "GetFulfillmentOrder".
These api definitely gonna save lot of time :)
To get Non-Amazon Orders list, you have to consume "FulfillmentOutbound" Api. Let me note down how you will use this.
For US Marketplace , https://mws.amazonservices.com/scratchpad/index.html
open this link and in API Section select "Fulfillment" option then under Operation you have to select FulfillmentOutbound -> ListAllFulfillmentOrders
now you have to fill the seller information and enter the date from which you want to receive orders .

Magento - Create credit memo / refund programmatically through code

Is there any way of creating a Credit Memo / Refund dynamically through code. I am aware of the fact that Credit Memo can be created using back-end functionality on an invoice but I would like to create a credit memo for a specific order separately based on the following requirements
For selected items
Deduct the shipping cost from the refund
Updating the Stock Qty back
Contacting my payment gateway to perform this refund and transfer the money back into customer's account
I have Sagepay module installed as well for payment purposes and the Refund happens fine using Magento's in built functionality and Sagepay together. But I would like to create a Refund when a customer after shipment asks for refund for few items or all items of a order.
I have created a custom module and am calling a function to perform the refund action. So on call of this function I want to dynamically create Refund for selected items and contact Sagepay to perform the refund transaction for the customer and Magento to update the stock back.
I would just like some help on the starting bits as to where to look for the code and how to combine Sagepay's refund functionality along with Magento's in built one in my module's function call etc ?
Any help is appreciated. Thanks in advance.
I have found an API(see link below) for creating credit memos.
http://www.magentocommerce.com/boards/errors.php/viewthread/215141/

Categories