Apple Wallet Store card expired before Expiry Date - php

In the application, we have a feature to download the wallet card into the Apple wallet as a contact card.
We have created this wallet contact card from the PHP code - below.
$data = [
'description' => 'MyApp',
'formatVersion' => 1,
'organizationName' => 'My app',
'passTypeIdentifier' => 'pass.test.test',
'serialNumber' => '12345678',
'teamIdentifier' => '*********',
'storeCard' => [
"headerFields" => [
[
"key" => "header-text",
"label" => "Let's connect",
"value" => "Together"
]
],
"auxiliaryFields" => [
[
"key" => "aux-text-two",
"label" => "",
"value" => ""
],
[
"key" => "aux-text-one",
"label" => "www.abc.com",
"value" => ""
]
],
"primaryFields" => [],
'secondaryFields' => [],
'backFields' => [],
],
'barcode' => [
'format' => 'PKBarcodeFormatQR',
'message' => 'https://abc.1-2-3-4-5.xyz/public/myapp/?id='.$userData->token.'',
'messageEncoding' => 'iso-8859-1',
],
"backgroundColor" => "rgb(255,255,255)",
'logoText' => '',
'relevantDate' => date('Y-m-d\TH:i:sP'),
"expirationDate" => "2030-01-01T23:00:00Z",
];
We are requesting an apple wallet card to be generated from the iOS code calling API for this - below.
if PKPassLibrary.isPassLibraryAvailable(){
if let data = try? Data(contentsOf: url){
if let pass = try? PKPass(data: data){
let passLibrary = PKPassLibrary()
if !passLibrary.containsPass(pass),
let passController = PKAddPassesViewController(pass: pass){
passController.delegate = self
self.present(passController, animated: true)
}else{
ShowAlert(message: "contact_card_already_exist".localize(), theme: .error)
}
}
}
}
As screenshots say - it’s valid till 1/1/30, PHP code we have given the expiry date as well, but still, the wallet card is gone to Expired in 2 days.
Any help is appreciated.

Related

How to create a stripe invoice without customer id

I'm trying to generate an invoice through stripe but the API requires a Client ID which I have no idea how to retrieve.
I'm using Session checkout:
method called by ajax
$checkout_session = Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'currency' => 'usd',
'unit_amount' => 2000,
'product_data' => [
'name' => 'Stubborn Attachments',
'images' => ["https://i.imgur.com/EHyR2nP.png"],
],
],
'quantity' => 1,
]],
'customer_email' => $email,
'mode' => 'payment',
'success_url' => $domain. '/success/{CHECKOUT_SESSION_ID}',
'cancel_url' => $domain. '/cancel/{CHECKOUT_SESSION_ID}',
]);
I receive
[
"id" => "cs_test_xxxxxxxxxxxxxxxx"
"object" => "checkout.session"
"allow_promotion_codes" => null
"amount_subtotal" => 2000
"amount_total" => 2000
"billing_address_collection" => null
"cancel_url" => "http://localhost/cancel/{CHECKOUT_SESSION_ID}"
"client_reference_id" => null
"currency" => "usd"
"customer" => null
"customer_details" => null
"customer_email" => "xxxxxxxxxxx#gmail.com"
"livemode" => false
"locale" => null
"metadata" => []
"mode" => "payment"
"payment_intent" => "pi_xxxxxxxxxxxxx"
"payment_method_options" => []
"payment_method_types" => array:1 [
0 => "card"
]
"payment_status" => "unpaid"
"setup_intent" => null
"shipping" => null
"shipping_address_collection" => null
"submit_type" => null
"subscription" => null
"success_url" => "http://localhost/success/{CHECKOUT_SESSION_ID}"
"total_details" => array:3 [
"amount_discount" => 0
"amount_shipping" => 0
"amount_tax" => 0
]
]
Create invoice requires a customer id which I don't have and have no idea where to get since session checkout creates a customer without giving me an id.
A Checkout Session in payment mode will generate a Payment Intent, not an Invoice. If you want to work solely with Invoices, you Checkout Session is not the right solution. If you don't care about Invoices and just want to be able to charge a customer for a one-off payment then you can continue using Checkout.
If you do want to work solely with Invoices, you need to do the following:
Create a Customer
Pass in the Customer ID when you create as many Invoice Items as you need
Pass in the Customer ID when you create an Invoice - this will automatically pull in any pending Invoice Items tied to the customer.
This is all summarized in this guide: https://stripe.com/docs/invoicing/integration

Push notification with pusher beam, unable to send data/payload

I am using following php sdk for generating pusher beam push notification. but there is not information provided in the sdk docs on how to send data/payload along with it. the notification is bean sent correctly but I am unable to send data: please guide me how we can send the data: it is showing hasData as false in beam console, please check:
php sdk i am using : https://github.com/pusher/push-notifications-php
my code look like this:
$pushNotification = new PushNotifications([
'instanceId' => env('BEAM_INSTANCE_ID'),
'secretKey' => env('BEAM_PRIMARY_KEY')
]);
$pushNotification->publishToInterests(
['message-notification'],
[
"apns" => [
"aps" => [
"alert" => "Message Received",
],
],
"fcm" => [
"notification" => [
'title' => 'some title',
'body' => 'some body',
'data' => 'some data', //passing data here but not working
],
],
]
);
I got it working, we can pass data in following way:
$publishResponse = $pushNotifications->publishToInterests(
["donuts"],
[
"apns" => [
"aps" => [
"alert" => "Hello!",
],
],
"fcm" => [
"notification" => [
"title" => "Hello!",
"body" => "Hello, world!",
],
"data" => [ // <==== pass data here
"name" => "adam",
"type" => "user",
],
],
]
);

Changing Cell Colour With Google Sheets API (PHP)

I'm trying to change a ranges colour via the Google Sheets API in PHP.
I have done around an hour of researchig. The code below is as far as I've got.
$requests = [
// Change the spreadsheet's title.
new Google_Service_Sheets_Request([
'updateSpreadsheetProperties' => [
'properties' => [
'title' => "The Title"
],
'fields' => 'title'
],
'UpdateCellsRequest' => [
'properties' => [
'range' => "Sheet1!A1",
'backgroundColor' => "#000"
],
'fields' => ''
]
])
];
// Add additional requests (operations) ...
$batchUpdateRequest = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest([
'requests' => $requests
]);
$response = $GoogleSheetsAPIHandler->sheets->spreadsheets->batchUpdate("SHEETID", $batchUpdateRequest);
print_r($response);
If I take out this:
'UpdateCellsRequest' => [
'properties' => [
'range' => "Sheet1!A1",
'backgroundColor' => "#000"
],
'fields' => ''
]
Then the code works to update the sheets title. However, I can't seem to update a ranges colour.
Any advice would be greatly appreciated!
I believe your goal and situation as follows.
You want to change the background color of cells using googleapis for php.
You have already been able to get and put values for Google Spreadsheet using Sheets API.
Modification points:
When you want to use the batchUpdate method of Sheets API, please put each request to each element of the array of requests.
I think that the request body of UpdateCellsRequest in your script is not correct.
From your question of I'm trying to change a ranges colour via the Google Sheets API in PHP., when you want to change the background color of several cells with one color, I think that RepeatCellRequest might be suitable.
In this answer, I would like to propose a modified script for changing the several cells using one color. When your script is modified, it becomes as follows.
Modified script:
Before you use this, please set the sheet ID.
$requests = [
new Google_Service_Sheets_Request([
'updateSpreadsheetProperties' => [
'properties' => [
'title' => "The Title"
],
'fields' => 'title'
]
]),
new Google_Service_Sheets_Request([
'repeatCell' => [
'cell' => [
'userEnteredFormat' => [
'backgroundColor' => [
'red' => 1,
'green' => 0,
'blue' => 0
]
]
],
'range' => [
'sheetId' => $sheetId, // <--- Please set the sheet ID.
'startRowIndex' => 0,
'endRowIndex' => 3,
'startColumnIndex' => 0,
'endColumnIndex' => 2
],
'fields' => 'userEnteredFormat'
]
])
];
When above request body is used for the batchUpdate method of Sheets API, the title of Spreadsheet is changed and the background color of the cells "A1:B3" changed to the red color.
Wne you want to use UpdateCellsRequest, you can use the following request body. At the following request body, the background colors of cells "A1:B1" are changed to red and green colors, respectively. When UpdateCellsRequest is used, each cell can be updated. About the detail information of UpdateCellsRequest, please check the official document. Ref
$requests = [
new Google_Service_Sheets_Request([
'updateCells' => [
'rows' => array([
'values' => array(
['userEnteredFormat' => [
'backgroundColor' => [
'red' => 1,
'green' => 0,
'blue' => 0
]
]],
['userEnteredFormat' => [
'backgroundColor' => [
'red' => 0,
'green' => 1,
'blue' => 0
]
]]
)
]),
'range' => [
'sheetId' => $sheetId, // <--- Please set the sheet ID.
'startRowIndex' => 0,
'startColumnIndex' => 0,
],
'fields' => 'userEnteredFormat'
]
])
];
References:
UpdateCellsRequest
RepeatCellRequest

how to create multiple payments using PHP SDK Quickbooks

I am creating App for Quickbook in PHP
I am using https://github.com/intuit/QuickBooks-V3-PHP-SDK/
I want to make payments to multiple invoice in single API call.
I see their example but those make single payment. I need multiple payments towards various invoice for different customers.
How that is possible?
Their example code is here:
https://github.com/IntuitDeveloper/SampleApp-CRUD-PHP/blob/master/CRUD_Examples/Payment/PaymentCreate.php
So here's a snippet:
$theResourceObj = Payment::create([
"CustomerRef" =>
[
"value" => "1"
],
"TotalAmt" => 100.00,
"Line" => [
[
"Amount" => 100.00,
"LinkedTxn" => [
[
"TxnId" => "210",
"TxnType" => "Invoice"
]]
]]
]);
$resultingObj = $dataService->Add($theResourceObj);
Then if you refer to their documentation:
https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/payment#the-payment-object
You can see that the Line element is composed of Zero or more transactions accounting for this payment. including The invoice to which payment is applied. i.e. you can repeat things within Line, to apply the payment to more than one invoice.
So applying a payment to more than one invoice lists each individual invoice, and the amount of the payment to apply, in the repeating Line node array:
$theResourceObj = Payment::create([
"CustomerRef" =>
[
"value" => "1"
],
"TotalAmt" => 100.00,
"Line" => [
[
"Amount" => 50.00,
"LinkedTxn" => [
[
"TxnId" => "210",
"TxnType" => "Invoice"
]]
],
[
"Amount" => 25.00,
"LinkedTxn" => [
[
"TxnId" => "211",
"TxnType" => "Invoice"
]]
],
[
"Amount" => 25.00,
"LinkedTxn" => [
[
"TxnId" => "212",
"TxnType" => "Invoice"
]]
],
]
]);
$resultingObj = $dataService->Add($theResourceObj);
Finally I found solution for me.
API have Batch Option to add multiple Objects in single Batch.
Thanks to everyone

Can't update map column of DynamoDB table

I am currently developing a skill for Amazon's echo dot which requires the use of persistent data. I ran into an issue when developing a web interface for my skill where I was not able to easily update the mapAttr column of the DynamoDB table used by the skill.
I've been trying to work this out for the last 2 days, I've looked everywhere including the documentation but can't seem to find anything that'll help me.
This is the code I am using:
$result = $client->updateItem([
'TableName' => 'rememberThisDBNemo',
'Key' => [
'userId' => [ 'S' => $_SESSION['userDataAsk'] ]
],
'ExpressionAttributeNames' => [
'#attr' => 'mapAttr.ReminderJSON'
],
'ExpressionAttributeValues' => [
':val1' => json_encode($value)
],
'UpdateExpression' => 'SET #attr = :val1'
]);
I have tried many different things so this might be just absolutely wrong, but nothing that I have found has worked.
The table has 2 columns, userId and mapAttr, userId is a string and mapAttr is a map. Originally I thought it was simply a JSON string but it was not like that as when I tried to update it with a JSON string directly it would stop working when read by Alexa.
I am only trying to update 1 out of the 2 attributes of mapAttr. That is ReminderJSON which is a string.
Any help would be appreciated. Thanks.
Try calling updateItem like this
$result = $client->updateItem([
'TableName' => 'rememberThisDBNemo',
'Key' => [
'userId' => [ 'S' => $_SESSION['userDataAsk'] ]
],
'ExpressionAttributeNames' => [
'#mapAttr' => 'mapAttr',
'#attr' => 'ReminderJSON'
],
'ExpressionAttributeValues' => [
':val1' => ['S' => json_encode($value)]
],
'UpdateExpression' => 'SET #mapAttr.#attr = :val1'
]);
However, please be aware that in order for this to work, attribute mapAttr must already exist. If it doesn't, you'll get ValidationException saying The document path provided in the update expression is invalid for update...
As a workaround, you may want to add a ConditionExpression => 'attribute_exists(mapAttr)' to your params, catch possible exception, and then perform another update adding a new attribute mapAttr:
try {
$result = $client->updateItem([
'TableName' => 'rememberThisDBNemo',
'Key' => [
'userId' => [ 'S' => $_SESSION['userDataAsk'] ]
],
'ExpressionAttributeNames' => [
'#mapAttr' => 'mapAttr'
'#attr' => 'ReminderJSON'
],
'ExpressionAttributeValues' => [
':val1' => ['S' => json_encode($value)]
],
'UpdateExpression' => 'SET #mapAttr.#attr = :val1'
'ConditionExpression' => 'attribute_exists(#mapAttr)'
]);
} catch (\Aws\Exception\AwsException $e) {
if ($e->getAwsErrorCode() == "ConditionalCheckFailedException") {
$result = $client->updateItem([
'TableName' => 'rememberThisDBNemo',
'Key' => [
'userId' => [ 'S' => $_SESSION['userDataAsk'] ]
],
'ExpressionAttributeNames' => [
'#mapAttr' => 'mapAttr'
],
'ExpressionAttributeValues' => [
':mapValue' => ['M' => ['ReminderJSON' => ['S' => json_encode($value)]]]
],
'UpdateExpression' => 'SET #mapAttr = :mapValue'
'ConditionExpression' => 'attribute_not_exists(#mapAttr)'
]);
}
}

Categories