Eu fiz um teste utilizando o gateway do PayPal pra ter certeza que n?o é configura??o, segue o resultado.
Cadastrei um produto de assinatura no valor de R$1,00 com periodo trial e 1 dia para 3 dias de assinatura.
https://postimg.org/image/avuyjmuel/
Fiz o pedido e finalizei a compra utilizando o paypal, digitei os dados do paypal e finalizei o checkout, que gerou o invoice_id #1117. Esse pedido foi gerado com o valor zero por ser trial e passou o status para processando.
Após 1 dia do período de teste (trial), aconteceu o pagamento recorrente da assinatura, que gerou o invoice_id #1135 com o valor de R$1,00.
No Paypal descontou corretamente o valor, ao invés de pegar do pedido que foi criado inicialmente #1117, descontou do pedido correto que foi criado, o #1135.
A assinatura ficou com os pedidos relacionados, #1117 e #1135.
https://postimg.org/image/rek9kxdb9/
O status dos dois pedidos ficaram como “processando”, já que é necessário validar manualmente para completar o pedido.
https://postimg.org/image/nl4tknm6n/
O status da assinatura #1124 está ATIVO, com os 2 pedidos relacionados a assinatura.
https://postimg.org/image/l0d12d0y7/
Minha conclus?o é que o plugin do Iugu contém algum Bug, sen?o para o PayPal também daria errado.
LOG PAYPAL
23-02-2016 -- envio do pedido de assinatura com trial
Subscription Request Parameters: Array
(
[method] => POST
[uri] => https://api-3t.sandbox.paypal.com/nvp
[user-agent] => Assinaturas-PayPal-WooCommerce/2.0.8 (WooCommerce/2.4.11; WordPress/4.2.7)
[headers] => Array
(
)
[body] => Array
(
[USER] => ***************************************
[PWD] => ****************
[SIGNATURE] => ********************************************************
[VERSION] => 124
[METHOD] => SetExpressCheckout
[PAYMENTREQUEST_0_AMT] => 0.00
[PAYMENTREQUEST_0_ITEMAMT] => 0.00
[PAYMENTREQUEST_0_SHIPPINGAMT] => 0.00
[PAYMENTREQUEST_0_TAXAMT] => 0.00
[PAYMENTREQUEST_0_CURRENCYCODE] => BRL
[PAYMENTREQUEST_0_CUSTOM] => {"order_id":1117,"order_key":"wc_order_56cc5852f0746"}
[L_BILLINGTYPE0] => MerchantInitiatedBillingSingleAgreement
[L_BILLINGAGREEMENTDESCRIPTION0] => Pedido com Cardapio Facil
[L_BILLINGAGREEMENTCUSTOM0] => {"order_id":1117,"order_key":"wc_order_56cc5852f0746"}
[RETURNURL] => https://www.cardapiofacil.com/wc-api/wcs_paypal/?action=create_billing_agreement
[CANCELURL] => https://www.cardapiofacil.com/cart/?cancel_order=true&order=wc_order_56cc5852f0746&order_id=1117&redirect&_wpnonce=9c398fb012
[BRANDNAME] => Cardapio Facil
[LANDINGPAGE] => Login
[NOSHIPPING] => 1
[PAYMENTREQUEST_0_PAYMENTACTION] => Sale
[MAXAMT] => 0.00
)
[duration] => 0.8367s
)
-- envio do pedido de assinatura apos o vencimento do periodo trial
02-24-2016 @ 16:31:23 - Subscription Request Parameters: Array
(
[method] => POST
[uri] => https://api-3t.sandbox.paypal.com/nvp
[user-agent] => Assinaturas-PayPal-WooCommerce/2.0.8 (WooCommerce/2.4.11; WordPress/4.2.7)
[headers] => Array
(
)
[body] => Array
(
[USER] => ***************************************
[PWD] => ****************
[SIGNATURE] => ********************************************************
[VERSION] => 124
[METHOD] => DoReferenceTransaction
[REFERENCEID] => B-166792201B487700N
[BUTTONSOURCE] => WooThemes_Cart
[RETURNFMFDETAILS] => 1
[AMT] => 1.00
[CURRENCYCODE] => BRL
[INVNUM] => CardapioFacil-1135
[PAYMENTACTION] => Sale
[NOTIFYURL] => https://www.cardapiofacil.com/wc-api/WC_Gateway_Paypal/
[CUSTOM] => {"order_id":1135,"order_key":"wc_order_56cddad4aafa7"}
[L_PAYMENTREQUEST_0_NAME0] => Mensal-Teste
[L_PAYMENTREQUEST_0_AMT0] => 1.00
[L_PAYMENTREQUEST_0_QTY0] => 1
[PAYMENTREQUEST_0_ITEMAMT] => 1.00
[PAYMENTREQUEST_0_SHIPPINGAMT] => 0.00
[PAYMENTREQUEST_0_TAXAMT] => 0.00
)
[duration] => 6.79019s
)
02-24-2016 @ 16:31:23 - Subscription Request Response: Array
(
[code] => 200
[message] => OK
[headers] => Array
(
[date] => Wed, 24 Feb 2016 16:31:17 GMT
[server] => Apache
[x-paypal-operation-name] => DoReferenceTransaction
[x-paypal-api-rc] =>
[connection] => close
[http_x_pp_az_locator] => slcsb
[content-length] => 442
[paypal-debug-id] => 5b03cd515e8e6
[set-cookie] => Array
(
[0] => X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D1880%26app%3Dappdispatcher_apit%26TIME%3D3587886422; domain=.paypal.com; path=/; Secure; HttpOnly
[1] => X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
)
[content-type] => text/plain; charset=utf-8
)
[body] => Array
(
[BILLINGAGREEMENTID] => B-166792201B487700N
[TIMESTAMP] => 2016-02-24T16:31:23Z
[CORRELATIONID] => 5b03cd515e8e6
[ACK] => Success
[VERSION] => 124
[BUILD] => 18778392
[TRANSACTIONID] => 54C27287M03645123
[TRANSACTIONTYPE] => merchtpmt
[PAYMENTTYPE] => instant
[ORDERTIME] => 2016-02-24T16:31:22Z
[AMT] => 1.00
[FEEAMT] => 0.43
[TAXAMT] => 0.00
[CURRENCYCODE] => BRL
[PAYMENTSTATUS] => Completed
[PENDINGREASON] => None
[REASONCODE] => None
[PROTECTIONELIGIBILITY] => Ineligible
[PROTECTIONELIGIBILITYTYPE] => None
)
)
LOG IUGU
02-16-2016 @ 15:02:17 - Creating customer payment method for order 1075...
02-16-2016 @ 15:02:17 - Creating customer...
02-16-2016 @ 15:02:18 - Customer created successfully!
02-16-2016 @ 15:02:19 - Customer payment method created successfully!
02-17-2016 @ 15:24:56 - Processing a subscription payment for order 1075
02-17-2016 @ 15:24:56 - Doing charge for order 1075...
02-17-2016 @ 15:24:59 - Creating an invoice on Iugu for order 1075 with the following data: Array
(
[email] => [email protected]
[due_date] => 18-02-2016
[return_url] => https://www.cardapiofacil.com/checkout/order-received/1075?key=wc_order_56c339f8a8ac0
[expired_url] => https://www.cardapiofacil.com/cart/?cancel_order=true&order=wc_order_56c339f8a8ac0&order_id=1075&redirect&_wpnonce=2e44d4daa7
[notification_url] => https://www.cardapiofacil.com/wc-api/WC_Iugu_Credit_Card_Addons_Gateway/
[ignore_due_email] => 1
[payable_with] => credit_card
[custom_variables] => Array
(
[0] => Array
(
[name] => order_id
[value] => 1075
)
)
[items] => Array
(
[0] => Array
(
[description] => Mensal-Teste - Cardápio Anuncios: Teste Cardapio Facil
[price_cents] => 000
[quantity] => 1
)
)
)
02-17-2016 @ 15:25:00 - Error while generating the invoice for order 1075: Array
(
[headers] => Array
(
[cache-control] => no-cache
[content-type] => application/json; charset=utf-8
[date] => Wed, 17 Feb 2016 15:25:01 GMT
[server] => nginx/1.4.6 (Ubuntu)
[status] => 422 Unprocessable Entity
[x-rack-cache] => invalidate, pass
[x-request-id] => b94ff3314ef7ee642281e56c95189e36
[x-runtime] => 0.052737
[x-ua-compatible] => IE=Edge,chrome=1
[content-length] => 45
[connection] => Close
)
[body] => {"errors":{"total":["deve ser maior que 0"]}}
[response] => Array
(
[code] => 422
[message] => Unprocessable Entity
)
[cookies] => Array
(
)
[filename] =>
)
02-17-2016 @ 15:25:00 - Error while doing the charge for order 1075: Missing the invoice ID.
02-17-2016 @ 23:41:16 - Creating customer payment method for order 1089...
02-17-2016 @ 23:41:16 - Creating customer...
02-17-2016 @ 23:41:18 - Customer created successfully!
02-17-2016 @ 23:41:19 - Customer payment method created successfully!
02-18-2016 @ 23:45:52 - Processing a subscription payment for order 1089
02-18-2016 @ 23:45:52 - Doing charge for order 1089...
02-18-2016 @ 23:45:52 - Creating an invoice on Iugu for order 1089 with the following data: Array
(
[email] => [email protected]
[due_date] => 19-02-2016
[return_url] => https://www.cardapiofacil.com/checkout/order-received/1089?key=wc_order_56c503307ef3e
[expired_url] => https://www.cardapiofacil.com/cart/?cancel_order=true&order=wc_order_56c503307ef3e&order_id=1089&redirect&_wpnonce=999b6fb32c
[notification_url] => https://www.cardapiofacil.com/wc-api/WC_Iugu_Credit_Card_Addons_Gateway/
[ignore_due_email] => 1
[payable_with] => credit_card
[custom_variables] => Array
(
[0] => Array
(
[name] => order_id
[value] => 1089
)
)
[items] => Array
(
[0] => Array
(
[description] => Mensal-Teste
[price_cents] => 000
[quantity] => 1
)
)
)
02-18-2016 @ 23:45:53 - Error while generating the invoice for order 1089: Array
(
[headers] => Array
(
[cache-control] => no-cache
[content-type] => application/json; charset=utf-8
[date] => Thu, 18 Feb 2016 23:46:09 GMT
[server] => nginx/1.4.6 (Ubuntu)
[status] => 422 Unprocessable Entity
[x-rack-cache] => invalidate, pass
[x-request-id] => 16f548eeb0fea627969f310b7d67d91c
[x-runtime] => 0.071531
[x-ua-compatible] => IE=Edge,chrome=1
[content-length] => 45
[connection] => Close
)
[body] => {"errors":{"total":["deve ser maior que 0"]}}
[response] => Array
(
[code] => 422
[message] => Unprocessable Entity
)
[cookies] => Array
(
)
[filename] =>
)
02-18-2016 @ 23:45:53 - Error while doing the charge for order 1089: Missing the invoice ID.