Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation example for b2b #24

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions examples/b2bpayment.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
extern crate africastalking_gateway;

use std::env;
use std::collections::HashMap;
use africastalking_gateway::AfricasTalkingGateway;


fn main() {
let username = env::var("AFRICAS_TALKING_USERNAME").unwrap();
let apikey = env::var("AFRICAS_TALKING_APIKEY").unwrap();

let gateway = AfricasTalkingGateway::new(&username, &apikey, "sandbox");

let mut recipient_payload: HashMap<&str, &str> = HashMap::new();

recipient_payload.insert("username", "Matt Gathu");
recipient_payload.insert("provider", "PaymentProvider");
recipient_payload.insert("transfer_type", "BusinessBuyGoods");
recipient_payload.insert("destination_channel", "supplierProviderChannel");
recipient_payload.insert("destination_account", "supplierAccount");

let mut recipient_metadata: HashMap<&str, &str> = HashMap::new();

recipient_metadata.insert("shopId", "1234");
recipient_metadata.insert("itemId" , "abcdef");

let amount: f32 = 100.0;

println!(
"{:?}", gateway.mobile_payment_b2b_request("My Online Store", recipient_payload, "KES", amount, recipient_metadata)
);

}