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