Create first transaction immediately for Paymill subscription - paymill

So we have implemented the Paymill subscriptions in our app. The problem is that after the user submits his credit card info and we create the subscription on the back-end, the first transaction isn't made immediately. Only after a few minutes, we receive the first subscription.succeeded web-hook denoting the first transaction. It gets the job done, but how can we get the first transaction at the same time as we create the subscription? Through pre-authorization?
The thing is, there isn't much info on the Paymill website, nor in the API docs regarding use cases like this one.

You are right a Webhook does not allow you to get an instant response for your API call.
However, you can get an instant response by creating a transaction:
curl https://api.paymill.com/v2.1/transactions \
-u <YOUR_PRIVATE_KEY>: \
-d "amount=4200" \
-d "currency=EUR" \
-d "payment=<CLIENT_PAYMENT>" \
-d "client=<YOUR_CLIENT>" \
-d "description=Transaction"
The transaction response is instantly given back to your server which allows you to inform your customer without delay.
If the transaction is successful you also want to debit your customer in the future by creating a subscription:
curl https://api.paymill.com/v2.1/subscriptions \
-u <YOUR_PRIVATE_KEY>: \
-d "client=<YOUR_CLIENT>" \
-d "payment=<CLIENT_PAYMENT>" \
-d "amount=4200" \
-d "currency=EUR" \
-d "interval=1 week,monday" \
-d "name=Example Subscription" \
-d "period_of_validity=2 YEAR" \
-d "start_at=<SUBSCRIPTION_STARTING_DATE"
The start_at parameter needs to contain the date when the subscription starts(future):
current_date + subscription_interval(E.g. 1 week)
If this parameter is not set you will charge the credit card of your customer twice on the same date!

Related

Cloudflare API: unknown rate limit for creating for mass zone creation via API

Tried to create 400 new zones on Cloudflare via its API, like this:
curl -X POST "https://api.cloudflare.com/client/v4/zones" \ -H "X-Auth-Email: user#example.com" \ -H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \ -H "Content-Type: application/json" \ --data '{"name":"example.com","account":{"id":"01a7362d577a6c3019a474fd6f485823"},"type":"full"}'
Managed to add 172 successfully, then got an error 1117:
Error screenshot
Does anyone know the maximum number of zone creation requests per hour that can be sent via the API?
Found a message about 11 (?) and 30 - .
In the list of errors in the dock (https://support.cloudflare.com/hc/en-us/articles/360029779472-Troubleshooting-Cloudflare-1XXX-errors) 1117 is simply missing.
Any ideas?

refreshing StubHub API tokens?

We are trying to refresh a previously working application's refresh tokens as per stub-hub's developers docs with the following commands (where <whatever> are account specific placeholders).
ENCRYPTED_ACCT=$(echo -n "<client-id>:<client-secret>" | base64);
curl -X POST "https://account.stubhub.com/oauth2/token" \
-u "${ENCRYPTED_ACCT}" --basic \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=refresh_token" \
-d "refresh_token=<PREV_REFRESH_TOKEN>" \
--data-urlencode "scope=read:events";
In the past we've followed a similar flow (api changed since). But now with the recommended procedure the endpoint is failing due to invalid credentials for the ENCRYPTED_ACCT. Can anyone post a functioning workflow to refresh tokens of an existing account?

Nexmo API change on Text to Speech?

For a very long time I've been using the following to send text-to-speech alerts from my applications.
curl 'https://api-us-1.nexmo.com/tts/json' \
-d api_key=****** \
-d api_secret=****** \
-d to=0035193xxxxxxx \
-d from=0035193xxxxxxx \
--data-urlencode 'text=Alert! Check Something... ' \
-d repeat=2 \
-d voice="male" \
Very recently the service has stopped working for some carriers.
While going over Nexmo docs I can't see the /tts/json API documented.
Anyone knows what happened?
Is the /tts/json API still usable?
The /v1/calls API is absolutelly overkill for my needs.
Unfortunately that API was sunset quite a while ago and replaced with the newer Voice API.
https://developer.nexmo.com/voice/voice-api/code-snippets/make-an-outbound-call-with-ncco would the closest alternative with the Voice API. The biggest change is switching to using a JWT for authentication versus the key/secret auth the older API used.
If you have the Nexmo CLI installed you can generate a JWT as part of a script. The following should work:
#!/bin/bash
#
# Send voice message to a user
#
# ./script.sh <number to call> <vonage number> "<message to speak>"
PATH_TO_PRIVATE_KEY=<path to private key>
VONAGE_APPLICATION_ID=<application ID>
TO_NUMBER=$1
VONAGE_NUMBER=$2
MESSAGE=$3
JWT=$(nexmo jwt:generate $PATH_TO_PRIVATE_KEY application_id=$VONAGE_APPLICATION_ID)
curl -X POST https://api.nexmo.com/v1/calls\
-H "Authorization: Bearer "$JWT\
-H "Content-Type: application/json"\
-d "{\"to\":[{\"type\": \"phone\",\"number\": \"$TO_NUMBER\"}],
\"from\": {\"type\": \"phone\",\"number\": \"$VONAGE_NUMBER\"},
\"ncco\": [
{
\"action\": \"talk\",
\"text\": \"$MESSAGE\"
}
]}"

How to Delete a Service Account in Spinnaker FIAT? API to delete Service account in Spinnaker

Can anyone provide a snippet sample reference on how we could essentially delete a service account? The doc only shows a POST request on how to create but not amend or delete. https://www.spinnaker.io/setup/security/authorization/service-accounts/#service-account-roles
Obtain the name of the service account to be removed
curl $FRONT50/serviceAccounts
Execute following command to Delete
curl $FRONT50/serviceAccounts \
-H "Content-type: application/json" \
-d '{ "name": "service-account-name#spinnaker-domain.net" }' \
-X DELETE

Auth0 does not return user information immediately after creation

Auth0:
Sign up your user
Grep userId from response (I used jq)
Get user information by id immediately >> Returns nothing!
Repeat step 3 in 1 second >> OK
Check out this script
user=$(curl -s -X POST -d 'email=test1#mail.com&password=test1Pass&connection=Username-Password-Authentication' 'https://your-acc.auth0.com/dbconnections/signup')
userId=$(echo $user | jq -r '._id')
curl -X GET -H 'Authorization: Bearer insert-token' "https://your-acc.auth0.com/api/v2/users?q=user_id:\""$userId"\""
sleep 1
curl -X GET -H 'Authorization: Bearer insert-token' "https://your-acc.auth0.com/api/v2/users?q=user_id:\""$userId"\""
I was able to fix it by calling
/api/v2/users/{userId}
which returns single user. Surprisingly it works just fine.
Anyway, it does not solve my problem if I want to request multiple users at a time.
Did not get any response at auth0 forum.