Invoice number in create_with_paypal node sdk PayPal - node.js

I'm using Create PayPal SDK to make a transaction using paypal and redirecting the user to paypal.
I'm using the same code as per suggested in above link, but i want to send invoice number with create paypal to be shown under transaction detail. but i am not able to find how can i send a invoice number to paypal.
Please guide me if there is any object in which i can sent the invoice number to Create PayPal SDK OR any other method through which i can sent invoice number to PayPal.
Note: this project is in sailsjs.
Thanks

Please check this: https://github.com/paypal/PayPal-node-SDK/blob/master/samples/invoice/send.js
var invoiceId = "INV2-GLJ8-9FA2-26BB-GHLU";
paypal.invoice.send(invoiceId, function (error, rv) {
if (error) {
console.log(error.response);
throw error;
} else {
console.log("Send Invoice Response");
console.log(rv);
}
});
Please look at the complete invoice example here, there is everything you need: https://github.com/paypal/PayPal-node-SDK/tree/master/samples/invoice
As per documentation you can handle your custom IDs:
For exploring additional payment capabilites, such as handling
discounts, insurance, soft_descriptor and invoice_number, have a look
at this example. These bring REST payment functionality closer to
parity with older Merchant APIs. https://github.com/paypal/PayPal-node-SDK

Related

payment intent not changes status after processing

const reader = await stripe.terminal.readers.processPaymentIntent(
'reader_id',
{ payment_intent:'payment_intent.id' }
);
I am integrating stripe terminal for collecting payment. I have created payment intent first and then I am processing that payment intent with processPaymentIntent API. I have read in stripe docs that after processing it changes status from 'requires_payment_method' to 'requires_capture' but in my case it is not changing status. Please guide me. Thanks in advance!
After processPaymentIntent you will need to wait for customers to insert their card to the reader. Have you observed that step is done successfully? There are 4 approaches to observe:
Listen to webhooks
Poll the Stripe API
Use the PaymentIntent
Use the reader object
Refer to Stripe Doc for more detail.

How to get payment response callback to my backend while using all-in-one sdk on Android

I am trying to setup paytm in my Flutter app, I create the txn token on firebase cloud function in which the callback URL I pass it is paytm's static url, https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=order_id. While the payment flow is working on the client side, I'm not sure how do I get back the response of the payment ON MY BACKEND once the transaction is complete (succeeded or failed)? Do I set up a polling just after I create the transaction token to call the order status API? I tried setting up a webhook in the dashboard > Developer > Webhooks > payment notification, but no requests are made from the paytm servers after the transaction (same goes for refund webhooks).
There is a one plugin available for doing this called paytmkaro you can use this but it's only work with production keys.
Before starting upload the server side code on server which is available on their documentation which is available here please don't make any changes on server side code it's used to generate a txn token on paytm server.
Change the minimum sdk version to 19
and just copy paste this code
` try {
PaytmResponse paymentResponse = await _paytmKaro.startTransaction(
url: serverside code url e.g. https://arcane-temple-61754.herokuapp.com/intiateTansection.php,
mid: your Production merchant id,
mkey: your merchant key,
customerId:customer id (must be unique for every customer),
amount: transection amount,
orderId: Order Id (Order id must be unique Everytime for every order),
);
if(paymentResponse.status=="TXN_SUCCESS"){
Navigator.push(context, MaterialPageRoute(builder: (context)=>txnSuccessful(paytmResponse: paymentResponse,)));
}
else if(paymentResponse.status=="TXN_FAILURE"){
Navigator.push(context, MaterialPageRoute(builder: (context)=>txnFailed(paytmResponse: paymentResponse,)));
}
}
catch(e){
print(e);
key.currentState.showSnackBar(SnackBar(content: Text(e.toString()))); // platformVersion = 'Failed to get platform version.'
}`
and you are done.
Please raise a query to paytm -> Open paytm developer portal than go into the FAQ section and click on send a Query.

Stripe API get invoices is empty but payment intents successful

I'm using NODE JS Stripe API (in test mode) to fetch a customers invoices as follows:
stripeInvoices = await stripe.invoices.list({
customer: user.stripeCustomerId
})
// => Returns: { data: [] }
But it returns an empty list even though I can see transactions in the dashboard (See image below).
As a side node, I store the payment intents IDs in my own database during the payment process and can get the info that way but why is the invoice empty?
Thanks in advance for your help.

Stripe Automatic Confirmation and order fulfillment without Webhooks?

The stripe documentation says when using payment intent using automatic confirmation you should Asynchronously fulfill the customer’s order using webhooks.
If i'm offering a service e.g. ability to download a file once purchased then why do I need to monitor for the payment_intent.succeeded webhook?
If payment succeeded in the following handleCardPayment function then is there still a possibility for the charge to fail? Why shouldn't I allow the user to download the file straight away if the payment has succeeded?
var cardholderName = document.getElementById('cardholder-name');
var cardButton = document.getElementById('card-button');
var clientSecret = cardButton.dataset.secret;
cardButton.addEventListener('click', function(ev) {
stripe.handleCardPayment(
clientSecret, cardElement, {
payment_method_data: {
billing_details: {name: cardholderName.value}
}
}
).then(function(result) {
if (result.error) {
// Display error.message in your UI.
} else {
// The payment has succeeded. Display a success message.
}
});
});
Maybe I've not understood how the handleCardPayment works. Any help appreciated.
When using handleCardPayment, the issue is not so much that the payment might fail, it's that it might succeed but your code doesn't know about it.
handleCardPayment kicks off several asynchronous steps — showing the user a dialog to authenticate a payment with their bank, processing the actual charge against their card, and closing the dialog. It's only after all that completes does the Promise resolve and your function that receives result executes.
Consider the case where:
the customer clicks Pay
handleCardPayment is called
the customer sees a dialog from their bank to authenticate the
payment
they do that, and they consider that their payment is now complete,
and they close their browser immediately.
In this case, your code will never execute, but Stripe still processed the charge. So you don't know that the payment happened and you can't fulfil the order.
That's why it's important to use webhooks, so you get notified asynchronously when the payment completed, even if the user closed their browser mid-process and your code after handleCardPayment never got a chance to run. Alternatively you can use the manual confirmation flow, where the steps are split up and the actual charge isn't processed until your server makes a separate API call.

Paypal: Transaction History with REST API / Nodejs SDK

I would like to display all the inbound/outbound transactions a user made/received to display it in a simple html list.
I'm using the recommended node.js module https://github.com/paypal/rest-api-sdk-nodejs and I'm trying to use this code to get the transactions:
// Get Transaction History
paypal.payment.list({
'count': 100,
'sort_by':'create_time',
'sort_order': 'asc',
'start_time': '2008-03-06T11:00:00Z'
}, function(error, payment_history){
if(error){
console.error('error', error);
response.data.payment_history = {};
} else {
console.log('history', payment_history);
response.data.payment_history = payment_history;
}
response.finish();
});
but payment_history gives me { count: 0 }. I'm pretty sure that I have transactions since 2008.
I'm not really sure what's the problem. The user is already logged in using the access_token and I can display user informations but I have no idea how to pull transaction informations.
Look into https://developer.paypal.com/docs/faq/#general-developer-questions for the answer to "Can I retrieve the history of transactions created using the Classic APIs using the REST API?".
I also ran into this issue. Strangely, It seems that the PayPal REST API only returns results for payments made through the REST API. See here: https://stackoverflow.com/a/18139747
Classic API will remain the way to do this until the REST API is improved.

Resources