My postback php for google wallet in-app payments looks like this:
<?php
$payload = array(
"iss" => $sellerIdentifier,
"aud" => "Google",
"typ" => "google/payments/inapp/item/v1",
"exp" => time() + 3600,
"iat" => time(),
"request" => array (
"name" => "pizza ",
"description" => "yum yum",
"price" => "10.50",
"currencyCode" => "USD",
"sellerData" => "",
)
);
$testToken = JWT::encode($payload, $sellerSecret);
?>
I have two questions:
1.
why do I see 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.
2.
How can this work if I have multiple items for sale? the example php above lets you buy a 'pizza for $10.50' how can I add another item like a 'hotdog for $2.99'?
ps: I have studied the following documentation:
https://developers.google.com/in-app-payments/docs/tutorial#4
https://developers.google.com/in-app-payments/docs/jsreference#jwt
https://developers.google.com/in-app-payments/docs/postback
Thank you for your time.
//update!
postback.php:
require_once 'JWT.php';
JWT.php:
$json = json_encode($input, JSON_UNESCAPED_SLASHES);
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.
You're supposed to decode the raw encoded jwt data sent to your postback.php.
In bare minimum your postback.php should look something like below (assuming your postback.php is hosted on apache server). Hope this helps
<?php
require_once(dirname(__FILE__) . "JWT.php");
$response = isset($HTTP_RAW_POST_DATA) ?
$HTTP_RAW_POST_DATA : file_get_contents("php://input");
$response = substr_replace($response, "", 0, 4); //remove "jwt=" from raw http data
$response = JWT::decode($response, "your secret key here");
print_r($response->response);
?>
is your postback.php accessible without a .htaccess password and username? I had that for a while - drove me nuts... until i figured realized that my postback.php was password protected -.-
to make a hotdog additionally do this:
<?php
$cake_payload = array(
"iss" => $sellerIdentifier,
"aud" => "Google",
"typ" => "google/payments/inapp/item/v1",
"exp" => time() + 3600,
"iat" => time(),
"request" => array (
"name" => "cake",
"description" => "yum yum",
"price" => "10.50",
"currencyCode" => "USD",
"sellerData" => "",
)
);
$hotdog_payload = array(
"iss" => $sellerIdentifier,
"aud" => "Google",
"typ" => "google/payments/inapp/item/v1",
"exp" => time() + 3600,
"iat" => time(),
"request" => array (
"name" => "hotdog",
"description" => "yum yum",
"price" => "5.99",
"currencyCode" => "USD",
"sellerData" => "",
)
);
$cake_token = JWT::encode($cake_payload, $sellerSecret);
$hotdog_token = JWT::encode($hotdog_payload, $sellerSecret);
?>
pass both to a separate purchase() function in javascript (so purchase_hotdog() and purchase_cake()
Your example worked perfectly #Pawan. Thanks. The only change I needed was on the path to JWT.php.
I now use
require_once(dirname(FILE) . "/lib/JWT.php");
Paul
Related
I am using PHP to get oauth token for FCM however the access token returned contains a lot of '....'
$client= new \Google_Client();
error_log(__DIR__);
$client->setAuthConfig(__DIR__ . '/service-account-key.json');
$client->addScope('https://www.googleapis.com/auth/firebase.messaging');
$client->refreshTokenWithAssertion();
$token = $client->getAccessToken();
error_log(json_encode($token));
return $token;
Result
The actual access token doesnt contain the asterisk(*), it used to be characters that i have replaced with asterisks to censor out the token.
{"access_token":"ya29.*.b*************r1FYWFz***CCg3v8VYHTlu*******************hiMIDhSX******6UfwvazfOcuV***********ewuo-c87WgM-ir
S5unipu0goCl3RtC_0g7hkjqNwQ2pcZjmJCZIr7JM5VwD4........................................................................................................................................................................................
......................................................................................................................................................................................................................................
......................................................................................................................................................................................................................................
....................................................................................................................................................","expires_in":3599,"token_type":"Bearer","created":1652776589}
Can someone please tell me why it is returning a bunch of '.'
Despite the access token being returned is filled periods(...), there is no issue using that access token to send a FCM notification. The issue that prevent me from sending a notification out is due to not following the correct payload format to send out the data.
Ideal payload format
$data = array(
"message" => array(
"token" => $user->device_token,
"notification" => array(
"title" => "New Task",
"body" => "Hi " . $user->name . ",\nYou have a new " . $ticket_description ." task to work on.",
),
"data" => array(
"notification_id" => $notificationMessage->id,
"item_id" => $notificationMessage->item_id,
"ticket_classification" => $notificationMessage->classification,
"ticket_segment_type" => $notificationMessage->segment_type,
"routing_page"=>$notificationMessage->page_routing_classification,
"title" => $notificationMessage->title ,
"body" => $notificationMessage->body ,
),
"android" => array(
"priority" => "high",
"notification" => array(
"sound" => 'default',
//So that noptification can be sent while the app is killed
"click_action" => "FCM_PLUGIN_ACTIVITY",
)
)
)
);
I would like to store credit card information for a customer in our QuickBooks account
using the PHP Payments SDK - the following is what I am trying to achieve this but I get an invalid arguments error:
$client = new PaymentClient([
'access_token' => $accessTokenValue,
'environment' => "sandbox" ]);
$array = [
"number" => "4408041234567893",
"expMonth" => "12",
"expYear" => "2026",
"name" => "Test User",
"address" => [
"streetAddress" => "1245 Hana Rd",
"city" => "Richmond",
"region" => "VA",
"country" => "US",
"postalCode" => "44112"
],
"customerid" => "94"
];
$create = CardOperations::createCard($array);
$response = $client->charge($create);
I have not had any luck reaching out to support, any way this can be done, I appreciate the help.
Error received:
Uncaught TypeError: Argument 1 passed to
QuickBooksOnline\Payments\Operations\CardOperations::createCard() must
be an instance of QuickBooksOnline\Payments\Modules\Card, array given
UPDATE using recommended code:
Uncaught ArgumentCountError: Too few arguments to function
QuickBooksOnline\Payments\Operations\CardOperations::createCard(), 1
passed
As per your error it seems the required Card data should be an instance of the class
QuickBooksOnline\Payments\Modules\Card
But you're passing array to it. As per the documentation could you please check this below code , hopefully it will work.
$client = new PaymentClient([
'access_token' => $accessTokenValue,
'environment' => "sandbox"
]);
$cardData = [
"number" => "4408041234567893",
"expMonth" => "12",
"expYear" => "2026",
"name" => "Test User",
"address" => [
"streetAddress" => "1245 Hana Rd",
"city" => "Richmond",
"region" => "VA",
"country" => "US",
"postalCode" => "44112"
],
"customerid" => "94"
];
$chargeData = [
"amount" => "10.55",
"currency" => "USD",
"card" => $cardData,
"context" => [
"mobile" => "false",
"isEcommerce" => "true"
]
];
$customerId = "94";
$charge = ChargeOperations::buildFrom($chargeData);
$chargeResponse = $client->charge($charge);
$clientId = rand();
$card = CardOperations::buildFrom($cardData);
$createCardresponse = $client->createCard($card, $clientId, rand() . "abd");
//or alternatively $createCardresponse = $client->createCard($card, $customerId, rand() . "abd");
When using the new gocardless api examples I can list customers so I'm assuming that I have composer installed correctly but when I try the example for creating a subscription (as listed below) I get http error 500 does anybody know what I may be doing wrong?
<?php
require 'vendor/autoload.php';
$client = new \GoCardlessPro\Client(array(
'access_token' => 'my_sandbox_access_token_goes_here',
'environment' => \GoCardlessPro\Environment::SANDBOX
));
$client->subscriptions()->create([
"params" => ["amount" => 25,
"currency" => "GBP",
"name" => "Monthly test",
"interval_unit" => "monthly",
"day_of_month" => 1,
"metadata" => ["order_no" => "test1"],
"links" => ["mandate" => "MA125"]]
]);
?>
Thanks
i followed a tutorial on youtube on using parallel payments with php.
the problem is I keep getting an invalid requset error
this is an excerpt of my code:
$createtePacket = array(
"actionType" => "PAY",
"currencyCode" => "USD",
"receiverList" => array(
"receiver" => array(
array("amount"=>"1.00" ,"email" => "mail#mail.com"),
array("amount"=>"50.00" ,"email" => "mail2#mail.com"),
)
),
"returnUrl"=>"http://local.dev/store",
"cancelUrl"=>"http://local.dev/store" ,
"requestEnvelope" => array("errorLanguage"=>"en_US","detailLevel"=>"ReturnAll")
);
and the error part of the result is :
message":"Invalid request: {0}
any ideas what i'm doing wrong here?
This is my first post in this forum.
I'm trying to develop all the payments to Adyen using the WS, instead of the skin/post method that I was using until now.
So, I downloaded from their example, this code (I'm posting also the class method to connect by WS)
function Adyen($login, $password, $host ="live", $debug=FALSE ) {
$this->DEBUG = $debug;
$this->client = new SoapClient( "https://pal-$host.adyen.com/pal/Payment.wsdl",
array(
"login" => $login,
"password" => $password,
'trace' => 1,
'soap_version' => SOAP_1_1,
'style' => SOAP_DOCUMENT,
'encoding' => SOAP_LITERAL
)
);
}
function authorise( $amount,$currencyCode,$cardHolder,$cardNumber,$expm,$expy,$cvc,$reference) {
global $merchantAccount;
$response = $this->client->authorise( array(
"paymentRequest" => array
(
"amount" => array (
"value" => $amount,
"currency" => $currencyCode),
"card" => array (
"cvc" => $cvc,
"expiryMonth" => $expm,
"expiryYear" => $expy,
"holderName" => $cardHolder,
"number" => $cardNumber,
),
"merchantAccount" => $merchantAccount,
"reference" => $reference,
)
)
);
When I'm executing this code, it returns this error
#!/usr/bin/php SOAP Error on test SoapFault Object ( [message:protected] => security 010 Not allowed [string:Exception:private] =>
Do you have any suggestions to solve it?
Best Regards.
Edit:
It's too strange, cause with the same method, but with different parameters (In case of the recurring payment, I haven't this error. This the case runs
$response = $this->client->authorise(
array(
"paymentRequest" =>
array(
"amount" => array("value" => $amount,
"currency" => $currencyCode),
"merchantAccount" => $merchantAccount,
"reference" => $reference,
"shopperReference" => $reference",
"shopperEmail" => $email,
"recurring" => array("contract" => "RECURRING"),
"selectedRecurringDetailReference" => "LATEST",
"shopperInteraction" => "ContAuth"
)
)
);
Had the same question, here is the support answer:
You are trying to make an API payment. Please be aware that there are a few downsides using the direct integration API.
Most important, due to strict industry regulations, the Merchant is required to be PCI DSS (Payment Card Industry Data Security Standard) compliant at Level 1 or 2. The PCI DSS certification process requires a big contribution from you in both time and money.
http://en.wikipedia.org/wiki/PCI_DSS
The direct integration also offers a limited set of payment methods and might require you to implement features like the 3D secure mechanism.
The normal integration works as follow:
Redirect the shopper from your website to our Hosted Payment Pages.
Shopper can choose several payment methods and makes the payment.
Shopper is redirected back to your website and we pass back a result code of the payment.
We sent also a notification via SOAP or HTTP Post.
From Adyen documentation
010 Not allowed You are not allowed to perform this action
I think you should send email to their support. May be your account not ready for use.
You need to add your ip in the ca admin area for the user 'Edit Allowed User IP Range'.
I think in this code you have mistakenly put extra double quotes( "shopperReference" => $reference",).
$response = $this->client->authorise(
array(
"paymentRequest" =>
array(
"amount" => array("value" => $amount,
"currency" => $currencyCode),
"merchantAccount" => $merchantAccount,
"reference" => $reference,
"shopperReference" => $reference",
"shopperEmail" => $email,
"recurring" => array("contract" => "RECURRING"),
"selectedRecurringDetailReference" => "LATEST",
"shopperInteraction" => "ContAuth"
)
)
);