open-pay/openpay-dotnet

Samples

Closed this issue · 7 comments

I'm sorry to post for help in here, but OpenPay support limits its responses to: You have to look at the API's reference.

I can't find a single working sample on how to implement credit card payments in my website using .net

Any help would be appreciated.

Hi @GeorgeInterface

we have son examples inside OpenpayTest folder in ChargeServiceTest.cs, what exactly do you need?

Hi Oswaldo,

Well, I am not an experienced web developer, but I have worked with another payment company, I can't figure out is the sequence of functions I need to use to process a simple payment with debit/credit card from my website.

So far I have tried this, but I just don't get the result:

` Dim card As Card = New Card()
card.CardNumber = "4111111111111111"
card.HolderName = "Juanito Pérez Nuñez"
card.Cvv2 = "123"
card.ExpirationMonth = "01"
card.ExpirationYear = DateTime.Now.AddYears(2).Year.ToString().Substring(2)
card.DeviceSessionId = "120938475692htbssd3"

    Dim openpayAPI As OpenpayAPI = New OpenpayAPI("PrivateKeyString", "MerchantIdString")

    card = openpayAPI.CardService.Create(card)
    Assert.IsNotNull(card.Id)
    Assert.IsNotNull(card.CreationDate)
    Assert.IsNull(card.Cvv2)
    openpayAPI.CardService.Delete(card.Id)`

What I need is a step by step guide with .net, is there any available?

Have you read our card charge guide? you can select .Net as Server library for seen server side code examples

You need to understand the flow starts in browser side,
. Get card information in the browser,
. Send card info to Openpay directly using our javascript library, Openpay will generate a token id
. Generate a device session id using the Openpay javascript library
. Send charge information to your server, including token id and device session id, so far every thing happened in browser side
. In your server you have to take charge information and send a charge request using .Net library to Openpay

I hope this helps

Thanks Oswaldo, but the openpay-dotnet only list the functions available, but they don't say how to use them logically.

. Get card information in the browser: DONE
. Send card info to Openpay directly using our javascript library, Openpay will generate a token id: DONE
. Generate a device session id using the Openpay javascript library: DONE
. Send charge information to your server, including token id and device session id, so far every thing happened in browser side HOW?
. In your server you have to take charge information and send a charge request using .Net library to Openpay HOW?

Hi George
In order to make this snippet to work you gotta store some IDs in the row of whoever you are gonna charge:
-deviceSessionId is the one you generate in instruction var deviceSessionId = OpenPay.deviceData.setup("payment-form", "deviceIdHiddenFieldName");
you may want to send that in a ajax request if you have a custom form

for Card_id and CustomerID you gotta create both objects acording to this https://www.openpay.mx/docs/api/?csharp#pago-a-id-registrado and store the ID from
request = api.CustomerService.Create(request); CustomerID = request.id

snippet:
ChargeRequest request = new ChargeRequest();
request.Method = "card";
request.DeviceSessionId = deviceSessionId;
request.SourceId = Card_id;
request.Description = "Concept";
request.Amount = new Decimal(Math.Round(amount, 2, MidpointRounding.ToEven));

Charge charge = openpayAPI.ChargeService.Create(CustomerID, request);

hope this response is useful to you

Hello, i am working with .net to create a card charge but i am only working with .net not browser, (console) so how is possible to generate the device session ID to create a charge, only in console c# .net

Have you read our card charge guide? you can select .Net as Server library for seen server side code examples

You need to understand the flow starts in browser side,
. Get card information in the browser,
. Send card info to Openpay directly using our javascript library, Openpay will generate a token id
. Generate a device session id using the Openpay javascript library
. Send charge information to your server, including token id and device session id, so far every thing happened in browser side
. In your server you have to take charge information and send a charge request using .Net library to Openpay

I hope this helps

Thanks pal, that helped a lot !!!