create token from card
Closed this issue · 17 comments
i have problems to ceate tokens from card, the exception say action cancel
Maybe I can help. Can you share some code or be more specific please?
thanks in firsttime i do the idsession and token to, but i have the same problem
`using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Openpay.Xamarin;
using Openpay.Xamarin.Abstractions;
namespace open
{
public partial class MainPage : ContentPage
{
int cvvi;
string holo;
string MerchantId = "mbjrxiwrzgveqlkeukie";
string ApiKey = "pk_e868bc6d57a2444a937b90e89d4ad2d8";
string hhh;
string tok;
private Token _token;
public MainPage()
{
InitializeComponent();
}
public async void token(object sender, EventArgs e)
{
try
{
string customer_id = "a375avdnmph80qriyzhj";
if (CrossOpenpay.IsSupported)
{
Card card = new Card
{
HolderName = "Francisco Pantera",
Number = "4111111111111111",
ExpirationMonth = "12",
ExpirationYear = "21",
Cvv2 = 132
};
var token = await CrossOpenpay.Current.CreateTokenFromCard(card);
tok = token.Id;
await DisplayAlert("dato", tok,"ok");
}
}
catch (Exception ex)
{
await DisplayAlert("excepción", ex.ToString(), "ok");
}
}
}
}
`
I cannot find any errors on the project. I just tried downloading the entire solution and testing the sample without any problem
Are you initializing the API in your App.xaml.xs file?
protected override void OnStart()
{
base.OnStart();
// Initialize Openpay
if (CrossOpenpay.IsSupported)
{
CrossOpenpay.Current.Initialize(MerchantId, ApiKey, false);
}
}
Please download the entire project and run the sample provided in /samples/OpenpayXamarinSample/OpenpayXamarinSample.sln. I have just tested it and it runs smoothly.
is possible to gnerate chargas and payments?
I inicializa the api and the sessionID works, but token doesn´t
I'll work on Charges/Payments... I'll close this issue since the provided sample works correctly. Please expect a new release for Charges/Payments in the next couple of days.
FYI - Per Openpay specification charges and payment must be generated from your server API. Please review the document named Flujo para realizar pagos con tarjeta located at https://www.openpay.mx/docs/card-charge.html. The diagram clearly states the flow between subsystem.
Your app interacts straight with Openpay for:
- Generating Device Session ID
- Tokenizing a card
Then your app interacts with your server side for:
- Sending purchase information, token and device session id
Finally, your server side interacts with Openpay for:
- Payment/Charge operation
- Validating response
thanks!!!
Glad to help
I made a new project and I have the same problem, but I think it is openpay error
Can you share your project. Maybe I can help.
error: System.Threading.Tasks.TaskCanceledException: A task was canceled.09-03 14:51:20.434 D/Mono (14057): Found as '__android_log_print'.
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00026] in :0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0 09-03 14:51:20.435 I/mono-stdout(14057): error: System.Threading.Tasks.TaskCanceledException: A task was canceled.
at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 at System.Net.Http.HttpClientHandler+<SendAsync>d__64.MoveNext () [0x004f5] in <dcbf7ae3bce147228fa58d5bc31257ae>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0001a] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1+ConfiguredTaskAwaiter[TResult].GetResult () [09-03 14:51:20.443 I/mono-stdout(14057): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00026] in :0
0x00000] in :0
at System.Net.Http.HttpClient+d__49.MoveNext () [0x000ca] in :0
--- End of stack trace from previous location where exception was thrown ---09-03 14:51:20.443 I/mono-stdout(14057): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0001a] in :0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 at Openpay.Xamarin.Abstractions.OpenpayBaseImplementation+<Post>d__11
2[TRequest,TResponse].MoveNext () [0x000ad] in /Users/juanroman/Projects/openpay-xamarin/src/Openpay.Xamarin.Abstractions/OpenpayBaseImplementation.cs:113
--- End of stack trace from previous location where exception was thrown ---09-03 14:51:20.443 I/mono-stdout(14057): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0001a] in :0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 at openXama.MainPage+<tokencard>d__1.MoveNext () [0x000a3] in C:\Users\Vianey\Desktop\openXama\openXama\openXama\MainPage.xaml.cs:35 09-03 14:51:20.444 I/mono-stdout(14057): at System.Runtime.CompilerServices.TaskAwaiter
1[TResult].GetResult () [0x00000] in :0
09-03 14:51:20.444 I/mono-stdout(14057): at System.Net.Http.HttpClientHandler+d__64.MoveNext () [0x004f5] in :0
09-03 14:51:20.444 I/mono-stdout(14057): --- End of stack trace from previous location where exception was thrown ---
09-03 14:51:20.444 I/mono-stdout(14057): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
09-03 14:51:20.444 I/mono-stdout(14057): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0001a] in :0
09-03 14:51:20.445 I/mono-stdout(14057): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
09-03 14:51:20.445 I/mono-stdout(14057): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
09-03 14:51:20.445 I/mono-stdout(14057): at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 09-03 14:51:20.445 I/mono-stdout(14057): at System.Net.Http.HttpClient+<SendAsyncWorker>d__49.MoveNext () [0x000ca] in <dcbf7ae3bce147228fa58d5bc31257ae>:0 09-03 14:51:20.445 I/mono-stdout(14057): --- End of stack trace from previous location where exception was thrown --- 09-03 14:51:20.445 I/mono-stdout(14057): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 09-03 14:51:20.446 I/mono-stdout(14057): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0001a] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 09-03 14:51:20.446 I/mono-stdout(14057): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 09-03 14:51:20.446 I/mono-stdout(14057): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 09-03 14:51:20.446 I/mono-stdout(14057): at System.Runtime.CompilerServices.TaskAwaiter
1[TResult].GetResult () [0x00000] in :0
09-03 14:51:20.446 I/mono-stdout(14057): at Openpay.Xamarin.Abstractions.OpenpayBaseImplementation+d__112[TRequest,TResponse].MoveNext () [0x000ad] in /Users/juanroman/Projects/openpay-xamarin/src/Openpay.Xamarin.Abstractions/OpenpayBaseImplementation.cs:113 09-03 14:51:20.446 I/mono-stdout(14057): --- End of stack trace from previous location where exception was thrown --- 09-03 14:51:20.446 I/mono-stdout(14057): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 09-03 14:51:20.446 I/mono-stdout(14057): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0001a] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 09-03 14:51:20.446 I/mono-stdout(14057): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 09-03 14:51:20.446 I/mono-stdout(14057): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 09-03 14:51:20.446 I/mono-stdout(14057): at System.Runtime.CompilerServices.TaskAwaiter
1[TResult].GetResult () [0x00000] in :0
09-03 14:51:20.447 I/mono-stdout(14057): at openXama.MainPage+d__1.MoveNext () [0x000a3] in C:\Users\Vianey\Desktop\openXama\openXama\openXama\MainPage.xaml.cs:35
this is the full exception
I suggest you check if there is a valid internet connection in your simulator.
it works, openpay tsl disabled, so add tsl in my application.