utrustdev / utrust-ts-library Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
I am trying @utrustdev/utrust-ts-library
version 1.0.4
.
on sandobox environment, with parameters
const order = {
reference: '1234',
amount: { total: '60.00', currency: 'EUR' },
return_urls: { return_url: 'https://app.ggbot2.com/settings#billing' },
line_items: []
}
const customer = {
first_name: 'satoshi',
last_name: 'nakamoto',
email: '[email protected]',
country: 'IT'
}
I am getting "Request failed with status code 400", any hint?
I am trying to implement a simple demo with React here: https://github.com/fibo/hello-utrust
I just added a createOrder
to a submit button in a form but when I trigger it I get a CORS error.
The instructions about how to run the demo code are really simple and documented in the repo's README.
Can you please give me any hint?
Hi,
I see that this software is licensed with GPL. Is it compatible with this library use case?
For example I am building a commercial product and I am not releasing as Open Source Software: GPL could have issues with that.
I would consider using the MIT license or any other license that provides users the freedom to build a commercial product.
Furthermore I see that the package.json license attribute is ISC
.
Hi, I am trying the following code
import { ApiClient } from '@utrustdev/utrust-ts-library'
const API_KEY = process.env.REACT_APP_API_KEY
export async function placeOrder () {
const { createOrder } = ApiClient(API_KEY, 'sandbox')
const order = {
reference: 'order-51367',
amount: {
total: '10.00',
currency: 'EUR'
},
return_urls: {
return_url: 'http://example.com/success',
},
line_items: [{
sku: 'item-unique-id',
name: 'Donation',
price: '10.00',
currency: 'EUR',
quantity: 1
}]
}
const customer = {
email: '[email protected]',
country: 'US'
}
const { status, data, errors } = await createOrder(order, customer)
console.log(status, data, errors)
}
And I am getting this error
The types of 'amount.currency' are incompatible between these types.
Type 'string' is not assignable to type 'Currency'.
I noticed that in the tests in this repo, there is a cast to Currency
, something like
currency: <Currency>'EUR',
I wanted to try it in my project but il looks the Currency
type is not exported.
Can you suggest me a solution? Thanks.
I am getting "Internal Server Error" when trying to create an order.
To reproduce it you can use this script
import { ApiClient } from "@utrustdev/utrust-ts-library";
async function test() {
console.log(process.env.UTRUST_API_KEY);
const { createOrder } = ApiClient(process.env.UTRUST_API_KEY, "sandbox");
const order = {
reference: "1234",
amount: { total: "60.00", currency: "EUR" },
return_urls: {
callback_url: "https://www.example.com/callback",
return_url: "https://www.example.com/thank-you",
},
line_items: [
{
sku: "basic",
name: "subscription",
price: "60.00",
currency: "EUR",
quantity: 1,
},
],
};
const customer = {
email: "[email protected]",
country: "IT",
};
try {
const { data } = await createOrder(order, customer);
console.log(data);
} catch (error) {
console.log(error);
}
}
test();
Any hint?
Edit: It seems the problem is with the website instead, as it displays eventType, but actually it did send event_type.
This issue can therefore be closed as no adjustments to the library are needed. I will leave it open so maybe the website can be fixed instead :)
Hello everybody!
The webhook validator expects a payload in the following form:
{
event_type,
resource: { amount, currency, reference },
state,
signature: eventSignature,
}
From the (staging) environment I receive however the following payload:
{
"eventType": "ORDER.PAYMENT.RECEIVED",
"resource": {
"amount": "0.05",
"currency": "EUR",
"reference": "[redacted]"
},
"signature": "[redacted]",
"state": "completed"
}
Not that it uses eventType
while the validator expects event_type
.
While it is an easy workaround to create another object from the actual payload like this:
const webhookValidationPayload = {
event_type: payload.eventType,
resource: payload.resource,
signature: payload.signature,
state: payload.state,
};
I would prefer this to be aligned (or have the method accept both variants to not break existing integrations).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.