-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrefund.go
More file actions
42 lines (32 loc) · 905 Bytes
/
refund.go
File metadata and controls
42 lines (32 loc) · 905 Bytes
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
package main
import(
"fmt"
"github.com/yourpayments/go-api-client"
)
func main(){
merchant := ypmn.GetMerchantFromEnv() // Получить данные мерчанта из environment
// merchant := ypmn.Merchant{MerchantCode:"CC1", MerchantSecret:"SECRET_KEY"}
// Можно передать данные вручную
refund = Refund{
PayuPaymentReference: "123456"
OriginalAmount: 100
Amount: 100
Currency: "RUB"
}
responce, err := apiRequest.SendRefundRequest(refund)
if(err != nil){
panic("Error: " + err.Error())
}
code, _ := responce["code"].(float64)
if(int(code) == 429){
panic("Слишком много запросов")
}
if(int(code) == 202){
panic("Операция возврата уже была совершена")
}
if(int(code) != 200){
fmt.Println(responce)
panic("Bad responce")
}
fmt.Println("Успешный возврат")
}