bazzar/pay_u
2022-04-24 13:37:35 +02:00
..
src PayU client 2022-04-24 12:55:22 +02:00
tests/responses PayU client 2022-04-24 12:55:22 +02:00
Cargo.toml Add readme and license 2022-04-24 13:37:35 +02:00
Readme.md Add readme and license 2022-04-24 13:37:35 +02:00

Payu REST API

Install

cargo add pay_u

Usage

async fn usage() {
    let client_id = std::env::var("PAYU_CLIENT_ID").unwrap();
    let client_secret = std::env::var("PAYU_CLIENT_SECRET").unwrap();
    let merchant_id = std::env::var("PAYU_CLIENT_MERCHANT_ID").unwrap().parse().unwrap();
    let mut client = Client::new(client_id, client_secret, merchant_id);

    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;
}

Bugs

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