PayPal Express Checkout: Setting logo_image and name using REST API - api

PayPal's Express Checkout documentation says that you can customize the checkout using the Experience API. And when you go to the Experience API documentation, you see the ability to set a custom name, logo_image, and more.
In our implementation, hiding the shipping fields (no_shipping: 1) works - and that uses the Experience API - but setting the name and logo_image does not.
Code below. Does anyone know if there's a way to set name and/or logo_image?
payment: function(data, actions) {
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '9.99', currency: 'USD' }
}
]
},
experience: {
name: 'Custom Name',
presentation: {
logo_image: 'https://i.imgur.com/customimage.png'
},
input_fields: {
no_shipping: 1
}
}
});
},

Related

Netsuite Rest API Create Non-inventory Item for Sale

I try to create a Non-Inventory Sale item with the NetSuite API.
Here is my request :
Method : POST
Endpoint: /services/rest/record/v1/nonInventorySaleItem
Payload:
{
"itemId": "Test Item",
"IncomeAccount": {
"id": "1315"
},
"deterredRevenueAccount": {
"id": "1343"
},
"itemType": {
"refName": "NonInvtPart"
},
"location": {
"id": "46"
},
"taxSchedule": {"id": "1"}
}
It keeps returning 400 HTTP Error and the message :
Error while accessing a resource. Please enter value(s) for: Tax Schedule.
I tried to work around with a custom entity field and a UserEventScript SuiteScript to update taxSchedule before submit without success.
I spoke with NetSuite support staff and they basically said that the feature isn't supported. If you want you can create a RESTlet and recreate the functionality by accepting the parameters that you want and creating the item that way. Something roughly like this:
define(['N/record'], function(record) {
function post(context) {
if (context.request.method !== 'POST') {
throw {
status: 405,
message: 'Invalid HTTP method',
};
}
// Parse the request body
var requestBody = JSON.parse(context.request.body);
// Create the inventory item record
var itemRecord = record.create({
type: record.Type.INVENTORY_ITEM,
isDynamic: true,
});
// Set the item name, tax schedule, asset account, and cogs account
itemRecord.setValue({
fieldId: 'itemid',
value: requestBody.name,
});
itemRecord.setValue({
fieldId: 'taxschedule',
value: requestBody.taxSchedule,
});
itemRecord.setValue({
fieldId: 'assetaccount',
value: requestBody.assetAccount,
});
itemRecord.setValue({
fieldId: 'cogsaccount',
value: requestBody.cogsAccount,
});
// Save the inventory item record
var itemId = itemRecord.save({
enableSourcing: true,
ignoreMandatoryFields: true,
});
// Return the new inventory item ID
return {
id: itemId,
};
}
return {
post: post,
};
});
Obviously also include any other fields that you want, but I found that the Tax Schedule, COGS account, and asset accounts were all required.

storing qr code in google pay(google wallet)

Is it possible to store information such as QR code in google pay just like apple wallet ? if not is there any alternative ,I have researched certain apps and haven't got any relevant resource yet
Yes, it is possible. Many different types of passes support a Barcode property where type is QR_CODE.
Here is an example on how to set it:
const loyaltyObject = {
id: getLoyaltyId(email),
classId: `${issuerId}.${loyaltyProgram}`,
accountId: email,
accountName: name,
state: 'active',
loyaltyPoints: {
balance: {
int: points,
},
label: 'Points',
},
barcode: {
type: 'qrCode',
value: email,
},
};

Shopify App Billing API: How to offer multiple billing plans?

Shopify's recent July 2020 API update allows billing annually for apps, so I've been trying to add the option to choose between monthly and annual billing to my app.
I've been trying to do this by modifying the GraphQL call that creates the billing plan.
I've been trying several different options, but the most logical one seems to be to add an additional line item. This works in rendering both plans to the billing approval screen, but it is still not possible to actually choose between plans (details for both plans are displayed, but only the latter option is actually effective.
Here's the code I've been working with:
const query = JSON.stringify({
query: `mutation {
appSubscriptionCreate(
name: "Basic Plan"
trialDays: 7
returnUrl: "${process.env.HOST}"
lineItems: [
{
plan: {
appRecurringPricingDetails: {
price: { amount: 4.99, currencyCode: USD }
}
}
plan: {
appRecurringPricingDetails: {
price: { amount: 49.99, currencyCode: USD }
interval: ANNUAL
}
}
}
]
) {
userErrors {
field
message
}
confirmationUrl
appSubscription {
id
}
}
}`
});
I'd be happy about any suggestions.
Thanks a lot!

Youtrack check if user has permissions

I'm trying to create a Youtrack workflow where only a specific role is allowed to edit the Kanban state to ready-to-pull when the current issue is in backlog. I wasn't quite able to get it correctly working, keeps throwing exceptions but I'm unable to read the full exception.
I tried to create the current workflow code:
var entities = require('#jetbrains/youtrack-scripting-api/entities');
var workflow = require('#jetbrains/youtrack-scripting-api/workflow');
exports.rule = entities.Issue.onChange({
title: workflow.i18n('Block change in Kanban stage for issues that are in backlog'),
guard: function(ctx) {
return ctx.issue.isReported && ctx.issue.fields.isChanged(ctx.KanbanState);
},
action: function(ctx) {
var issue = ctx.issue;
if (!ctx.user.hasRole('project-admin', ctx.project)) {
workflow.message('U dont have the correct permissions to do this');
ctx.KanbanState = ctx.KanbanState.Blocked;
}
},
requirements: {
Stage: {
type: entities.State.fieldType
},
KanbanState: {
name: 'Kanban State',
type: entities.EnumField.fieldType,
ReadyToPull: {
name: 'Ready to pull'
},
Blocked: {}
}
}
});
Most of this is a copy from the Kanban change workflow that blocks moving the issue to a new stage when the kanban state isn't set to "Ready-to-Pull". I basically want the exact same, but I want to only allow project admins to change the kanban state to "ready-to-pull" when the current stage is "Backlog". The current code only checks the permissions at the moment, but I started getting stuck there already.
To implement this task, I suggest you use the workflow.check method, for example:
workflow.check(ctx.user.hasRole('project-admin', ctx.project), 'U dont have the correct permissions to do this');
I hope this helps.
Seeing as in our current situation we only need to disable a single person to not be able to change the Kanban states when new tickets are set, we have the following solution:
exports.rule = entities.Issue.onChange({
title: workflow.i18n('Block change in Kanban stage for issues in backlog stage'),
guard: function(ctx) {
var issue = ctx.issue;
return issue.fields.isChanged(ctx.KanbanState);//Runs when Kanban state changes
},
action: function(ctx) {
var issue = ctx.issue;
//Check if user has changed the kanban state to ready to pull while the current stage is backlog.
if (issue.fields.Stage.name == 'Backlog') {
//Current stage is backlog
if (issue.fields.KanbanState.name === ctx.KanbanState.ReadyToPull.name) {
//Kanban state was changed to ready to pull;
var target = '<useremail>';
workflow.check(ctx.currentUser.email == target,
workflow.i18n('No permissions to change the Kanban state.'));
issue.fields.KanbanState = ctx.KanbanState.Blocked;
}
}
},
requirements: {
Stage: {
type: entities.State.fieldType,
Backlog: {},
Development: {}
},
KanbanState: {
name: 'Kanban State',
type: entities.EnumField.fieldType,
ReadyToPull: {
name: 'Ready to pull'
},
Blocked: {}
}
}
});
However I checked the answer of #Oleg Larshun and his answer worked as well. replacing the email section with:
workflow.check(ctx.user.hasRole('project-admin', ctx.project), 'U dont have the correct permissions to do this');

How to generate Items list with vue-paypal-checkout?

I am trying to generate an items list response from paypal checkout requests. I am trying to do it dynamically, using my data objects and some computed properties in a for in loop. As far as I have understood, my items_list will always need to be a data variable, never a hard-coded array.
Here is my template element:
<div v-bind:key="plan.key" v-for="plan in plans" >
<PayPal
:amount="plan.price" // all good
currency="GBP" // all good
:client="credentials" // all good
env="sandbox" // all good
:items="[plan]" // this is NOT working
#payment-authorized="payment_authorized_cb" // all good
#payment-completed="payment_completed_cb" // all good
#payment-cancelled="payment_cancelled_cb" // all good
>
</PayPal>
</div>
Here are my data objects on my script:
plans: {
smallPlan: {
name: 'Small Venue',
price: '6',
},
mediumPlan: {
name: 'Medium Department',
price: '22',
},
}
payment_completed: {
payment_completed_cb() {
}
},
payment_authorized: {
payment_authorized_cb() {
}
},
payment_cancelled: {
payment_cancelled_cb() {
}
},
Here are my methods:
methods: {
payment_completed_cb(res, planName){
toastr.success("Thank you! We'll send you a confirmation email soon with your invoice. ");
console.log(res);
},
payment_authorized_cb(res){
console.log(res);
},
payment_cancelled_cb(res){
toastr.error("The payment process has been canceled. No money was taken from your account.");
console.log(res);
},
The documentation of Vue-paypal-checkout is available here https://www.npmjs.com/package/vue-paypal-checkout
If I don't add the items list :items everything works perfectly:
{"id":"PAY-02N9173803167370DLPMKKZY","intent":"sale","state":"approved","cart":"90B34422XX075534E","create_time":"2018-10-30T18:39:51Z","payer":{"payment_method":"paypal","status":"VERIFIED","payer_info":{"email":"joaoalvesmarrucho-buyer#gmail.com","first_name":"test","middle_name":"test","last_name":"buyer","payer_id":"JCZUFUEQV33WU","country_code":"US","shipping_address":{"recipient_name":"test buyer","line1":"1 Main St","city":"San Jose","state":"CA","postal_code":"95131","country_code":"US"}}},"transactions":[{"amount":{"total":"245.00","currency":"GBP","details":{}},"item_list":{},"related_resources":[{"sale":{"id":"2RA79134UX2301839","state":"pending","payment_mode":"INSTANT_TRANSFER","protection_eligibility":"ELIGIBLE","parent_payment":"PAY-02N9173803167370DLPMKKZY","create_time":"2018-10-30T18:39:50Z","update_time":"2018-10-30T18:39:50Z","reason_code":"RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION","amount":{"total":"245.00","currency":"GBP","details":{"subtotal":"245.00"}}}}]}]}
But if I add :items="[plan]" i get this error message:
Uncaught Error: Error: Request to post https://www.sandbox.paypal.com/v1/payments/payment failed with 400 error. Correlation id: 19238526650f5, 19238526650f5
{
"name": "VALIDATION_ERROR",
"details": [
{
"field": "transactions.item_list.items.item_key",
"issue": "This field name is not defined for this resource type"
}
],
"message": "Invalid request - see details",
"information_link": "https://developer.paypal.com/docs/api/payments/#errors",
"debug_id": "19238526650f5"
Any thoughts?
Also if you happen to know, is there a way to sell/implement a subscription instead of a one-off transaction using Vue-paypal-checkout?
Many thanks