How to view coinbase transaction activity - node.js

The node.js tests : https://github.com/coinbase/coinbase-node/tree/master/test & documentation : https://github.com/coinbase/coinbase-node do not appear to describe tests or functionality that return all activity on account.
I'm attempting to access all buys and sells of currencies for an account.
Is this functionality available ? Can view via an api call buys and sells for an account for each currency coinbase supports ?
Update : im attempting to access cummulative sum of all purchases for all currencies within coinbase portfolio. Is my method above the canocical way to achieve this ?

As documented under List transactions:
Lists account’s transactions. See transaction resource for more information.
HTTP REQUEST
GET https://api.coinbase.com/v2/accounts/:account_id/transactions
SCOPES
wallet:transactions:read
Example request
var Client = require('coinbase').Client;
var client = new Client({'apiKey': 'API KEY',
'apiSecret': 'API SECRET'});
client.getAccount('2bbf394c-193b-5b2a-9155-3b4732659ede', function(err, account) {
account.getTransactions(function(err, txs) {
console.log(txs);
});
});

Related

Generate Stripe Subscription Link

I want to create a payment link for a subscription in the backend and send it to the client without having any frontend site.
const customer = await stripe.customers.create({
metadata: {
author_id: "author_id",
custom_id: "custom_id",
},
....
}
First I created a customer, using my app specific credentials. Then I want to generate a link using this custome id, but I'm kinda confused how to make it work,
Stripe documentation shows something like this,
await stripe.paymentLinks.create({
line_items: [{price: price_id, quantity: 1}],
});
But it creates a completely new product price.
Is there any way to create a link using pre made product price id and customer metadata using Stripe NodeJS backend?
You cannot pass a pre-existing Customer object (cus_xxx) when creating a Payment Link. The default behaviour for Payment Links infer that a new Customer object be created depending on other parameters set on the Payment Link, as noted in the documentation:
The Checkout Session will only create a Customer if it is required for Session confirmation. Currently, only subscription mode Sessions require a Customer.

Angular/node.js Stripe Checkout Integration (1 account to facilitate payments from third party payer to third party receiver)

Man, I have been at this for some days and can't find a good solution to this. I want to use my account (via public key and private key) to facilitate payments from one account to another (nothing will be going into my account). On the front-end I have:
checkout(amount) {
const strikeCheckout = (<any>window).StripeCheckout.configure({
key: environment.PRODUCTION==='true'?stripeLiveClientId:stripeTestClientId,
locale: 'auto',
token: (stripeToken: any) => {
if(stripeToken){
console.log(stripeToken)
this.createCharge(stripeToken,amount)
}
}
});
strikeCheckout.open({
name: 'Camel Stripe',
description: 'Stripe Checkout',
amount: amount
});
}
Just a small snipet, but essentially this just captures the credit card and email and ensures it is a valid credit card and then makes a stripe token. I then pass this token to the node backend and do:
stripe.paymentIntents.create({
amount: priceInPence,
currency: 'usd',
source: stripeTokenId,
capture: false, // note that capture: false
}).then(charge => {
return res.json({ success: true, message: 'Success', result: charge })
}).catch(error => {
res.status(400).json({ success: false, status: 400, message: error });
});
//})
};
No matter how I structure it, it always end's up getting the payment to my account, the account with the public/private key. Does anyone know a way I can use this token since it has the necessary information, and send the money to another account?
You can't accept payments and move the funds into a completely different Stripe account unless you're using Connect.
To piggy back on Paul's comment, after much research on Stripe Connect I wanted to share my findings. Please note this is specific to my use case and is using angular/express.
Connect offers multi-party payments, meaning you can receive funds from 1 user, then route them into another users account. You will need a stripe connect account. After that you connect an account, aka create account. They offer 3 account types all these account types need to be
Custom: basically is if you don't want the account you're routing to to see anything stripe related, meaning it is white labeled and the user has no dashboard or view of what is going on in the background.
Standard(the one I chose): this account will have a full stripe dashboard, it has all the functionality that an account would have that you make on your own. You will get a unique account id relevant to your specific connect account environment, on their end, they will have multiple account ids depending on how many other connects they are connected to, or if it is an already existing account. You will need to use this api to get the link to have them verify information before they are integrated into your connect environment account link api
Express: they will have a slimmed down version of a dashboard, it is similar to standard with less functionality
At this point you're ready to start routing payments. I did angular on the front-end, here is an example basically this simply creates a stripeToken, which is a verification that the card data is valid. You need to pass this to a backend to make use of it, this will not create any charges.
On the backend, I used express, you use the charge api You pass the stripeToken as the source attribute. One important step is to add the stripe account id you see in your connected accounts dashboard. It should look similar to:
stripe.charges.create({
amount: priceInPence,
currency: 'usd',
source: stripeTokenId,
capture: false, // note that capture: false
},{
stripeAccount:'{{acctId}}'
})
This should be sufficient to get your payments routing to the necessary account while leveraging a simple UI checkout.
One thing to note about the charges API, this is an older API and has less functionality. For my use case (US CA only with only card payments) it is sufficient. If you have a more complicated use case, or maybe your app is for heavy prod use to many users you should look into payment intents.

List all charges of a Connected Stripe Account

I have stripe platform with connected stripe accounts.
I would like to obtain all charges that have been made on a particular connected account.
User connected account id:
acct_xxx
The only documentation I can find is for retrieved customers based on secret api keys.
https://stripe.com/docs/api/charges/list
const stripe = require('stripe')('sk_test_xxx');
const charges = await stripe.charges.list({
limit: 3,
});
I need to obtain all charges of a connected account. Not charges on the platforms customers.
I found a similar stack overflow question for ruby. Get a list of the charges on a Stripe account connected via Stripe Connect
I do not know how to achieve this using node.js
You need to pass the Stripe-Account header to make API calls "on Connect accounts": https://stripe.com/docs/connect/authentication#stripe-account-header
Most of Stripe's client libraries (like stripe-node) allow passing a parameter with each API call function, in the options hash, like:
const charges = await stripe.charges.list(
{
limit: 3,
},
{
stripeAccount: 'acct_12345'
}
);

How to implement Paypal subscription in a vue application?

I am working on a project which needs to deducts a fixed amount from a user's account to a business account on monthly basis. I am trying to create a Paypal button client side (vue) for accepting subscriptions on monthly basis. The users deduction information on monthly basis shall be stored in a database. The user shall also provided an option to cancel the subscription. Any help would be greatly appreciated.
Well i found out an answer after a little digging in the documentation provided at https://developer.paypal.com/docs/subscriptions/integrate and went through the steps they provided.
Steps
Create a product through their API by providing access_token in the headers.
After the product has been created, get product-Id from response and then create plan using the product_id in request body.
After the plan has been successfully created copy Plan_id and replace the id in smart subscription button.
paypal.Buttons({
createSubscription: function(data, actions) {
return actions.subscription.create({
'plan_id': 'P-your_plan_id'
});
onApprove: function(data, actions) {
alert('You have successfully created subscription ' + data.subscriptionID);
}
}

How to get Paypal transactions in NodeJS

Problem description:
I go into my paypal buyer sandbox account and send 10 Pounds to my facilitator sandbox account. The transaction goes trough and all is fine. I log into my facilitator account and i see the transaction.
Now when i use the following nodejs code to get the transactions:
var paypal_api = require('paypal-rest-sdk');
var config_opts = {
'host': 'api.sandbox.paypal.com',
'port': '',
'client_id': 'HIDDEN',
'client_secret': 'HIDDEN'
};
var listPayment = {
'count': '10',
'start_index': '0'
};
paypal_api.payment.list(listPayment, config_opts, function (error, payment) {
if (error) {
throw error;
} else {
console.log("List Payments Response");
console.log(JSON.stringify(payment));
}
});
i get this in the console:
List Payments Response
{"count":0,"httpStatusCode":200}
So its not showing me any transactions.
How can i see those transactions?
I have read on another Stackoverflow thread that these might not show up because they are not done trough REST. If thats the case, would payments done trough the official PayPal mobile app appear in my NodeJS response?
Question 2:
Is there any way by using NodeJS to see transactions that are coming into my merchant account? (paid in from the PayPal app, or from their website)
Question 3:
How can i use WebHooks to see the transactions in NodeJS?
I would really appreciate your help guys, ive been looking everywhere for a response to these questions.
Thank you so much.
Alex
EDIT 1:
I have tried Webhooks and i still cant get anything to trigger when i do a transaction. An event triggers on my NodeJS side only when i use the Webhook simulator, but not when i do a normal transaction on Paypal using my sandbox accounts.
I wonder if there is any way to test things with the Paypal mobile app, does anybody know if you can do sandbox testing with the mobile app?
Click manage webhooks and Add your webhook listener URL(API endpoint), then select which event you want to get from PayPal.

Resources