Giter VIP home page Giter VIP logo

utrust-ts-library's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

utrust-ts-library's Issues

Request failed with status code 400

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?

CORS error

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?

Consider update the Software License.

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.

cannot set currency

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.

Request failed with status code 500

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?

Webhook validator payload isn't equal to webhook payload

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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.