-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathPaymentSample.cs
42 lines (37 loc) · 1.61 KB
/
PaymentSample.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Model.Generated.Object;
using Bunq.Sdk.Samples.Utils;
namespace Bunq.Sdk.Samples
{
public class PaymentSample : ISample
{
private const int UserItemId = 0; // Put your user ID here
private const int MonetaryAccountItemId = 0; // Put your monetary account ID here
private const string PaymentAmount = "0.01";
private const string PaymentCurrency = "EUR";
private const string CounterpartyPointerType = "EMAIL";
private const string CounterpartyEmail = "[email protected]";
private const string PaymentDescription = "This is a generated payment!";
public void Run()
{
var apiContext = ApiContext.Restore();
var paymentMap = new Dictionary<string, object>
{
{Payment.FIELD_AMOUNT, new Amount(PaymentAmount, PaymentCurrency)},
{
Payment.FIELD_COUNTERPARTY_ALIAS,
new Pointer(CounterpartyPointerType, CounterpartyEmail)
},
{Payment.FIELD_DESCRIPTION, PaymentDescription}
};
var paymentId = Payment.Create(apiContext, paymentMap, UserItemId, MonetaryAccountItemId).Value;
Console.WriteLine(Payment.Get(apiContext, UserItemId, MonetaryAccountItemId, paymentId));
// Save the API context to account for all the changes that might have occurred to it
// during the sample execution
apiContext.Save();
}
}
}