#jtapping-ios-currency

1 messages ยท Page 1 of 1 (latest)

mellow iron
#

hey there, can you share a snippet showing where this comes from in your code?

marsh fable
#

hi - yeah I can try. I don't actually control this VC though, its part of the Stripe integration.

#

evertything else in the app shows correctly .... just this one view controller.

#

I'm using the Stripe API's of course

wicked delta
#

this is a surprisingly difficult question to answer actually. Trying to figure it out!

marsh fable
#

ha ha:)

#

i get the impression that its hard coded in the stripe API ... bu that would be strange. Must be an override but I can't find it.

wicked delta
#

my current guess is it's hard coded on Apple's side based on the country of the shipping address but still digging

marsh fable
#

thats the thing, I am shipping to Ffance .

#

France

#

thanks

wicked delta
#

ah, it takes the value of the STPPaymentContext.paymentCurrency

paymentContext.paymentSummaryItems = [
            PKPaymentSummaryItem(label:"Pay", amount:42.42, type:.final)
        ];
        paymentContext.paymentCurrency = "eur"
#

if that's what you're using, or do you use a different VC? (your code only shows how you interact with your backend, not which part of the SDK you're using)

marsh fable
#

Excellent that looks great. Now to look at how to use it. Thankyou

#

this looks like what I am using

wicked delta
#

cool!

#

let me know if there's anything else we can help with or if you're not using the STPPaymentContext

marsh fable
#

MyAPIClient.sharedClient.createPaymentIntent(products: products, orderReferenceId: orderReferenceId!, shippingMethod: paymentContext.selectedShippingMethod, country: shippingCountry, paymentCurrency = "eur") { result in

#

looks like I need to do this

#

looks good thanks agin

wicked delta
#

well not really, that code is how you call your backend

marsh fable
#

again

#

really ?

#

hmm, confused

wicked delta
#

somewhere in your app you should have something that looks like

 self.paymentContext = STPPaymentContext(customerContext: customerContext,
                                                configuration: STPPaymentConfiguration.shared,
                                               theme: theme)

for example

#

it's in that VC where you are setting this up

#

it's also where you have added code to define that 3.50 amount

#

look for didUpdateShippingAddress for example

marsh fable
#

required init?(coder aDecoder: NSCoder) {

    let customerContext = STPCustomerContext(keyProvider: MyAPIClient.sharedClient)
    self.paymentContext = STPPaymentContext(customerContext: customerContext)
    
    super.init(coder: aDecoder)
    
    self.paymentContext.delegate = self
    paymentContext.hostViewController = self
    self.paymentContext.paymentAmount = 5000 // This is in cents, i.e. $50 USD
    
    // MyAPIClient.sharedClient.baseURLString = "https://stripetestsjta.herokuapp.com/"
    
    let config = STPPaymentConfiguration.shared
    config.appleMerchantIdentifier = self.appleMerchantID
    config.companyName = "QRCode for Wifi"
    config.requiredBillingAddressFields = .full
    
    config.requiredShippingAddressFields = [.postalAddress, .emailAddress, .name]
    
    //config.shippingType = settings.shippingType
    config.applePayEnabled = true
    config.fpxEnabled = false
    config.cardScanningEnabled = true
    
}
wicked delta
#

yep!

#

so where you have self.paymentContext.paymentAmount = 5000 there

#

you want to add a line with self.paymentContext.paymentCurrency="eur"

#

it defaults to USD if you don't pass a currency

marsh fable
#

ah got it

#

in the init ...

#

perfect

#

thankyou

wicked delta
#

(what the STPPaymentContext shows there is technically separate from what the customer is actually charged by the way, since that's controlled by your PaymentIntent created on the backend, just for clarity)

marsh fable
#

yes understood

marsh fable
#

confirmed working ๐Ÿ™‚

#

are you from Stripe ?

mellow iron
#

yes, admins in this channel are stripe engineers ๐Ÿ™‚

#

glad its working for you ๐Ÿ˜„