3 posts / 0 new
Last post
gustavocroquer3175
AngularJS

I try in several ways to send data to api but always have error 403 no matter use my own credentials or example credentials, this is my code
"
controller("otroController",function($scope,$resource){
$scope.postResource = function(){
var nonce = Math.random() * 1000000000000000000;
var timeInMillis = new Date().getTime();
var payStatus = $resource('https://api.payeezy.com/v1/transactions',{},
{post: {method: 'POST',
headers: {
'Content-Type' :'application/json',
'Accept': 'application/json',
'apikey' :'y6pWAJNyJyjGv66IsVuWnklkKUPFbb0a',
'token' :'fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6',
'nonce': nonce,
'timestamp':timeInMillis, 'Authorization':'ZGZhZjRiZGM2NzZlNDY2YThmMWFkMTZjMDcyOGEzMDM5MzVlZWZjMTUyYzA2OTZhMjc4YTQ4YTVjNmY5NzMyNQ=='
}}
}
);

payStatus.post(function() {
({merchant_ref: 'Astonishing-Sale',
transaction_type: 'authorize',
method: 'credit_card',
amount: '1299',
currency_code: 'USD',
credit_card: {
type: 'visa',
cardholder_name: 'John Smith',
card_number: '4788250000028291',
exp_date: '1020',
cvv: '123'
}});
});
}
})
"
Api response
XMLHttpRequest cannot load https://api.payeezy.com/v1/transactions. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://btmembers.us' is therefore not allowed access. The response had HTTP status code 403.

If you have a better idea let me know please

Regards
Gustavo


pramodrao2872
Re: AngularJS

Please see the header values captured from chrome developer tools listed below as a sample. From developer portal, click Docs and Sandbox and refer to Credit Card Payments Transaction. Review all the header parameters.  I have shown below list of header parameters that I passed. The API Key and Secret token values are values that I have generated by creating a SANDBOX APP. You can create your own APP under MY APIs menu for sandbox (test) region. This APP provides you with API Key, API Secret and token. API Secret will be used to generate the HMAC header parameter which is the Authorization header parameter value. Refer to HMAC generation logic which is provided in every api transaction. Click on "i" for more information which provides the HMAC generation logic. Using this alogorithm, generate HMAC in Angular JS by passing API KEY, consumer secret and merchant token.  The token used below for header parameter is the merchant token. In Sandbox (test) region, we provide you with a test merchant called Sandbox merchant. You can view this merchant by clicking My Merchants. The token used for every transaction is this merchant token. 

 

SAMPLE HEADER Parameter Values

POST /smartdocs/v1/sendrequest?targeturl=https%3A%2F%2Fapi-cert.payeezy.com%2Fv1%2Ftransactions HTTP/1.1
Host: apiconsole-prod.apigee.net
Connection: keep-alive
Content-Length: 309
Origin: https://developer.payeezy.com
nonce: 5778342437231913000
Authorization: OTRmMWZiMDFlMjVhMTUwMmRjODAyNmQ0YzI0MTJlOTE1M2UzZTVkM2EyZjQ1MzQyMDc0MjY3NGVlZWU3MzFjZg==
Content-Type: application/json
Accept: */*
timestamp: 1428327349720
apikey: HQH1IJAauc6lm0e07Xu7jvCWkhVb67vR
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36
token: fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6
Referer: https://developer.payeezy.com/payeezy-api-reference/apis/credit-card-payments
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8

 


alandavies3254
Re: AngularJS

If you don't get everything right - it don't work! In your case, at least the timestamp is incorrect - it should be seconds, not milliseconds - so divide by 1000 and see if that works.