|
1
|
|
|
package e2e |
|
2
|
|
|
|
|
3
|
|
|
import ( |
|
4
|
|
|
"context" |
|
5
|
|
|
"net/http" |
|
6
|
|
|
"os" |
|
7
|
|
|
"testing" |
|
8
|
|
|
|
|
9
|
|
|
"github.com/NdoleStudio/neero-go" |
|
10
|
|
|
"github.com/davecgh/go-spew/spew" |
|
11
|
|
|
"github.com/stretchr/testify/assert" |
|
12
|
|
|
) |
|
13
|
|
|
|
|
14
|
|
|
func TestTransactionIntentService_CashIn(t *testing.T) { |
|
15
|
|
|
// Arrange |
|
16
|
|
|
source := os.Getenv("NEERO_SOURCE_PAYMENT_ID") |
|
17
|
|
|
destination := os.Getenv("NEERO_DESTINATION_PAYMENT_ID") |
|
18
|
|
|
request := &neero.TransactionIntentCreateRequest{ |
|
19
|
|
|
Amount: 10000, |
|
20
|
|
|
CurrencyCode: "XAF", |
|
21
|
|
|
PaymentType: neero.TransactionIntentPaymentTypeMerchantCollection, |
|
22
|
|
|
SourcePaymentMethodID: &source, |
|
23
|
|
|
DestinationPaymentMethodID: &destination, |
|
24
|
|
|
Confirm: true, |
|
25
|
|
|
MetaData: map[string]any{"order_id": "1234"}, |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
// Act |
|
29
|
|
|
transaction, response, err := client.TransactionIntent.CashIn(context.Background(), request) |
|
30
|
|
|
|
|
31
|
|
|
// Assert |
|
32
|
|
|
assert.Nil(t, err) |
|
33
|
|
|
assert.Equal(t, http.StatusOK, response.HTTPResponse.StatusCode) |
|
34
|
|
|
assert.NotEmpty(t, transaction.ID) |
|
35
|
|
|
spew.Dump(transaction.ID) |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
func TestTransactionIntentService_Get(t *testing.T) { |
|
39
|
|
|
// Arrange |
|
40
|
|
|
transactionID := "68cf03354e5f2f5a69f72773" |
|
41
|
|
|
|
|
42
|
|
|
// Act |
|
43
|
|
|
transaction, response, err := client.TransactionIntent.Get(context.Background(), transactionID) |
|
44
|
|
|
|
|
45
|
|
|
// Assert |
|
46
|
|
|
assert.Nil(t, err) |
|
47
|
|
|
assert.Equal(t, http.StatusOK, response.HTTPResponse.StatusCode) |
|
48
|
|
|
assert.Equal(t, transactionID, transaction.ID) |
|
49
|
|
|
assert.Equal(t, "SUCCESSFUL", transaction.Status) |
|
50
|
|
|
spew.Dump(transaction.ID) |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
func TestTransactionIntentService_CashOut(t *testing.T) { |
|
54
|
|
|
// Arrange |
|
55
|
|
|
source := os.Getenv("NEERO_DESTINATION_PAYMENT_ID") |
|
56
|
|
|
destination := "68cf045e0aac937c7e5140b1" |
|
57
|
|
|
request := &neero.TransactionIntentCreateRequest{ |
|
58
|
|
|
Amount: 1000, |
|
59
|
|
|
CurrencyCode: "XAF", |
|
60
|
|
|
PaymentType: neero.TransactionIntentPaymentTypeOrangeMoneyTransfer, |
|
61
|
|
|
SourcePaymentMethodID: &source, |
|
62
|
|
|
DestinationPaymentMethodID: &destination, |
|
63
|
|
|
Confirm: true, |
|
64
|
|
|
MetaData: map[string]any{"order_id": "1234"}, |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
// Act |
|
68
|
|
|
transaction, response, err := client.TransactionIntent.CashOut(context.Background(), request) |
|
69
|
|
|
|
|
70
|
|
|
// Assert |
|
71
|
|
|
assert.Nil(t, err) |
|
72
|
|
|
assert.Equal(t, http.StatusOK, response.HTTPResponse.StatusCode) |
|
73
|
|
|
assert.NotEmpty(t, transaction.ID) |
|
74
|
|
|
spew.Dump(transaction.ID) |
|
75
|
|
|
} |
|
76
|
|
|
|