Closed neo1992 closed 2 years ago
Anyone?
Hi @neo1992 ,
The customer id can be retrieved from the CustomerResponse
class after making the request. For example:
string name = "Smit";
string email = "johnsmit@mollie.com";
CustomerClient customerClient = new CustomerClient(this.ApiKey);
CustomerRequest customerRequest = new CustomerRequest() {
Email = email,
Name = name,
Locale = Locale.nl_NL
};
CustomerResponse result = await customerClient.CreateCustomerAsync(customerRequest);
string customerId = result.Id;
The SequenceType
property is part of the PaymentRequest
class, since the customer needs to give consent through a first payment. This is explained further in the Mollie documentation on recurring payments, which you can find here: https://docs.mollie.com/payments/recurring
Kind regards, Vincent
Hi Vincent,
Thank you for you reply :)
Item 1: I thought your example is exactly what I'm trying to do with this code? I however get a design time error "Expression does not produce a value".
Protected Async Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim customerResponse As Models.Customer.CustomerResponse = Await CreateNewCustomer("test@test.com", "John Doe", Models.Payment.Locale.en_US) 'getting design time error "Expression does not produce a value"
'STEP 2: I need customerResponse.Id here for the next function, how do I get it from the previous call?
StartPayment(customerResponse.Id, 150)
End Sub
Item 2:
Ok, so SequenceType
is part of the paymentrequest
class, and in my example I wanted it to make that part of SubscriptionRequest
. Does it mean I need to do 2 calls somehow, one using paymentrequest for 1 first payment and a second one subscriptionrequest for ongoing payments? My reasoning was that the first payment would be equal to the monthly subscription so I could just call SubscriptionRequest to both initiate the initial as well as subsequent payments?
Hi @neo1992
Regarding issue 1: I am no VB.NET expert, but shouldn't the method CreateNewCustomer
return the customerResponse
object? Right now it isn't returning anything and I think that is causing the issue. For example:
Protected Async Function CreateNewCustomer(ByVal emailAddress As String, ByVal fullName As String, ByVal locale As String) As Threading.Tasks.Task
Dim customerRequest As Models.Customer.CustomerRequest = New Models.Customer.CustomerRequest() With {
.Email = emailAddress,
.Name = fullName,
.Locale = locale'Models.Payment.Locale.en_US
}
Dim customerClient As Client.Abstract.ICustomerClient = New Mollie.Api.Client.CustomerClient(ConfigurationManager.AppSettings("mollie_api_testkey"))
Dim customerResponse As Models.Customer.CustomerResponse = Await customerClient.CreateCustomerAsync(customerRequest)
Return customerResponse
End Function
Regarding issue 2: The customer first needs to do a payment with the customerId
and sequenceType
properties set. sequenceType
should be set to first
. After that, you'll have a mandate which you can use to setup recurring payments.
Thanks. Here's a working code sample for other people that may be interested:
Protected Async Function CreateNewCustomer(ByVal emailAddress As String, ByVal fullName As String, ByVal locale As String) As Threading.Tasks.Task(Of Models.Customer.CustomerResponse) 'Threading.Tasks.Task
Dim customerRequest As Models.Customer.CustomerRequest = New Models.Customer.CustomerRequest() With {
.Email = emailAddress,
.Name = fullName,
.Locale = locale'Models.Payment.Locale.nl_NL
}
Dim customerClient As Client.Abstract.ICustomerClient = New Mollie.Api.Client.CustomerClient(ConfigurationManager.AppSettings("mollie_api_livekey"))
Dim customerResponse As Models.Customer.CustomerResponse = Await customerClient.CreateCustomerAsync(customerRequest)
Return customerResponse
End Function
I want to create a new customer and then start a first payment of a unlimited series of recurring payments (until customer cancels).
I have this so far:
However, I don't know how to get the response of the customer creation request (STEP 2) so I can use the new customer id in the
StartPayment
method.On a separate note, in Mollie's documentation there's mention of a
Sequencetype
property that needs to be set for "first", however this is not a property ofSubscriptionRequest
(see STEP 1) https://docs.mollie.com/payments/recurring#payments-recurring-first-payment