#Custom payment Provider

113 messages Β· Page 1 of 1 (latest)

modern verge
#

hi, i am trying to create a custom payment provider for medusa

i created a service i attached the file below

but i cant see the provider in the admin is there something i am missing here

civic delta
#

you are missing static identifier = "wallet-provider" or the name you want

#

Also, I suggest you to look at the stripe plugin if you feel like it

modern verge
#

i added it but still not working i am also using stripe plugin in addition to it is there any restriction on multiple payment providers and also i can directly run the backend or do i need to do something before starting the backend? @civic delta

civic delta
#

you need to build and then start

modern verge
#

got it after i build and started its working i am using nodemon for dev seems like its not working for this current scenario

civic delta
#

It should work, weird

#

What is your script?

modern verge
#

nodemon --watch './src/**/*.ts' --exec ts-node ./src/main.ts

civic delta
#

You should exec build and run. Also, run from dist/main.js

modern verge
#

Thank you!

modern verge
#

this.options_ = options
it showing a linter error if i trying to access this option in extended payment service
is it normal or am i doing something wrong?

civic delta
#

And what does the error says?

modern verge
#

@civic delta if i am using the custom payment provider should i use custom store front or next js will support. i just dupliacted the manual payment service from the code and excecuted.. the store front throws the error with no "paymenSession.provider_id" ?

civic delta
#

You might need to update your store to display the payment element/component linked to your provider

balmy ridge
#

In my side, i was able to add payment provider in admin setting.

#

but in the frontend, I am getting issue "paymentSession"..

#

This is error screen after I put billing address and click checkout.

civic delta
#

have you updated your payment info map?

balmy ridge
#

where should I update it?

civic delta
#

you can look where it is imported from and it just open

balmy ridge
#

I have not changed storefront code. I just added payment service in the backend.

#

Like this

civic delta
#

Yes, but you have to update your store front to display your provider and give the user the ability to select it

balmy ridge
#

ok.

#

Cool

#

it worked

#

I updated paymentinfomap

civic delta
#

πŸŽ‰ perfect

#

@modern verge you need to do the same

balmy ridge
#

@civic delta May I ask one more thing?
After that, what should I do? can you please explain some next steps that I need to pass?

civic delta
#

Now, you should be able to select the provider, it will set it has active on your cart and set it has initiated while communicating with the provider. But you should be able to use it now unless there is a bug in your implementation

modern verge
balmy ridge
#

Here, you can find payment-container/index.ts\

modern verge
#

okayyy!

balmy ridge
#

Now when I click "my custom provider item", it does not show any element, but before that, it has 500 server issue.

#

@civic delta is there any issue here? thank you

#

Does this require "createPayment" method in backend service?

civic delta
#

Yes you need to implement all the methods

balmy ridge
#

okay, then do you think everything should be ok once I finalize all the methods only?

civic delta
#

It should yes

#

I don't see anything else to do as of now

#

Once the 1.8 is released, you might want to migrate to the payment processor API (easier to implement) and you will be able to look at stripe and paypal plugins that will have been migrated

balmy ridge
#

awesome but when is eta of release 1.8?

civic delta
#

I don't have the exact ETA but it should be in the coming weeks

balmy ridge
#

that's great. πŸ₯³

balmy ridge
#

Here, I have one question.

#

How to pass option values into contructor? which means is where I should call this class?

civic delta
#

the second argument of the constructor are the plugin options πŸ‘

cobalt jetty
#

You would need to create a plugin from your service.

civic delta
#

so in your medusa-config, in the plugins, you have your plugin and you can pass the options

#

the second option is to create a new object in project-config. the second arg of the constructor will be the config. and you can then retrieve it from there. If I am right

balmy ridge
#

oh. so I need to create on plugin... but basically I am going to start on backend itself. in this case, I need to put option variables directly on constructor right?

cobalt jetty
#

You can hardcode them now if you want, yes.

balmy ridge
#

Got it.

#

Once it works in my side, I am going to convert it to plugin finally

#

πŸš€

balmy ridge
#

πŸ₯³ I passed step 1, it works well.

civic delta
#

Very nice πŸ™Œ

balmy ridge
#

Hi, Here, I found wired thing.

#

In the storefront, I can see 10$ as subtotal and 20$ as total, but I can see 2000, 1000 in session.

#

what's wrong?

#

also, as you can see, its payment amount is always 2500 EURO

#

even though I changed currency EUR to USD.

#

The payment number is also wrong..

#

it should be 20$.

#

I am not sure what's my wrong.

civic delta
balmy ridge
#

ok..

balmy ridge
#

I changed it in admin panel

civic delta
#

what do you mean?

#

you have to handle it in your payment provider implementation

balmy ridge
#

Yes, I did it

#

but in admin panel, if admin change currency from EUR to USD, the payment intent session is also need updated?

civic delta
#

if your region change its currency there is an issue, in France the last time the currency has changed was in 2000

#

but yes indeed, in that case you can create a subscriber and get all active carts and update the initiated payment session. But I think that if the currency changed, you need to inform your customer first as they have paid in one currency and then it is another one

#

Not sure this is a case that happen

balmy ridge
#

ah, I understand..

#

in that case, we need to notice maintaneous at least to customers..

#

ok, I got you.

#

thank you a lot.

balmy ridge
#

I want to change product from EU to NA..

#

I selected NA option, but product price does not change to NA.

#

what is the wrong?

cobalt jetty
#

It's not relevant to this discussion topic

#

But probably your cart is in different region

balmy ridge
cobalt jetty
#

Or region is different in local storage.

#

Can't remember now how nextjs starter sets that.

balmy ridge
#

yah, it seems region is not my location..

balmy ridge
#

πŸš€ I was able to finalize the integration of my custom payment gateway on medusa.

#

Thank you for all your support.

civic delta
#

That is awesome 😊

#

Glad to ear

sacred oasis
#

@civic delta @modern verge @cobalt jetty
I need some help regarding this. I have both the storefront and backend admin code.
I want to create a custom provider for my app and I’m using Medusa version 1.20.9. I have attached the code files.
Do I need to pull the backend code, or should I only be working in the backend admin code?
Additionally, when creating a custom provider, how can I integrate a payment gateway into the storefront?
I really need serious assistance with this issue. Any help would be greatly appreciated.

cobalt jetty
#

Do not ping and DM (😑) for help. Creating your own thread is enough.

timid needle
# balmy ridge

which version of Medusa are you using, I've updated to the latest version and it is different than screenshot. Edit: my bad I thought I was looking at a new thread. It was from 2023.