Payu REST API

Install

bash cargo add pay_u

Usage

```rust async fn usage() { let clientid = std::env::var("PAYUCLIENTID").unwrap(); let clientsecret = std::env::var("PAYUCLIENTSECRET").unwrap(); let merchantid = std::env::var("PAYUCLIENTMERCHANTID").unwrap().parse().unwrap(); let mut client = Client::new(clientid, clientsecret, merchant_id); client.authorize().await.expect("Invalid credentials");

let _res = client.create_order(
    OrderCreateRequest::new(
        Buyer::new("john.doe@example.com", "654111654", "John", "Doe", "pl"),
        "127.0.0.1",
        "PLN",
    )
        // Endpoint which will be requested by PayU with payment status update
        .with_notify_url("https://your.eshop.com/notify")
        // payment description (MANDATORY)
        .with_description("RTV market")
        // add list of products
        .with_products(
            [
                Product::new("Wireless Mouse for Laptop", 15000, 1),
                Product::new("HDMI cable", 6000, 1),
            ]
                .into_iter(),
        )
        // add additional product
        .with_product(Product::new("HDMI cable", 6000, 1)),
)
    .await;

let _res = client
    .partial_refund(
        "H9LL64F37H160126GUEST000P01",
        RefundRequest::new("Refund", 1000),
    )
    .await;

} ```

Notification with Actix

```rust use actix_web::{, web::};

[post("/payu/{ownorder_id}/notify")]

async fn handlenotification(path: Path, Json(notify): Json) -> HttpResponse { let status = notify.status(); let orderid = path.intoinner(); match handleupdate(orderid, status, notify) { Ok() => (), Err(e) => { // ALWAYS SEND OK! log::error!("{e:?}"); } }; HttpResponse::Ok().body("") } ```

Bugs

Please report bugs here: https://todo.sr.ht/~tsumanu/payu-rs