Switch to int based currencies

parent a03f86ad
......@@ -107,6 +107,7 @@ func paypal() {
spew.Dump(payment)
panic("Actual base of transaction value is not 10")
}
valuei, _ := value.Int64()
// spew.Dump(payment)
p := mq.Payment{
......@@ -123,7 +124,7 @@ func paypal() {
Email: payment.Payer.PayerInfo.Email,
DateTime: *payment.Transactions[0].RelatedResources[0].Sale.CreateTime,
Amount: value,
Amount: valuei * 100, // in smallest currency unit
AmountS: payment.Transactions[0].Amount.Total,
Currency: payment.Transactions[0].Amount.Currency,
......
......@@ -79,6 +79,7 @@ func paypal(context smolder.APIContext, id string) (db.Payment, error) {
spew.Dump(payment)
return p, errors.New("Actual base of transaction value is not 10")
}
valuei, _ := value.Int64()
// spew.Dump(payment)
mp := mq.Payment{
......@@ -95,7 +96,7 @@ func paypal(context smolder.APIContext, id string) (db.Payment, error) {
Email: payment.Payer.PayerInfo.Email,
DateTime: *payment.Transactions[0].RelatedResources[0].Sale.CreateTime,
Amount: value,
Amount: valuei * 100, // in smallest currency unit
AmountS: payment.Transactions[0].Amount.Total,
Currency: payment.Transactions[0].Amount.Currency,
......@@ -109,7 +110,7 @@ func paypal(context smolder.APIContext, id string) (db.Payment, error) {
}
pretty.Println(mp)
p.Amount, _ = value.Float64()
p.Amount = valuei * 100 // in smallest currency unit
p.Currency = payment.Transactions[0].Amount.Currency
p.Code = payment.Transactions[0].Custom
p.Description = payment.Transactions[0].Description
......
......@@ -19,7 +19,7 @@ type PaymentResponse struct {
type paymentInfoResponse struct {
ID int64 `json:"id"`
UserID int64 `json:"user_id"`
Amount float64 `json:"amount"`
Amount int64 `json:"amount"`
Currency string `json:"currency"`
Code string `json:"code"`
Description string `json:"description"`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment