bigcommerce / bigcommerce-api-php

Connect PHP applications with the Bigcommerce Platform
https://developer.bigcommerce.com
MIT License
143 stars 186 forks source link

Bigcommerce 401 error on Processing payment with code 10001 #251

Open sardarusama41062 opened 5 years ago

sardarusama41062 commented 5 years ago

Expected behavior

Actual behavior

i'm trying to process payment in bigcommerce by using Payment API. But i'm getting the error of 401. i have followed the doc but unable to solve the issue, i have also provided the Authorization code for cards, but it's not working for me. here is my request to bigcommerce payment APi axios(${store.PAYMENT_API}/, { headers: { 'Accept': 'application/vnd.bc.v1+json', 'Content-Type': 'application/json', 'Authorization':PTA ${accesstoken} }, method: 'POST', data: { "payment": { "instrument": {}, "payment_method_id": "cod", "amount": 81505146, "currency_code": "PKR" } } } ) .then(res => { console.log(res) dispatch({ type: 'SET_PAYMENT_METHODS', }) })

Steps to reproduce behavior

karen-white commented 5 years ago

Hey @sardarusama41062 , looks like you're sending PTA in the authorization instead of PAT. You'll also want to make sure there's a space between PAT and the token itself.

sardarusama41062 commented 5 years ago

Thanks this worked for me, but now it is displaying the error of payment was declined. Here is my data for request { "payment": { "instrument": { "type": "card", "number": "4111111111111111", "cardholder_name": "asd", "expiry_month": 12, "expiry_year": 2020, "verification_value": "123" }, "payment_method_id": "testgateway.card" } } and this is the response { "id": "584999f7-a1e1-4902-9146-837d3d24bbc6", "status": 422, "code": 30102, "title": "The payment was declined.", "type": "https://developer.bigcommerce.com/api#api-status-codes", "errors": {} } Also, how can i process offline methods? for offline methods it is giving this error { "code": 10001, "errors": { "payment.instrument.type": "Type is invalid." }, "id": "831d27ba-55f8-4b37-9add-d76c2c71ed26", "status": 422, "title": "Missing or incorrect required fields.", "type": "https://developer.bigcommerce.com/api#api-status-codes" } I checked in the server logs and found this Transaction ID: , Status: declined, Message: invalid_gateway - gateway is invalid, missing_test_mode - test_mode is required