whmcs: run function when an invoice for a new order is paid - cpanel

I'm new to whmcs, and I'm developing my first "Provisioning Modules" if you have any good resources kindly post the link.
What I want: run a function when the user pays for the module (that is a service). Why? to run specific API for that services.
I found those functions: https://developers.whmcs.com/provisioning-modules/supported-functions/

Related

Shopify: custom scripts in the checkout to execute web requests

I've a client that wants certain clients to buy with Store Credit. The amount of credit is stored in their external ERP system. My idea was to create a manual custom payment, show this payment method for users with a certain customer tag and add some scripts in the checkout in order to execute a web request and get how much credit the client has at that moment and do some validations (don't let them order if the checkout is bigger than the credit) in order to let them complete the order or not.
The only link I've found basically says:
With a few exceptions, Shopify Scripts are not capable of input/output. This means that scripts can't execute web requests or database calls, and can't get input from a user. Source: https://help.shopify.com/en/manual/checkout-settings/script-editor/limitations#input-output
The client is aware they need to upgrade to Shopify Plus, but I can't find examples or any information that indicates this idea is doable.
I don't think Shopify Script is the solution in this case. (You can't make any outside call inside a script)
If you plan to use Shopify Plus you can modify checkout.liquid. You can create an app that has an endpoints that
Tells you how many points the customer has
Redeems X points and returns a discount code
Having that you can put a javascript that when checking out insert a button to redeem the points and if it's clicked you call the api and apply the discount.
To apply dynamically a coupon at checkout this is a working piece of code.
document.querySelector("#checkout_reduction_code").value = YOUR_CODE;
document.querySelector(".field__input-btn.btn").disabled = false;
document.querySelector(".field__input-btn.btn").click();
Other solution is to use Shopify Functions (https://shopify.dev/api/functions). This is a new feature that is availble in preview and lets you customize the checkout experience. I don't have experience with that but I suppose you can do something similar.

Payments through PayPal with ASP.NET CORE 3

I am trying to run payments through PayPal in sandbox mode with my .NET CORE 3 project.
The idea is to give the customer ability to choose whether to pay using his/her PayPal account or Credit Card.
I am using the PayPal-NET-SDK v2.0.0-rc2
I am trying to understand whether this is the right order to run things:
Create Payment using PaymentCreateRequest
At this point, I get the approval_url. I redirect the customer and approve the payment/order using Credit Card
Execute payment using PaymentExecuteRequest, using the PAYID and PAYERID I get from the redirect URL. Here I get an order object
Authorize order using OrderAuthorizeRequest with the order id (setting body to a PayPal.v1.Orders.Capture object)
Capture order using OrderCaptureRequest with the order id (setting body to a
PayPal.v1.Payments.Capture object)
Is that a correct execution order?
Rather than the old v1/payments, you should use v2/orders; the v2 SDK can be downloaded here
Rather than an old-style full page redirect to an approval_url , it's much nicer to use the new checkout's in-context UI that keeps your site loaded in the background. Here is a demo pattern. Another benefit is that it gives an embedded/in-line credit card form.
As a finishing touch once you have everything working, don't neglect to
gracefully handle/propagate funding failures back from your server,
so the buyer can choose something else when declined.
If you start out with intent=capture(v2) or sale(v1), the capture(v2)/execution(v1) call will be final and complete the transaction, there will be no authorize step, so (4) on your list is skipable. (You should only bother with implementing something other than intent=capture/sale if you find you have a specific business need for delaying captures, as it adds complexity)
More general information on implementing the server-side portion of the integration: https://developer.paypal.com/docs/checkout/reference/server-integration/set-up-transaction/

VirtoCommerce - Creation of a new payment gateway

I have a big problem dealing with new payment gateway creation. I followed a tutorial but I think I did something wrong because it doesn't work well.
I would like to create a "devis" (sorry I don't know the word in english... It looks like that.
When the customer buys something, he could choose this kind of payment which does nothing but provide the "devis". It would be perfect if the status of the order could be "on hold" directly in order to unhold it when the "real payment" is done.
I hope you have understand what I try to do but if you have not be free to ask me questions.
Here is what I've done:
I created a new class in the VirtoCommerce.PaymentGateways namespace called DevisPaymentGateway which inherits from the PaymentGatewayBase class.
In this class there is just one method: ProcessPayment where I do:
payment.status = PaymentStatus.Completed.ToString();
in the SqlOrderDatabaseInitializer.cs
I created a private SetupDevisGateway method:
private void SetupPaypalGateway(List<PaymentGateway> gateways)
which is called in the CreatePaymentGateways method just after the paypal gateway.
I deployed the database thanks to your powershell script, the gateway
is created as expected.
I enabled the gateway payment via
VirtoCommerce Manager Then I bought something on the website and I
chose the new Payment which is available so it seems to work.
When I click on proceed to checkout I have a new order line which is created
with the "Pending" status so it's perfect...
When I bought something with paypal for example, there was the same reaction BUUUT when the new order line was created there was the onBeforeUpdate method which detected that new line and some work was done asynchronously. With the new gateway it seems that the onBeforeUpdate method doesn't work anymore...
I think that I've forgot something which is done with Paypal and not with my gateway but what and where?
I already know that it's not a good idea to write something in the SqlOrderDatabaseInitializer.cs but I don't think that it's the problem... Does anybody have a solution?
Thanks
Edit: Explanation on what I try to achieve:
Products which are sold are in fact a couple: "images treatments" + "images"
Each customer can manage album and put photos into it, and when he clicks on a product (which is a treatment) he can choose an album.
So it's why I need this event, when the payment is done and the status change from pending to in progress, I send relevant information (about the treatment, the album...) to a queue and I have worker roles (one for each treatment) which read these messages and do some work.
I hope you understand the idea but if you don't, do not hesitate to ask me questions
can you explain why do you need that event? What will you do when that event is raised?
Some explanation below on how status is changed for the order below:
The order status is actually changed by the job "ProcessOrderStatusWork class" that simply runs in the background and changes the status order status from "Pending" to "InProgress" after order has been in pending state for a certain period of time. I would suggesting for you to create a copy of "ProcessOrderStatusWork" class and create a new job (name it MyProcessOrderStatusWork class), that in addition to changing status also adds custom work for your payment. You can then register that Job and disable the one included with VC, so it is not duplicated (by adding it in the database,similar to how you did payment gateway).
It might work for PayPal, because it uses slightly different logic, as order created on call back from PayPal, thus executing in the same web process and event is raised.

How to test "Payment Gateway" without making real payments?

I want to perform rigrous testing on Payment Gateway(2checkout) and Pay Pal. For testing, I need to simulate a large number of successful, failed and halted transactions (transaction stopped due to system crash/reboot). But I don't want to make actual payments.
1. Is there any way I can make a test transaction on payment gateway, using fake card numbers or something else.
2. What are the possible advance testing scenarios for Payment Gateway testing?
For example:
Changing the amount, unmask CVV or card from Inspect
element.
List item
There are two options :
Using the PayPal Sandbox (Application Testing), or
Using Dependancy Injection (Unit Testing).
Both would work but I would suggest a Dependancy Injection approach. Assuming you have a separate object that only interacts with PayPal and then other objects that do your actual application logic (and error handling, etc) then you can just create a dummy version of the PayPal interaction object (that always returns true, or conditionally returns false, whatever) and then test your various application classes in detail.
I would suggest you only one solution, look at this Git PayPal-Android SDK and go through the README.md file. Last link tells you how to create a sandbox PayPal account to create dummy transactions across your sandboxed account developer account.
If you have doubts, you can refer Part 1 and Part 2 of AndroidHive tutorial for this.

Clickbank - Create products for testing (in Sandbox)

I am new to Clickbank.
I want to try out the API for the same.
But I am stuck in between.
Can anyone guide me through the steps to successfully create a product.
I am getting some errors
You must make a test purchase before submiting this request.
A footer disclaimer is required for all Pitch and Thank You pages.
Also wanted to know, like how can I setup the sandbox account?
Please help me out.
Thanks in advance.
This question was asked a very long time ago but I just happened across it and know the answers.
First, however I think anyone starting on ClickBank, technical or otherwise, will benefit from the following: https://www.clickbank.com/launch-checklist/
Now, to answer the question(s):
Test Purchase:
• Can't do this without creating a product first
• To create a product you do the following:
Login to the account
Click: Vendor Settings -> My Products
On this page locate the list of ADD NEW buttons & Click Product
The product editor pretty well walks you through the process
AND now for the test purchase.
That process is described here: https://support.clickbank.com/hc/en-us/articles/360036958431-How-do-I-test-a-payment-link-
Footer/disclaimer:
This is what is known as the ClickBank Trust Badge currently, (not sure about 9years ago).
It's a little element that you copy and paste into your webpage, after configuring what you want it to look like & where you want it to be, from the available options.
To find and set it up:
Login to the account
Click Vendor Settings -> My Site
Scroll down to the section with the title "ClickBank Trust Badge - Injection Code"
If you like the default setup you can copy what's in the Javascript Snippet field
If you want to change where it's located and colors click the Configure Settings button (not going to describe everything here as it's pretty straight forward as well)
ClickBank APIs
Last, you mentioned wanting to use the ClickBank API, which I happen to know very well. However, the documentation for it is also actually pretty good so let me start off with that:
General ClickBank API documentation
Additionally each APIs primary endpoint is self documenting. Additionally this documentation tends to be the most relevant for a programmer
Example of self documenting endpoint: https://api.clickbank.com/rest/1.3/orders2
So, it's worth noting the following that are required to use the API:
You must have an HTTP header of "Authorization" and it must be set to both of the API keys for an account.
Both keys refers to the API- "Clerk Key" as well as the DEV- "Developer Key"
Enter them both, separated by a colon ":" as the value of the Authorization key with the DEV- key first (DEV-A23478C...:API-IA23456...)
You must also use the correct HTTP request type for the query you are wanting to make (the only two that are utilized are GET and POST)
Examples:(NOTE: ACCOUNT_NAME_HERE is the ClickBank "nickname" or account name)
Single transaction: https://api.clickbank.com/rest/1.3/orders2/RECEIPT_NUMBER_HERE
List transactions by date range and specific account: https://api.clickbank.com/rest/1.3/orders2/list?vendor=ACCOUNTNAME_HERE&startDate=2021-12-11&endDate=2021-12-14
Count of transactions by date range: https://api.clickbank.com/rest/1.3/orders2/count/?vendor=ACCOUNT_NAME_HERE&startDate=2022-01-01&endDate=2022-01-01
Monetary value of transactions by date range: https://api.clickbank.com/rest/1.3/quickstats/count/?account=ACCOUNT_NAME_HERE&startDate=2022-02-01&endDate=2022-02-10
Sending shipping data for physical products (POST): https://api.clickbank.com/rest/1.3/shipping2/shipnotice/4NVXUFNW?item=2&date=2018-08-14&carrier=UPS&tracking=1NH323452345WODFS&comments=Test%20again%20comment%20with%20spaces10%20receipt=4NVXUFNW