0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Scheduler】Using PayPal Rest API (Transaction:Get)

Last updated at Posted at 2022-11-02

This time, I will use PayPal Rest API to get Transaction data and save it to the file system.
Sharperlight provides various JavaScript functions for developers. Let's write JavaScript code using those functions and define them as scheduler tasks.
Initially, the underlying code is created with fixed Tokens and query parameters.
Refer to the following pages for authentication and data acquisition methods.

I also used Postman to verify authentication and data retrieval requests. At the stage of this article, I get Token with Postman and use it by pasting into JavaScript code.

Now, start Scheduler from the Sharperlight application menu.
image.png
Once the Scheduler is running, start creating tasks with the New button.
In the General tab of the task dialog, fill in Code, Group and Description, for example like this.
image.png
Go to the Actions tab. Here I actually send a request and get the Transaction data. Start creating a JavaScript action using the new icon.
image.png
A JavaScript action is added like this, so fill in the code and description. Then write the JavaScript code in the central script field.
image.png
The code this time looks like this. Created a transaction_Get function.
image.png
The obtained data will be saved in the Temp folder of the C drive with the file name PayPal_Transaction.json.
Token is after Bearer in the middle of the code.
I also used the following for the parameters:
start_date, end_date, fields, page_size, page
The two functions you can see at the bottom of the code, the lib_sys.urlContent.Get function, is a function to send a GET request, and the lib_sys.io.file.WriteAllText function writes the data got to a file.

Once the code is complete, use the Test button to validate the code.
Since I used an expired Token, I got an error like this.
image.png
Get a new Token in Postman and use it.
image.png
No errors this time.
image.png
Is the file created? Look in the Temp folder on the C drive.
It's there:thumbsup:
image.png
Let's open it. If you open it with Visual Studio Code, it will be properly formatted and displayed. I was able to get it successfully:clap:
image.png
Up to here for this time...

Thank you.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?