From 4ccf3ad87768b14c19dd08c1c45d3a197af09799 Mon Sep 17 00:00:00 2001 From: eraden Date: Sun, 24 Apr 2022 13:37:35 +0200 Subject: [PATCH] Add readme and license --- pay_u/Cargo.toml | 2 ++ pay_u/Readme.md | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/pay_u/Cargo.toml b/pay_u/Cargo.toml index 1e7608a..db02ad2 100644 --- a/pay_u/Cargo.toml +++ b/pay_u/Cargo.toml @@ -1,7 +1,9 @@ [package] name = "pay_u" +description = "PayU Rest API wrapper" version = "0.1.0" edition = "2021" +license = "MIT" [dependencies] reqwest = { version = "0.11.10", features = ["default", "native-tls", "json"] } diff --git a/pay_u/Readme.md b/pay_u/Readme.md index 50b09c4..3f16cbc 100644 --- a/pay_u/Readme.md +++ b/pay_u/Readme.md @@ -1,2 +1,53 @@ # Payu REST API +## Install + +```bash +cargo add pay_u +``` + +## Usage + +```rust +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 +