Skip to content

Commit

Permalink
Use api.donation.kiwix.org
Browse files Browse the repository at this point in the history
  • Loading branch information
rgaudin committed Nov 26, 2024
1 parent e7f9e84 commit 09acedf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Model/Payment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct Payment {
// call our server to get payment / setup intent and return the client.secret
Task { [resultHandler] in

let paymentServer = StripeKiwix(endPoint: URL(string: "http://192.168.100.7:4242")!,
let paymentServer = StripeKiwix(endPoint: URL(string: "https://api.donation.kiwix.org/v1/stripe")!,
payment: payment)
do {
let publicKey = try await paymentServer.publishableKey()
Expand Down
10 changes: 5 additions & 5 deletions Model/StripeKiwix.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ struct StripeKiwix {
throw StripeError.serverError
}
let json = try JSONDecoder().decode(PublishableKey.self, from: data)
return json.publishableKey
return json.publishable_key
}

func clientSecretForPayment(selectedAmount: SelectedAmount) async -> Result<String, Error> {
do {
// TODO: for monthly this should create a setup-intent !

Check notice on line 44 in Model/StripeKiwix.swift

View check run for this annotation

codefactor.io / CodeFactor

Model/StripeKiwix.swift#L44

TODOs should be resolved (for monthly this should create...) (todo)
var request = URLRequest(url: endPoint.appending(path: "create-payment-intent"))
var request = URLRequest(url: endPoint.appending(path: "payment-intent"))
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try JSONEncoder().encode(SelectedPaymentAmount(from: selectedAmount))
Expand All @@ -52,7 +52,7 @@ struct StripeKiwix {
throw StripeError.serverError
}
let json = try JSONDecoder().decode(ClientSecretKey.self, from: data)
return .success(json.clientSecret)
return .success(json.secret)
} catch let serverError {
return .failure(serverError)
}
Expand All @@ -62,13 +62,13 @@ struct StripeKiwix {
/// Response structure for GET {endPoint}/config
/// {"publishableKey":"pk_test_..."}
private struct PublishableKey: Decodable {
let publishableKey: String
let publishable_key: String

Check warning on line 65 in Model/StripeKiwix.swift

View check run for this annotation

codefactor.io / CodeFactor

Model/StripeKiwix.swift#L65

Variable name 'publishable_key' should only contain alphanumeric and other allowed characters (identifier_name)
}

/// Response structure for POST {endPoint}/create-payment-intent
/// {"clientSecret":"pi_..."}
private struct ClientSecretKey: Decodable {
let clientSecret: String
let secret: String
}

private struct SelectedPaymentAmount: Encodable {
Expand Down

0 comments on commit 09acedf

Please sign in to comment.