#Nugax
1 messages · Page 1 of 1 (latest)
oh sorry
didnt see this
trying to write a program to manage credit cards
in stripe accounts
for my program
have this code, Get_Customer_Cards, but it doesnt seem to return a list
the key is fine but it doesnt return the list as it should. maybe something changed in stripe?
Can you try this method instead? https://stripe.com/docs/api/payment_methods/customer_list?lang=php
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I dont know let me try
i changed the code and the last thing printed is the Secret Key from this line:
print("SK: $secretkey");
I dont know why it fails at the Client Setup
I can add new clients to Stripe using the add customer API
or maybe not.
...
that didnt work either. it was adding clients
Okie, do you see your request on Dashboard request log?
in stripe?
Yes
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
If you print $card_list do you see anything?
something is wrong with the client initalization i think
it wont even add a customer anymore. It used to. Its giving a ERROR 500 Internal Server error now
when i try to create a customer in stripe
that sounds like a completely different issue
could be the same issue if its not even creating the client
which is why no API calls are making it to the dashboard
//Create Stripe Customer Account
function Create_Stripe_Customer($customer_name, $customer_email, $customer_phone, $customer_id) {
//Set Customer Stripe Key
$key = $_SESSION["stripe_secret_key"];
//Set The Object For Client
$stripe = new \Stripe\StripeClient($key);
//Set Variables
$date_time = CreateDate();
$customer_description = "Created By KarateMonkey | $date_time | AccountID: $customer_id";
//Create The Customer
$cust_obj = $stripe->customers->create([
'name' => $customer_name,
'description' => $customer_description,
'email' => $customer_email,
'phone' => $customer_phone,
]);
//Set Customer ID That Is Returned From Stripe
$customer_stripe_id = $cust_obj["id"];
//Return Customer Stripe ID (IfSet)
if (isset($customer_stripe_id)) {
return $customer_stripe_id;
}
else {
//Return 0 if no customer ID
return 0;
}
}
That is supposed to create the stripe customer
but it returns an error 500
is it ok to make this call for each page? $stripe = new \Stripe\StripeClient($key);
You sure you have variable on $key? This part
$key = $_SESSION["stripe_secret_key"]
i should but I can output it
//Create Stripe Customer Account
function Create_Stripe_Customer($customer_name, $customer_email, $customer_phone, $customer_id) {
//Set Customer Stripe Key
$key = $_SESSION["stripe_secret_key"];
print("Key: $key");
//Set The Object For Client
$stripe = new \Stripe\StripeClient($key);
//Set Variables
$date_time = CreateDate();
$customer_description = "Created By KarateMonkey | $date_time | AccountID: $customer_id";
//Create The Customer
$cust_obj = $stripe->customers->create([
'name' => $customer_name,
'description' => $customer_description,
'email' => $customer_email,
'phone' => $customer_phone,
]);
//Set Customer ID That Is Returned From Stripe
$customer_stripe_id = $cust_obj["id"];
//Return Customer Stripe ID (IfSet)
if (isset($customer_stripe_id)) {
return $customer_stripe_id;
}
else {
//Return 0 if no customer ID
return 0;
}
}
in stripe dashboard, im not even seening a failed api attempt in the log
under developers
oh wait....
im supposed to have a VENDOR dir
correct?
tahts the issue!
crap
Yep that fixed it
I had re-cloned my git library and forgot to move the vendor dir from home dir back to the apache html hosting dir for it to load stripe library! I knew it was something like that.
its creating customers now
Glad to hear you figured it out!
lets see if we can get the wallet to work
so what I want to do is just be able to add a card
thats it.
well first return list of cards, second add a card!
but i cant get the wallet stuff to work
ok
got the list working
the last issue i have with the wallet
is my add card button doesnt work.
What stripe method would I use if I just created a page to grab card details myself?
You would want to use a SetupIntent
do you have an example code?
i see in the log when I use the $session = \Stripe\Checkout\Session::create([
it tries to start it, but it never displays the page to add the card info
it logs it though
so maybe i just need to collect the card info myself and send it to stripe using a method
I dont understand how to use SetupIntent
Where do I provide card info? number, exp, ccb?
ccv?
You can use a CheckoutSession with setup mode
It will collect the card without doing a charge
and then you will have the card info insde the PaymentMethod, inside the SetupIntet which is collected by the CheckoutSession
thats what I had, but it doesnt prompt anymore
//Set up the payment session
$session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'mode' => 'setup',
'customer' => $stripe_customer_id,
'success_url' => "http://server.karatemonkey.net/core/view_wallet.php?account_id=$account_id_given",
'cancel_url' => "http://server.karatemonkey.net/core/view_wallet.php?account_id=$account_id_given",
]);
and this is the JS i have
<script src="https://js.stripe.com/v3/"></script>
<script>
var stripe = Stripe('<?= $publish_key ?>');
var checkoutButton = document.getElementById('checkout-button');
checkoutButton.addEventListener('click', function() {
stripe.redirectToCheckout({
// Make the id field from the Checkout Session creation API response
// available to this file, so you can provide it as argument here
// instead of the {{CHECKOUT_SESSION_ID}} placeholder.
sessionId: '<?= $session->id ?>'
}).then(function (result) {
// If `redirectToCheckout` fails due to a browser or network
// error, display the localized error message to your customer
// using `result.error.message`.
alert(result.error.message);
});
});
Okie but on which part it "doesn't prompt anymore"? Do you see a Checkout Session cs_xxx created on your backend?
yes
but it used to load a form you could fill in
and it doenst load anything now
so I dont know how to actually collect the informatioon to add it
Not sure which form? I see you have a $session->id and use redirectToCheckout on it
"id": "cs_live_c1bG5xA5gyYzWvthMIDnAeQlyPhUECscs5LLYCTnyNCqx1mYt32Yhjs5Mk",
like that
how do i use redirectToCheckout
oh thats what i did
There are 2 potential issues here
redirectToCheckoutis a legacy method, you should just perfrom redirection serverside- That's a Live mode Checkout Session. You should test everything on Test mode before
Besides, your code should still work
sure it doesnt matter those, ill blow this account up latger on
its for testing anyhow
How do I do server side redirection