List Payouts of stripe Account - ruby

According to Stripe Payout API
I need to retrieve all payouts of a destination, So i made this request:
def all_payouts(external_account)
return Stripe::Payout.list(
:destination => external_account
)
end
from the API I tried to send the external_account(like "ba_XXXX") but it keeps returning
No such external account: ba_XXXX while testing it using Postman, I checked the external_account but it is exists on stripe.
Any help?

Since this is a common enough question and easy to miss that you solved it in the comments, here's the correct code to do this.
When trying to list payouts on a connected account, you have to make the API request authenticating as this account. You would pass the platform's Secret API key along with the connected account's id in the Stripe-Account header. In Ruby, the code would look like this:
payouts = Stripe::Payout.list(
{:destination => external_account},
{:stripe_account => "acct_XXXXXX"},
)

Related

How does Djoser account verification system really works under the hood?

So I'm currently in an attempt to make my own account verification system and I'm using some parts of Djoser as a reference. let me try to walk you to my question
Let's say you're to make a new account in Djoser app
you put in the information of your soon to be made account including email
submit the form to the backend
get an email to the whatever email account you put in earlier to verify your account
click the link in your email
get to the verify account page
now in this page there's a button to submit a UID and a token and both of those information lies in the URL.
My question is:
What are those tokens? is it JWT?
How do they work?
How can I implement that in my own projects without djoser?
The answers to your questions are immersed in the own code of djoser.
You can check djoser.email file and in the classes there, they are few methods get_context_data().
def get_context_data(self):
context = super().get_context_data()
user = context.get("user")
context["uid"] = utils.encode_uid(user.pk)
context["token"] = default_token_generator.make_token(user)
context["url"] = settings.ACTIVATION_URL.format(**context)
return context
So get the context in the class where is instance, and in this context add the 'uid' (this is basically str(pk) and coded in base64, check encode_uid()), the 'token' (just a random string created with a Django function from your Secret key; you can change the algorithm of that function and the duration of this token with PASSWORD_RESET_TIMEOUT setting) to use temporary links, and finally the URL according the action which is performed (in this case the email activation).
Other point to consider is in each of this classes has template assigned and you can override it.
Now, in the views, specifically in UserViewSet and its actions perform_create(), perform_update() and resend_activation(), if the Djoser setting SEND_ACTIVATION_EMAIL is True, call to ActivationEmail to send an email to the user address.
def perform_create(self, serializer):
user = serializer.save()
signals.user_registered.send(
sender=self.__class__, user=user, request=self.request
)
context = {"user": user}
to = [get_user_email(user)]
if settings.SEND_ACTIVATION_EMAIL:
settings.EMAIL.activation(self.request, context).send(to)
...
The email is sent and when a user click the link, whether the token is still valid and uid match (djoser.UidAndTokenSerializer), the action activation() of the same View is executed. Change the user flag 'is_active' to True and it may sent another email to confirm the activation.
If you want code your own version, as you can see, you only have to create a random token, generate some uid to identify the user in the way that you prefer. Code a pair of views that send emails with templates that permit the activation.

Calling Graph Api from Web Api doesn't return all user data

In my ASP.NET Core Web Api, I'm trying to call Graph API to retrieve the data of other users in the organization. I'm using the On Behalf Of flow. The bootstrap token is passed in from SPA client code.
In the Startup code, I have:
builder.Services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(builder.Configuration)
.EnableTokenAcquisitionToCallDownstreamApi()
.AddMicrosoftGraph("https://graph.microsoft.com/beta", "user.read user.readbasic.all profile")
.AddInMemoryTokenCaches();
In the Controller's Action, I have:
_graphServiceClient.Users.Request()
.Filter($"mail eq 'someuser#myorg.com'")
.Select((user) => new {
DisplayName = user.DisplayName,
City = user.City,
Country = user.Country,
BusinessPhones = user.BusinessPhones
})
.Request()
.GetAsync();
However, at runtime, I only get the DisplayName value. I don't get the values of City, Country or BusinessPhones. They are al null.
When I tried the same query in Graph Explorer, I saw the values for all of them.
What am I missing?
First, your code snippet has an error that you wrote 2 .Request(), you should remove one.
Whatever flow you used are all generating an access token so that you can access the api, therefore when you got correct data from the api, that means you have a right setting in using the flow, so I think if there's any issue, it should locate at the part of calling api. Then I did some test in my side.
Could you pls check if you call the api directly, you can get the value of City, Country and BUsinessPhones these 3 properties? Per my test, when I call the api, I can get response like screenshot below and by default it's null
https://graph.microsoft.com/beta/users?$filter=mail eq
'tinywang#xxx.onmicrosoft.com'&$select=mail,city,country,DisplayName,BusinessPhones,userType,usageLocation
And when I followed this tutorial to call the api via sdk, I got the same result:
My idea is checking the response of calling the api first and if we can't find the issue, then could you pls provide the tutorial you followed to help reproduce the issue.

Filter envelopes by email docusign

I need retrieving all the envelopes that have been signed or sent to an email.
I was trying to do this using the 'accounts/{account_id}/envelopes' endpoint passing the 'search_text' query param. As in the example in documentation https://developers.docusign.com/esign-rest-api/guides/concepts/envelopes/search
/v2.1/accounts/{account_id}/envelopes?search_text=Tabs
But I'm getting always error 400 - INVALID_REQUEST_PARAMETER. Am I doing this in the wrong way?
I think 4644 is most likely not your account ID. can you check what is your account ID?
Also, add :
&from_date=2019-03-04T00:00:00.000Z&to_date=2019-03-07T00:00:00.000Z

Get Recent Campaign Sends from Mailchimp API

I'm trying to pull the latest sends from all my campaigns in Mailchimp via the 3.0 API. The only way I seem to be able to do this is:
1) Search for a given member by email
/3.0/search-members?query=joe#example.com
2) Get the member ID and request their activity
3.0/lists/{LIST ID}/members/{USER ID}/activity
3) Pull the content of the email in their activity feed:
3.0/campaigns/{CAMPAIGN ID}/content
The problem with this is that I need to know the user's email in advance and then search by each user individually, meaning many wasted of API calls.
Is there an endpoint for campaigns that I can request the last sends for a given date range?
The /campaigns endpoint returns campaigns for a given list and each returned object does include a recipients property.
You may also want to checkout:
/search-campaigns
And:
/reports/{campaign_id}/sent-to

Inapppurchases: get api query failed "code":400,"message":"Invalid Value" "code":500,"message":null

I get access_token by this way :https://developers.google.com/android-publisher/authorization
1.use google account allow acess get code
2.use code to get refresh_token
3.use refresh_token get access_token
when use this api
$url_purchase = "https://www.googleapis.com/androidpublisher/v1.1/applications".
"/$packageName/inapp/$productId/purchases/$token?access_token=".
$return_data->access_token;
$return_purchase = http_get($url_purchase);
some billing return
{"error":{"code":500,"message":null}}
some billing return
{"error":{"errors":[{"domain":"global","reason":"invalid","message":"Invalid Value"}],"code":400,"message":"Invalid Value"}}
but some billing can success return
{"kind":"androidpublisher#inappPurchase","purchaseTime":"1395035642794","purchaseState":0,"consumptionState":1}
I think the access_token is right, why some billing failed . someone can help me ?thanks very much.
Are there any other way to check billing valid on the server?

Resources