Stripe Integration Part 3 - retrieving a customer object

Following on from Part 2.

I have made a modification to the table listing customers featured in Part 2 and made the ID field a link as below
showcustomer.php?cus=cus_EirxWeBc14NKy6


Where the string is the customer id

We will pass this to the API and retrieve a specific customer object

Again a simple API call will do the work

The customer id is passed as a GET variable as $_GET.cus

image

The API settings are pretty much identical to before, requiring a authorization in the header

On this occasion we post to a slightly different url as the customer if must be passed in the url

The url we will use is :https://api.stripe.com/v1/customers/{{$_GET.cus}} as the id must be passed in the url. See below curl example.

image

**NOTE: you may have an issue generating the schema for the API as $_GET.cus is undefined and an error will occur. To generate a schema paste a url with a valid customer id in it as shown in the above curl example into the Url field

image .

It should then be possible to generate the schema**

We can then use this server action to retrieve a specific customer object

showcustomer.php is a simple page to display the id, name and email address returned by the API call via a server connection

image

The page simply makes the call and the customer object is returned to app connect where the sdata objects are available in the picker.

Example:

image

Selecting the second in the list returns:details for that id

image

Of course you could retrieve the customer record via the database table. This would be useful when needing access to the records from a customer login
The user could login via the database table email and password and then the customer id returned form a data query.
This could them be passed as the parameter to the showcustomer.php type page

Part 4 following starts the payment process

4 Likes

Thank you for posting this step for stripe connection. I have read everything I can find on this step and it appears that I am missing something. I acknowledge that I am rather new at this but I have gotten this far. I know the process is probably simple but I seem to be missing something. I was able to get past the step of making the id field into a link (once I realized the difference of using the Bootstrap4 generator) but that is where things seem to stop.

I’m not sure what the next step is? Do I replace the SA that we created in step 2? or do I attach it to a new page. Also what does the showcustomer.php page look like?

Sorry for the confusion but I could use some help.

thank you

Sorry,on holiday and not near a computer. Cant check out what you mean until I get home

no worries, enjoy your holiday, it will wait.

thank you for letting me know

@Hyperbytes, hope you had a nice holiday.

I am still having problems with step three of the stripe tutorial retrieving customer data. I am able to get the Master page part setup but on the detail page the only thing that is showing up is the Stripe ID cus_GNxXcnFylO9ohd which is passed as a variable. The other fields are blank. I followed the DMX master detail video and don’t see where I am making the error. What would you like to see other than these screen shots:

As the api query is working correctly on the master page then I have to suspect that the API query is not set up correctly in the detail page

I see you are passing the customer ID as a parameter “cus”, how are you binding that the the API call on the detail page?

I used the bootstrap4 method and it setup an inner text with value: stripeDetailPage.data.api1.data.address for the address field and then for each field with the appropriate serverconnect1.data.api1.data.(fieldname)

@Hyperbytes, if your back from vacation I am still having issues trying to get this master detail example for retrieving customer information. I am able to get the Master Detail relationship to work using database queries but not when I try to use the API data. Would it be possible to get a more step by step process as I am not sure what I am missing?

If you are unable, where could I get some additional information?

thank you

I will try when i get some time but very busy with business at present

I understand, should I create a post to the larger community? I have been asked to figure this out for my department to use in one of our university classes. I am running short of time as well and really need to figure this out.

I am a newbie with Wappler but used Dreamweaver in the past. I am having some issues with the transition as the older tutorials for the DMX plugins are ok but some of the steps have different names and there may be some issues with language as well. I find that the DMX tutorials are pretty good but I am having issues with the Stripe API pages.

Please advise if I should create a post the the larger community and if you have some suggestions as to where additional resources or help could be found.

Thank you

It seems you have not got exactly the same stuff as Brian does.

Here is my suspect area


In the URL Brian states you need to remove the {{$_GET.cus}} and replace it with a real ID before you click the Fetch Schema button. Then press Save.
It will now take you back to your Server Connect API Properties where if you look at the URL that one should still be the correct one with the $_GET inside it.

Please try that and rebind your data, the reason i think you need to rebind your data is because if you look at Brians available data binding vs your schema they do not seem to 100% tie up.


The Pink side is Brians available Bindings vs your schema on the right, you have balance, he has account_balance, maybe I am wrong, but this is what i see just at a glance.

OK, so you can retrieve the customer list as per my instructions and display them in a table like this

I assume you then click on the link to go to the detail page passing the customer id as a paramater “cus”

Now what should be done is:

a second server action is required to retreive the specified customer records via a new api call passing the customer id ($_GET.cus) as a parameter as specified in the API documentation
(Don’t forget to declare the Query Parameters in the app settings)

https://stripe.com/docs/api/customers/retrieve

Not in position to check but i think that means you have to make the API URL call will be

https://api.stripe.com/v1/customers/{{$_GET.cus}}

If i got that syntax wrong I am sure someone can correct me

That should return the individual records from the API

(sorry, bit rusty on Stripe, not looked at it since those tutorials)

In the URL Brian states you need to remove the {{$_GET.cus}} and replace it with a real ID before you click the Fetch Schema button. Then press Save.

You can see that from my image I had pasted in an actual customer id and used it to build my scheme. As for the second part of your answer I do not know if it makes a difference between account balance or just balance but I suspect it could be because I am using my test data and it may depend on how I created the account.

I created two server actions,

  1. apiMaster which is called from the Master page and
  2. the second apiDetail which is called by the showcustomer.php detail page. Is that correct?

I checked to see that the url to the API had the second }, which it did not but fixing it did not change anything.

What does the link to the detail page look like on the page source?

Thank you , I was able to figure it out with your help. There were a couple of issues, 1) using Bootstrap 4 to populate my tables made it difficult and I was using the incorrect final part of this static/dynamic link function: showcustomer.php?cus={{id}}

I appreciate your help

1 Like