fixes for Paypal PPCP

This commit is contained in:
David Bomba 2023-10-16 20:49:07 +11:00
parent 1f05c10cea
commit f0dbb10f93
2 changed files with 17 additions and 13 deletions

View File

@ -214,6 +214,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver
public function processPaymentResponse($request)
{
nlog($request['gateway_response']);
$response = json_decode($request['gateway_response'], true);
@ -262,6 +263,8 @@ class PayPalPPCPPaymentDriver extends BaseDriver
$_invoice = collect($this->payment_hash->data->invoices)->first();
nlog($_invoice);
$invoice = Invoice::withTrashed()->find($this->decodePrimaryKey($_invoice->invoice_id));
$order = [
@ -275,8 +278,8 @@ class PayPalPPCPPaymentDriver extends BaseDriver
"address" => [
"address_line_1" => $this->client->address1,
"address_line_2" => $this->client->address2,
"admin_area_1" => $this->client->city,
"admin_area_2" => $this->client->state,
"admin_area_2" => $this->client->city,
"admin_area_1" => $this->client->state,
"postal_code" => $this->client->postal_code,
"country_code" => $this->client->country->iso_3166_2,
]

View File

@ -45,23 +45,24 @@
env: testMode ? 'sandbox' : 'production',
fundingSource: fundingSource,
client: testMode ? sandbox : production,
// Order is created on the server and the order id is returned
createOrder: function(data, actions) {
return orderId;
return orderId;
},
// Finalize the transaction on the server after payer approval
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
document.getElementById("gateway_response").value =JSON.stringify( details );
document.getElementById("server_response").submit();
});
return actions.order.capture().then(function(details) {
document.getElementById("gateway_response").value =JSON.stringify( details );
document.getElementById("server_response").submit();
});
},
onCancel: function() {
window.location.href = "/client/invoices/";
},
onError: function(err) {
console.log(err);
console.log("there was an error")
console.log(err)
// document.getElementById("gateway_response").value =JSON.stringify( err );
// document.getElementById("server_response").submit();
}
}).render('#paypal-button-container');