Forbidden (403) error when processing Stripe payments on home server
Asked Answered
U

2

9

I am an iOS developer looking to add Stripe payment to one of my apps. I have created a page on my SSL site which hosts the suggested code from the below link:

https://stripe.com/docs/charges

When I try to process a payment, I receive a 'forbidden (403)' error. Can anyone please advise what I could be doing wrong? All of the code in my Ruby file is as follows:

stripe.api_key = "MySecretKeyGoesHere"

token = request.POST['stripeToken']

try:
  charge = stripe.Charge.create(
    amount=1000, # amount in cents, again
    currency="gbp",
    source=token,
    description="Example charge"
  )
except stripe.error.CardError, e:
 # The card has been declined
 pass

There are examples for this in many major languages, I am happy to use any of them but am currently trying the Ruby and Python versions.

Unwilled answered 24/4, 2016 at 18:50 Comment(4)
May i know if are you using live mode or Test mode for Stripe Payments?Healey
I am working in Live modeUnwilled
How can you import with quotes around the identifier in python? Are you a wizard? ^^Mellette
Go easy on me, it's been 15 years since I've written anything other than Swift!Unwilled
H
0

int amount = 10000; // $100.00 int applicationFee = int(amount * 0.3); // 30% share

Map<String, Object> chargeParams = new HashMap<String, Object>();
chargeParams.put("amount", amount);
chargeParams.put("currency", "usd");
chargeParams.put("description", "Example charge");
chargeParams.put("customer", customerId); // customerId is the ID of the customer object for the paying person    
chargeParams.put("destination", accountId); // accountId is the ID of the account object for the vendor that should be paid
chargeParams.put("application_fee", applicationFee);
Charge.create(chargeParams);
  1. Please also verify if you are using correct Live Secret Key and Live Publishable Key in your server side setup.

  2. Check account logs to verify what is the exact problem you are facing while processing payments at https://dashboard.stripe.com/logs?method=not_get

  3. Verify your Connected Account on Stripe

    Account Details: https://dashboard.stripe.com/account/details
    Identity Verification: https://stripe.com/docs/connect/identity-verification

  4. Documentation Links:-
    [1] https://stripe.com/docs/api#create_charge
    [2] https://stripe.com/docs/api#create_transfer
    [3] https://stripe.com/docs/api#create_refund
    [4] https://stripe.com/docs/api#balance_object
    [5] https://stripe.com/docs/connect/payments-fees#charging-directly
    [6] https://stripe.com/docs/connect/authentication#authentication-via-the-stripe-account-header
    [7] https://stripe.com/docs/connect/payments-fees#charging-through-the-platform

Healey answered 29/4, 2016 at 20:13 Comment(4)
Can you please explain what this solves and where it goes? thanksUnwilled
Pleas check your account balance it have sufficient balance to process the payment process. Try to print the available balance while creating charges. Please also verify that if you are using correct private and public keys in your server side setup.Healey
Do you happen to have a live Stripe server?Unwilled
Yeah, we first tested everything on test mode. then after that we had turned on live mode and everything was working fineHealey
L
0

The issue that I had for my case was slightly different than you, but since it has Stripes documentation I thought I would share my issue.

Here is the python that Stripe has:

@app.route('/create-payment-intent', methods=['POST'])
def create_payment():
    try:
        data = json.loads(request.data)
        # Create a PaymentIntent with the order amount and currency
        intent = stripe.PaymentIntent.create(
            amount=calculate_order_amount(data['items']),
            currency='eur',
            automatic_payment_methods={
                'enabled': True,
            },
        )
        return jsonify({
            'clientSecret': intent['client_secret']
        })
    except Exception as e:
        return jsonify(error=str(e)), 403

In their except, they pass a 403 error and I hadn't realized that. So for me, I just removed that exception and passed the 500 error until I understand this system a bit better!

Lachrymose answered 29/6, 2022 at 4:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.