You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
606 B
25 lines
606 B
6 months ago
|
package data
|
||
|
|
||
|
import (
|
||
|
"bkb-payment/third_party/paypal"
|
||
|
"context"
|
||
|
"fmt"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func (r *greeterRepo) PaypalToken(ctx context.Context) (string, error) {
|
||
|
token, _ := r.data.rdb.WithContext(ctx).Get("access_token:paypal").Result()
|
||
|
if token == "" {
|
||
|
err, accessToken := paypal.GetAccessToken()
|
||
|
if err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
_, err0 := r.data.rdb.WithContext(ctx).Set("access_token:paypal", accessToken.AccessToken, time.Duration(accessToken.ExpiresIn)*time.Second).Result()
|
||
|
if err0 != nil {
|
||
|
fmt.Println(err0.Error())
|
||
|
}
|
||
|
return accessToken.AccessToken, nil
|
||
|
}
|
||
|
return token, nil
|
||
|
}
|