Relation between payment and invoices in ledgerJournalTrans - axapta

I'm working on AX 2012 and I need the relation between invoice (account payable->payment journal) and payment (account payable->invoice journal).

There is no such direct relation.
Usually the invoice issuer provide a payment id (from the payment slip) to be used on the payment. When paying you are supposed to provide the payment id but no law of nature force you to do so.
The payment id may be an invoice id, a customer id, a combination of the two, or some other unique identification of the payment.
All AX versions contain a field on the LedgerJournalTrans table called PaymentId for this purpose. It may be blank.

Related

How to Sync CPT Data oder BG Group Meta with User/member

i have big Challenge and i want to know, if it’s possible.
I need a Solution to create Company Profiles with Fields about the Adress, ZipCode, City etc… This Company can create a user (employee).
This User can invite another User(employee) to this Company.
If he do that, the Company profile Fields must be Synced with the Employee Profile Field Data.
The Employee Fild Data about the Company must be the Same as tthe Company.
My Acutally Setup:
User Creation: BuddyPress
Company Profiles: With BuddyPress Groups
To create a Group (Company) and a User Registration i use Buddyforms.
Buddyforms Create a new Post in a Custom Post Type with the Company Information an attach this Post to the Group.
Maybe is it possible, all BP Group Members will be synced with this custom fields?
Or maybe i need another Solution?
Regards

Corda - question for flow have multi state

I have 2 states : invoice state keep detail of invoice such as invoice no , amount , vat , payment batch (reference to payment state) etc. and payment state keep detail of payment such as payment batch , items of invoice. What's the best practices to implement flow when invoice paid ?
create updatePaymentFlow for update status to "PAID" in payment state and create updateInoviceFlow for update status to "PAID" in invoice state and then loop of all invoice in payment batch to call updateInoviceFlow.
create only flow updatePaymentAndInvoiceFlow for update both payment state and invoice state.
If there is an example that would be great.
see picture
Looking at the picture I understand that a Payment is dependent on Invoice state, and an Invoice state will have its own status - PAID/UNPAID, and Payment state will have its own status field - PAID/UNPAID. Payment state status will be PAID once all the invoice's have PAID status. I think what is the best way to implement this scenario is what your question is.
I would say have Invoice state as a StatePointer in your Payment state. In this way you can have a flow which will take care of updating the Invoice status. And you can have other flow which takes care of updating your Payment status. In this way, invoice status can be updated independently of Payment. Also having referencing the invoice as StatePointer(Linear Pointer) will always give you the latest updated state in Payment.

Updating Subscription status inside the database by using Stripe Webhooks

I am integrating the Stripe payment gateway with a subscription-based product website in ASP.NET Core 3.1.
I have a Subscription table in the SQL Server database. It has expiration_date (datetime) and is_active (bit) columns.
When the user subscribes to a product with a recurring price (per month), I add a current date + 1 month in the expiration_date column. I also insert 1 in is_active column to indicate that the subscription is active.
Once the first month of subscription has passed, I want the value of is_active flag of this subscription to become 0 in the database. Once the user has paid for the next month, the Current Period will update in stripe subscription and the value of is_active flag is to become 1 again.
For this purpose, I should use Stripe WebHooks. I want to get notified through webhook that a subscription period has ended. I am confused because, as per my understanding, webhook events for customer.subscription and price do not define something that gets triggered when the current period of subscription ends.
The image attached below indicates the current period and date of the next invoice. From documentation I have come to know that upcoming invoice events can be used. But I am not understanding how a webhook can be used with the upcoming invoice.
So, my questions are that which event fires at the end of the final day of one month of the subscription period and which one is fired when a new period is defined?
See https://stripe.com/docs/billing/invoices/subscription#subscription-renewal and https://stripe.com/docs/billing/subscriptions/webhooks#tracking.
When a subscription period ends, an invoice is created(invoice.created) to charge for the upcoming one. So when the cycle ends, you get a customer.subscription.updated event (because current_period_start and current_period_end are updated to the new period) and also an invoice.created event for the invoice that gets created to charge for this new period.
The way I would do it is
listen to the invoice.created event
when handling it, check that the billing_reason is subscription_cycle to differentiate from invoices created for other reasons https://stripe.com/docs/api/invoices/object#invoice_object-billing_reason
retrive the referenced subscription from the invoice(https://stripe.com/docs/api/subscriptions/retrieve) and look at the current_period_[start|end] fields, which is the information you're looking for.
You could also listen to customer.subscription.updated and check if the reason for it updating is the billing period changing(by looking for current_period_start in the previous_attributes of the Event ); or do the same as above but via invoice.paid instead of invoice.created if you only care to update your system when a successful payment is made(thats what the https://stripe.com/docs/billing/subscriptions/webhooks#tracking approach does)

Payflow Pro get the list of transaction made by customer

I need to get the list of transaction made for the customer. It should include both settled and unsettled transaction. I am having the following parameters such as reference transaction ID, name, email. Is there possibility to achieve it?

PayPal IPN and PDT mixing

I have implemented PayPal on my site. When user choose service to pay he is redirected to pay pal where he commit payment and in the end he is redirected back to my site.
Here I mix IPN and PDT. After payment I receive IPN message and save all variables in database.
When user is back to the site here I get his TXN_ID and UserID (from session) and store it in database.
I read somewhere that it is bad to mix pdt and ipn. Is there any better way to save IPN variables with UserID? Can I somehow send UserId to pay pal and get it with IPN message later when user finish payment?
I'm sorry I have to reopen question. I added 'invoice' field to send UserID to pay pal. But when I try to pay next time with same user ID I am redirected to pay pal page and I receive this error message:
This invoice has already been paid. For more information, please
contact the merchant.
It seams that invoice is not a good option to send user id to pay pal.
I tried to put user ID in "custom" field.
<input name="custom" type="hidden" id="custom" value="<%= UserInfo.UserID%>">
But all I get in IPN message is:
custom=%3C%25%3D+UserInfo.UserID%25%3E
The way I do it is to use the invoice field. This is a field you can send PayPal and they will send it back in the response. This is how I identify transactions coming back from PayPal.
And in my case I don't process both PDT and IPN messages. I process only the one that hits me first. When the second message (PDT or IPN) arrives I check that I have already processed that transaction and I simply discard it.
Also, please don't forget that you need to verify that the messages came from PayPal. Once you get the PDT or IPN message you need to post back to PayPal with your unique Auth_id and the tx token they sent in the original message. You should not rely on any field from the original message.
Once PayPal receives your confirmation request, it will send you a second message with the transaction details. This is the one you should rely on.
I don't see any benefit on processing both PDT and IPN messages for the same transaction. Having said that I do encourage you to implement both, because none of them are guaranteed to reach you.
Edit to include how to pass the invoice to PayPal
To pass the invoice to PayPal, just create a field like:
<input type="hidden" name="invoice" value=$uniquevaluecreatedbyyourapplication>
The unique id could be your user id.
The post to PayPal will be something like
paypal/or/sandbox/address?all the other fields&invoice=123456
Paypal will send back the invoice in the PDT and IPN messages.
Edit - non-unique invoice id number
I did further research and you can configure PayPal to accept multiple transactions for the same invoice id or to accept only one transaction per invoice id. See below the information straight from PayPal's website:
Blocking Accidental Payments
You can choose whether to accept payments with the same Invoice ID or
to block payments when the Invoice ID was already used.
When you receive payments from buyers, you can include an optional
Invoice ID field to track payments; buyers will not see this ID. A
buyer's Invoice ID must be unique for each transaction. If PayPal
receives a payment with an Invoice ID that was used for another
payment, PayPal will not accept the transaction.
To set the options for blocking this type of payment:
Log in to your PayPal account at https://www.paypal.com.
The My Account Overview page opens.
Click the Profile subtab.
The Profile Summary page opens.
In the Selling Preferences column, click the Payment Receiving
Preferences link.
The Payment Receiving Preferences page opens.
Scroll down the page to the Block accidental payments section as shown
below.
Select one of the following options:
Yes, block multiple payments per invoice ID – Do not accept more
than one payment per invoice. This option prevents duplicate payments
that you must refund.
No, allow multiple payments per invoice ID – Do not limit the number
of payments received for an invoice. Choosing this option might result
in duplicate payments that require a refund.
Scroll to the bottom of the page and click the Save button.
Another option would be to create your invoice id with user id + a random number. This would make it unique.
See below a sample code to get unique invoice numbers.
var r = Math.floor(Math.random()*100000);
var invoice = userid + "-" + r;
You could also use date & time instead of a random number.
var d = new Date();
var invoice = userid + "-" + d;
And in the response back from PayPal, you just discard what comes after the dash.
I hope this helps.

Resources