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.

Ben Sullivan
  • 2,134
  • 1
  • 18
  • 32

2 Answers2

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

Community
  • 1
  • 1
Jitendra
  • 842
  • 1
  • 9
  • 25
  • 1
    Can you please explain what this solves and where it goes? thanks – Ben Sullivan Apr 29 '16 at 22:44
  • 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. – Jitendra May 01 '16 at 05:47
  • Do you happen to have a live Stripe server? – Ben Sullivan May 04 '16 at 10:51
  • Yeah, we first tested everything on test mode. then after that we had turned on live mode and everything was working fine – Jitendra May 05 '16 at 07:18
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!

kevinb
  • 1
  • 2