We are trying to integrate Google Wallet for digital goods with or php app and 2 days ago, on 15 November we've managed to get it working. However, when checking again the next day and even today, although the code remained the same, we didn't change a letter in it, it is still not working, giving us this error:
Uh oh. There was a problem.
We couldn't complete your purchase because of a technical issue.
Details of the problem below: Unfortunately, we could not confirm your purchase with the merchant's server. Your order has been canceled. Please contact the merchant if this problem continues.
The code we're using is this:
$response = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : file_get_contents("php://input");
$response = substr_replace($response, "", 0, 4); //remove "
$response = JWT::decode($response, $sellerSecretKey);
header("HTTP/1.1 200 OK");
and like I said it worked fine two days ago and I have the feeling it's working now also, because in our log file we get printed this response
stdClass Object
(
[iss] => Google
[request] => stdClass Object
(
[name] => Product 1.
[description] => You are purchasing a total of 1 products from our Store. Thank you.
[price] => 9.99
[currencyCode] => USD
[sellerData] => client name,email address
)
[response] => stdClass Object
(
[orderId] => GWDG_S.c7a66f5b-4674-43f0-be16-2b72f69a7445
)
[typ] => google/payments/inapp/item/v1/postback/buy
[aud] => 03083876603093172875
[iat] => 1384689627
[exp] => 1384689647
)
The postback url is correctly specified and we are using sandbox to do the tests.
Is this a problem from Google? Are they working on the software or something and this is what's causing the problem? Or are we doing something wrong here?.
Any help would be much apreciated. Thank you.
Meant to comment but it won't fit...
That error points to something in your Postback handler. I just tried sandbox and things seem fine.
I'm not a php dev so this maybe inaccurate - are you responding to Postback with the orderId? Again, this is only based on my read of the code above (I think I only see http 200?)
The only other thing I can think of is that the lag for you to respond is more than 10 seconds(?) - which could explain why could be another reason you have logged data, but Google still cancelled it.
*Strike through text: you'd get data to log because Google will send you the data, it's whether or not you respond properly that matters
Once you decode the JWT with your Seller Secret, you can make sure that the cake purchase is OK and record it. Within 10 seconds of receiving the postback, your server must send a 200 OK response where the only content is the value of the "orderId" field. If it doesn't, Google cancels the transaction.
REF: https://developers.google.com/commerce/wallet/digital/docs/postback#responding
Hth.
Related
I had Discord Oauth2 implemented so that my users could log into my website by authenticating through Discord. For months, everything worked great and now all of the sudden it stopped working.
Per Discord's oauth2 instructions,https://discordapp.com/developers/docs/topics/oauth2#shared-resources, I am able to successfully acquire the access code that is meant to be traded for the access token. However, when I try to receive the access token I receive an 'invalid_client' error.
First, I am hitting this endpoint:
https://discordapp.com/api/oauth2/authorize?client_id=${process.env.CLIENT_ID}&redirect_uri=http%3A%2F%2Flocalhost%3A5000%2Flogin%2Fdiscord%2Fcallback&response_type=code&scope=identify%20email%20gdm.join
which successfully returns the following:
http://localhost:5000/login/discord/callback?code={some_access_code}
The access code is then sent back to discord to obtain the access token. Here is the code that is failing:
export function getDiscordAccessToken(accessCode, call) {
const redirect = call === 'login' ? process.env.DISCORD_LOGIN_REDIRECT : process.env.DISCORD_CONNECT_REDIRECT
return new Promise((resolve, reject) => {
axios
.post(
`https://discordapp.com/api/oauth2/token?client_id=${process.env.DISCORD_CLIENTID}&client_secret=${process.env.DISCORD_SECRET}&grant_type=authorization_code&code=${accessCode}&redirect_uri=${redirect}&scope=identify%20email%20gdm.join`
)
.then(res => {
resolve(res.data)
})
.catch(err => {
// log error to db
console.log("Here is your error: ", err.response)
reject(err.response)
})
})
}
This code was working for months with no problems. Then, all of the sudden it stopped working. I even checked the Discord change logs which can be found here, https://discordapp.com/developers/docs/change-log, but I found no reference to authentication changes.
Any help you can provide is greatly appreciated!
The query parameters should be in the BODY of the POST request, not the URL for the oauth/token url.
Discord recently pushed a update to the oAuth2 which makes it confine more with the standard. This means they no longer support parameters in the URL for POST, but instead require them to be in the body and form encoded (basically the same, but in the body and without the leading ?).
So you basically need (not tested):
axios.post(
`https://discordapp.com/api/oauth2/token`,
`client_id=${process.env.DISCORD_CLIENTID}&client_secret=${process.env.DISCORD_SECRET}&grant_type=client_credentials&code=${accessCode}&redirect_uri=${redirect}&scope=identify%20email%20gdm.join`
)
I know the question has already been answered, but in my case I copied a wrong secret key. Just make sure that you copy the right one.
Secret Key is located under OAuth2 Tab and not under General Information tab on discord developer's dashboard.
Feb 8, 2018
My Ruby on Rails application has been successfully using ActiveMerchant::Billing::AuthorizeNetCimGateway with the payment type :credit_card for creating a customer profile with an embedded payment profile.
I'm now in the process of migrating to Authorize.Net's Accept.js which accepts credit card info directly sent from their hosted payment form and returns a payment nounce of type COMMON.ACCEPT.INAPP.PAYMENT that can be used for one time to create a payment transaction, customer profile, etc.
I constructed a payment_profile hash with :opaque_data in place of :credit_card. For example:
> payment_profile
=> {:payment=>
{:opaque_data=>
{:data_descriptor=>"COMMON.ACCEPT.INAPP.PAYMENT",
:data_value=> "eyJjb2RlIjoiNTBfMl8wNjAwMDUzNjBDMzAwOUQ3OEUzOUQ1MDk4QTYxMjFGNzlCQ0Y3RDRGQUE4NTNCMEU3MkYyMUJBNTI3NUE0NjQ2Q0ZFQTVFNzMxMDI2Qjg5ODJGNjBFRUE2RDZFMTZCMUY5NzQ4NUJFIiwidG9rZW4iOiI5NTE4MDc3Njg5NDA4MTAwOTAzNTAyIiwidiI6IjEuMSJ9"}},
:bill_to=>{:first_name=>"Firstname", :last_name=>"Lastname", :address=>nil, :city=>nil, :state=>nil, :zip=>nil, :country=>nil, :phone_number=>"(012) 234-5678"}}
I then tried to create a customer profile with an existing code similar to the following:
response = #gateway.create_customer_profile profile: {
email: client.email,
description: client.name,
merchant_customer_id: client.id,
payment_profiles: payment_profile
}
However, I received a response which had a result_code of Error and complained about "incomplete content" for element payment as follows:
> response
=> #<ActiveMerchant::Billing::Response:0x007f9827d14900
#authorization=nil,
#avs_result={"code"=>nil, "message"=>nil, "street_match"=>nil, "postal_match"=>nil},
#cvv_result={"code"=>nil, "message"=>nil},
#emv_authorization=nil,
#error_code="E00003",
#fraud_review=nil,
#message=
"The element 'payment' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has incomplete content. List of possible elements expected: 'creditCard, bankAccount, trackData, encryptedTrackData, payPal, opaqueData, emv' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.",
#params=
{"messages"=>
{"result_code"=>"Error",
"message"=>
{"code"=>"E00003",
"text"=>
"The element 'payment' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has incomplete content. List of possible elements expected: 'creditCard, bankAccount, trackData, encryptedTrackData, payPal, opaqueData, emv' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'."}}},
#success=false,
#test=true>
I have a few questions in my mind:
Does ActiveMerchant::Billing::AuthorizeNetCimGateway even support Accept.js' :opaque_data in place of :credit_card?
If ActiveMerchant::Billing::AuthorizeNetCimGateway does support :opaque_data, what's may be wrong with the above payment_profile and what other content that I'd need to provide for payment element?
I'd appreciate any help in resolving this issue.
While this question is over 4 years old, and I'm assuming you have either found a solution or abandoned your effort, I ran into this same issue recently, and thought it would be helpful to add my findings in case someone else runs into this.
the AuthorizeNetCimGateway does not currently support Accept.js' opaqueData. In looking at the sourcecode for the active_merchant gem, specifically in /lib/active_merchant/billing/gateways/authorize_net_cim.rb, there is ultimately a method add_payment_profile that gets called. In that method, specifically on lines 759-761, you can see that the options are either a credit_card, bank_account, or drivers_license. A tokenized payment is not currently supported.
That being said, there is an open PR#2422 that adds support for this. At the time of writing this, it appears to be failing some rubocop specs, but hopefully it can get deployed in the near future!
I put this into my terminal
uri = URI('https://api.madmimi.com/mailer/to_list')
res = Net::HTTP.post_form(uri,'username'=>'test#example.com',
'api_key' => 'xxxxxx2ce1ac9eb91c75f5933283eb6c ', 'promotion_name' =>
'bulletin', 'subject' => 'Your Daily Bulletin Update', 'from' =>
'noreply#matsu-namibiaflood.opensciencedatacloud.org/', 'list_name' => 'bulletin')
The result was
#<Net::HTTPBadRequest 400 Bad Request readbody=true>
On the Mad Mimi API they talk about putting in your user name and API key https://madmimi.com/developer/mailer/methods
What am I doing wrong? Should I put the username and API key elsewhere?
James here from Mad Mimi, would you mind popping an email to us and I can have a look at your account and check the settings, list names and the promotion.
I would say remove the / at the end of the your "from" email and just check there are no spaces in your API key.
If that doesn't work, I would need to check the promotion but make sure there are no {placeholder} in your bull
Thank you,
James
I have facebook social comments box. How can I post comment through graph API to it?
I can give you half the answer to this question, but still need the other half very much myself. You can post a reply to an existing comment within Social Comments box by finding its post_fbid. To get this you can use FQL such as:
https://api.facebook.com/method/fql.query?query=SELECT post_fbid, id FROM comment WHERE object_id IN (SELECT comments_fbid FROM link_stat WHERE url ='[ PAGE_URL ]')&access_token=[ ACCESS_TOKEN ]
This query will need to be run through an escape() with the PAGE_URL and then used for an HTTP GET request:
https://api.facebook.com/method/fql.query?query=SELECT%20post_fbid%2C%20id%20%0A%20%20%20%20%20%20%20%20FROM%20comment%20%0A%20%20%20%20%20%20%20%20WHERE%20object_id%20IN%20%0A%20%20%20%20%20%20%20%20%20%20(SELECT%20comments_fbid%20%0A%20%20%20%20%20%20%20%20%20%20%20FROM%20link_stat%20%0A%20%20%20%20%20%20%20%20%20%20%20WHERE%20url%20%3D'http%3A%2F%2Fexample.com')&access_token=[ ACCESS_TOKEN ]
With the post_fbid you can make a reply by doing an HTTP POST to:
https://graph.facebook.com/[ POST_FBID ]/comments/?access_token=[ ACCESS_TOKEN ]&message=[ MESSAGE]
Now for posting a new comment to the page this used to work until recently with an HTTP POST:
http://graph.facebook.com/comments/?ids=[ PAGE_URL ]&access_token=[ ACCESS_TOKEN ]&message=[ MESSAGE]
But currently this is consistently returning:
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException"
}
}
I hope this helps a bit and if anyone can shed some light if posting a new comment like this is even possible anymore it would be greatly appreciated.
Seems that it is not possible, and will never be:
This functionality was never and is not intended to be available.
An error message has been added for this case: "Comments may not be
added to a comment plugin"
https://developers.facebook.com/bugs/164794086987157
Its very easy as you post on user feed after getting access_token with publish stream token
I assume you use PHP SDK if you need in other let me known
You just need Step 4 but i give you more details in Step 1 to 3 so you can understand and do clearly
Step 1
get the user access token
$token = $facebook->getAccessToken();
echo "</br>" . 'Access_Token:' . $token;
Step 2
set default access token and profile
$facebook->setAccessToken($token);
Step 3
compile the post
$WallPost = array(
'message' => 'hey this app is cool!!',
'link' => $canvas_page,
'caption' => 'caption',
'description' => 'Test Description',
); // you can also use 'picture', 'description', 'source'....
Step 4
post to wall or your Social Comment Plugin
$response = $facebook->api('/me' . '/feed','POST',$WallPost);
Thanks
I'm having trouble getting Twitter's rate_limit_status https://dev.twitter.com/docs/api/1/get/account/rate_limit_status to work correctly. I've used to curl and a web browser https://api.twitter.com/1/account/rate_limit_status.json to test it and it does returns a JSON object, but when I run the code below all I get is a 200 so I know I got the response successfully. It's not rated limited so even if I was over my limit it would still work. I've googled it and searched this forum but I can't seem to find why my specific code isn't working. As you can see I've put an alerts in the .getJSON function but neither goes off. I'm using the other Twitter APIs get Friends, get Followers successfully using basically the same code as below. I'm new to JQuery so I'm wondering if I'm missing something. Thanks in advance for any help!
function getRateLimit (){
var uri = "https://api.twitter.com/1/account/rate_limit_status.json";
$.getJSON(uri, function(data) {
alert("Alert before.");
console.log(data["reset_time"]);
console.log(data["remaining_hits"]);
alert("For testing purposes.");
});
}
The Same origin policy prevents that from working. Even if it would work, it would show the rate limit for each user and not for your application. (the rate limit status for the requester's IP address is returned)
You have to to get this data on server-side, everything else makes no sense.