de almacoop: soportar instrucciones especiales
This commit is contained in:
parent
2ebc2db286
commit
a1fd00908b
1 changed files with 11 additions and 7 deletions
|
@ -4,7 +4,7 @@ import { CartBaseController } from './cart_base_controller'
|
||||||
* Retrieves payment methods and redirect to external checkouts
|
* Retrieves payment methods and redirect to external checkouts
|
||||||
*/
|
*/
|
||||||
export default class extends CartBaseController {
|
export default class extends CartBaseController {
|
||||||
static targets = [ 'form', 'submit' ]
|
static targets = [ 'form', 'submit', 'specialInstructions' ]
|
||||||
|
|
||||||
async connect () {
|
async connect () {
|
||||||
const orderToken = this.token
|
const orderToken = this.token
|
||||||
|
@ -42,17 +42,21 @@ export default class extends CartBaseController {
|
||||||
|
|
||||||
const payment_method_id = this.formTarget.elements.payment_method_id.value
|
const payment_method_id = this.formTarget.elements.payment_method_id.value
|
||||||
const orderToken = this.token
|
const orderToken = this.token
|
||||||
|
const special_instructions = this.specialInstructionsTarget.value.trim()
|
||||||
|
|
||||||
// XXX: Currently SpreeClient expects us to send payment source
|
// XXX: Currently SpreeClient expects us to send payment source
|
||||||
// attributes as if it were a credit card.
|
// attributes as if it were a credit card.
|
||||||
let response = await this.spree.checkout.orderUpdate({ orderToken },
|
let response = await this.spree.checkout.orderUpdate({ orderToken },
|
||||||
{
|
{
|
||||||
order: { payments_attributes: [{ payment_method_id }] },
|
order: {
|
||||||
payment_source: {
|
special_instructions,
|
||||||
[payment_method_id]: {
|
payments_attributes: [{ payment_method_id }] },
|
||||||
name: 'Pepitx',
|
payment_source: {
|
||||||
month: 12,
|
[payment_method_id]: {
|
||||||
year: 2020
|
name: 'Pepitx',
|
||||||
|
month: 12,
|
||||||
|
year: 2020
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue